From da070373c4ff340135306b593a16d601daabc6ea Mon Sep 17 00:00:00 2001 From: Paulo Custodio Date: Wed, 3 Nov 2021 11:07:35 +0000 Subject: Add Python solution to challenge 116 --- challenge-001/paulo-custodio/test.pl | 2 +- challenge-116/paulo-custodio/Makefile | 2 ++ challenge-116/paulo-custodio/python/ch-1.py | 52 +++++++++++++++++++++++++++++ challenge-116/paulo-custodio/python/ch-2.py | 37 ++++++++++++++++++++ challenge-116/paulo-custodio/test.pl | 4 --- 5 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 challenge-116/paulo-custodio/Makefile create mode 100644 challenge-116/paulo-custodio/python/ch-1.py create mode 100644 challenge-116/paulo-custodio/python/ch-2.py delete mode 100755 challenge-116/paulo-custodio/test.pl diff --git a/challenge-001/paulo-custodio/test.pl b/challenge-001/paulo-custodio/test.pl index c8dc2b9f75..7efe038555 100644 --- a/challenge-001/paulo-custodio/test.pl +++ b/challenge-001/paulo-custodio/test.pl @@ -148,7 +148,7 @@ sub build { return "bf $prog_wo_ext.bf"; } if (/^c$/) { - run("gcc $prog -o $prog_wo_ext -lmpfr -lgmp") if (!-f $exe || -M $exe > -M $prog); + run("gcc $prog -o $prog_wo_ext -lm -lmpfr -lgmp") if (!-f $exe || -M $exe > -M $prog); return $exe; } if (/^cpp$/) { diff --git a/challenge-116/paulo-custodio/Makefile b/challenge-116/paulo-custodio/Makefile new file mode 100644 index 0000000000..c3c762d746 --- /dev/null +++ b/challenge-116/paulo-custodio/Makefile @@ -0,0 +1,2 @@ +all: + perl ../../challenge-001/paulo-custodio/test.pl diff --git a/challenge-116/paulo-custodio/python/ch-1.py b/challenge-116/paulo-custodio/python/ch-1.py new file mode 100644 index 0000000000..4dd2b06e2c --- /dev/null +++ b/challenge-116/paulo-custodio/python/ch-1.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 + +# Challenge 116 +# +# TASK #1 - Number Sequence +# Submitted by: Mohammad S Anwar +# You are given a number $N >= 10. +# +# Write a script to split the given number such that the difference between two +# consecutive numbers is always 1 and it shouldn't have leading 0. +# +# Print the given number if it impossible to split the number. +# +# Example +# Input: $N = 1234 +# Output: 1,2,3,4 +# +# Input: $N = 91011 +# Output: 9,10,11 +# +# Input: $N = 10203 +# Output: 10203 as it is impossible to split satisfying the conditions. + +import sys +import re + +def print_sequences(rest): + def worker(rest, prev): + found_solution = False + if rest=='': + if not found_solution: + print(",".join(prev)) + found_solution = True + else: + for i in range(1, len(rest)+1): + pref = rest[:i] + suff = rest[i:] + if not re.match(r"^0", suff): + if len(prev) > 0: + if int(prev[-1])+1 == int(pref): + if not found_solution: + if worker(suff, [*prev, pref]): + found_solution = True + else: + if not found_solution: + if worker(suff, [*prev, pref]): + found_solution = True + return found_solution + + return worker(rest, []) + +print_sequences(sys.argv[1]) diff --git a/challenge-116/paulo-custodio/python/ch-2.py b/challenge-116/paulo-custodio/python/ch-2.py new file mode 100644 index 0000000000..5d538ff59e --- /dev/null +++ b/challenge-116/paulo-custodio/python/ch-2.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 + +# Challenge 116 +# +# TASK #2 - Sum of Squares +# Submitted by: Mohammad Meraj Zia +# You are given a number $N >= 10. +# +# Write a script to find out if the given number $N is such that sum of squares +# of all digits is a perfect square. Print 1 if it is otherwise 0. +# +# Example +# Input: $N = 34 +# Ouput: 1 as 3^2 + 4^2 => 9 + 16 => 25 => 5^2 +# +# Input: $N = 50 +# Output: 1 as 5^2 + 0^2 => 25 + 0 => 25 => 5^2 +# +# Input: $N = 52 +# Output: 0 as 5^2 + 2^2 => 25 + 4 => 29 + +import sys +import math + +def sum_of_squares_is_perfect_square(num): + if num < 10: + return False + sum = 0 + for digit in [int(x) for x in str(num)]: + sum += digit**2 + sqint = int(math.sqrt(sum)) + return sqint**2 == sum + +if sum_of_squares_is_perfect_square(int(sys.argv[1])): + print(1) +else: + print(0) diff --git a/challenge-116/paulo-custodio/test.pl b/challenge-116/paulo-custodio/test.pl deleted file mode 100755 index ba6c37260b..0000000000 --- a/challenge-116/paulo-custodio/test.pl +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env perl -use Modern::Perl; -use Test::More; -require '../../challenge-001/paulo-custodio/test.pl'; -- cgit From 0e3775f53fc56ed1528f508e80450ef85884d6ff Mon Sep 17 00:00:00 2001 From: Paulo Custodio Date: Wed, 3 Nov 2021 14:55:57 +0000 Subject: Add Python solution to challenge 115 --- challenge-115/paulo-custodio/Makefile | 2 ++ challenge-115/paulo-custodio/python/ch-1.py | 43 +++++++++++++++++++++++++++++ challenge-115/paulo-custodio/python/ch-2.py | 39 ++++++++++++++++++++++++++ challenge-115/paulo-custodio/test.pl | 4 --- 4 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 challenge-115/paulo-custodio/Makefile create mode 100644 challenge-115/paulo-custodio/python/ch-1.py create mode 100644 challenge-115/paulo-custodio/python/ch-2.py delete mode 100755 challenge-115/paulo-custodio/test.pl diff --git a/challenge-115/paulo-custodio/Makefile b/challenge-115/paulo-custodio/Makefile new file mode 100644 index 0000000000..c3c762d746 --- /dev/null +++ b/challenge-115/paulo-custodio/Makefile @@ -0,0 +1,2 @@ +all: + perl ../../challenge-001/paulo-custodio/test.pl diff --git a/challenge-115/paulo-custodio/python/ch-1.py b/challenge-115/paulo-custodio/python/ch-1.py new file mode 100644 index 0000000000..cd2ec0c787 --- /dev/null +++ b/challenge-115/paulo-custodio/python/ch-1.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +# Challenge 115 +# +# TASK #1 - String Chain +# Submitted by: Mohammad S Anwar +# You are given an array of strings. +# +# Write a script to find out if the given strings can be chained to form a +# circle. Print 1 if found otherwise 0. +# +# A string $S can be put before another string $T in circle if the last +# character of $S is same as first character of $T. +# +# Examples: +# Input: @S = ("abc", "dea", "cd") +# Output: 1 as we can form circle e.g. "abc", "cd", "dea". +# +# Input: @S = ("ade", "cbd", "fgh") +# Output: 0 as we can't form circle. + +import sys + +def is_circle(words): + def worker(pending, path): + found_solution = False + if len(pending)==0: + if not found_solution: + found_solution = path[-1][-1] == path[0][0] + else: + for word in pending: + if len(path)==0 or path[-1][-1] == word[0]: + new_pending = list(filter(lambda x:x != word, pending)) + if not found_solution: + found_solution = worker(new_pending, [*path, word]) + return found_solution + + return worker(words, []) + +if is_circle(sys.argv[1:]): + print(1) +else: + print(0) diff --git a/challenge-115/paulo-custodio/python/ch-2.py b/challenge-115/paulo-custodio/python/ch-2.py new file mode 100644 index 0000000000..1e080c88f2 --- /dev/null +++ b/challenge-115/paulo-custodio/python/ch-2.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +# Challenge 115 +# +# TASK #2 - Largest Multiple +# Submitted by: Mohammad S Anwar +# You are given a list of positive integers (0-9), single digit. +# +# Write a script to find the largest multiple of 2 that can be formed from the +# list. +# +# Examples +# Input: @N = (1, 0, 2, 6) +# Output: 6210 +# +# Input: @N = (1, 4, 2, 8) +# Output: 8412 +# +# Input: @N = (4, 1, 7, 6) +# Output: 7614 + +import sys + +def largest_mult2(nums): + # select smallest even number for last element + even = list(filter(lambda x: x%2 == 0, nums)) + if len(even)==0: + return 0 # no even numbers + even.sort() + last = even[0] + + # sort the other elements in descending order + nums = list(filter(lambda x: x!=last, nums)) + nums.sort() + nums = nums[::-1] + + return int("".join([str(x) for x in [*nums, last]])) + +print(largest_mult2([int(x) for x in sys.argv[1:]])) diff --git a/challenge-115/paulo-custodio/test.pl b/challenge-115/paulo-custodio/test.pl deleted file mode 100755 index ba6c37260b..0000000000 --- a/challenge-115/paulo-custodio/test.pl +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env perl -use Modern::Perl; -use Test::More; -require '../../challenge-001/paulo-custodio/test.pl'; -- cgit From dd979819d8042c04464033dcff0c2853546e34c1 Mon Sep 17 00:00:00 2001 From: Paulo Custodio Date: Wed, 3 Nov 2021 15:22:21 +0000 Subject: Add Python solution to challenge 114 --- challenge-114/paulo-custodio/Makefile | 2 ++ challenge-114/paulo-custodio/python/ch-1.py | 31 ++++++++++++++++++++++++ challenge-114/paulo-custodio/python/ch-2.py | 37 +++++++++++++++++++++++++++++ challenge-114/paulo-custodio/test.pl | 4 ---- 4 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 challenge-114/paulo-custodio/Makefile create mode 100644 challenge-114/paulo-custodio/python/ch-1.py create mode 100644 challenge-114/paulo-custodio/python/ch-2.py delete mode 100755 challenge-114/paulo-custodio/test.pl diff --git a/challenge-114/paulo-custodio/Makefile b/challenge-114/paulo-custodio/Makefile new file mode 100644 index 0000000000..c3c762d746 --- /dev/null +++ b/challenge-114/paulo-custodio/Makefile @@ -0,0 +1,2 @@ +all: + perl ../../challenge-001/paulo-custodio/test.pl diff --git a/challenge-114/paulo-custodio/python/ch-1.py b/challenge-114/paulo-custodio/python/ch-1.py new file mode 100644 index 0000000000..e9e2967b0c --- /dev/null +++ b/challenge-114/paulo-custodio/python/ch-1.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +# Challenge 114 +# +# TASK #1 - Next Palindrome Number +# Submitted by: Mohammad S Anwar +# You are given a positive integer $N. +# +# Write a script to find out the next Palindrome Number higher than the given +# integer $N. +# +# Example +# Input: $N = 1234 +# Output: 1331 +# +# Input: $N = 999 +# Output: 1001 + +import sys + +def is_palindrome(n): + rev_n = int(str(n)[::-1]) + return n==rev_n + +def next_palindrome(n): + while True: + n += 1 + if is_palindrome(n): + return n + +print(next_palindrome(int(sys.argv[1]))) diff --git a/challenge-114/paulo-custodio/python/ch-2.py b/challenge-114/paulo-custodio/python/ch-2.py new file mode 100644 index 0000000000..09f6731bbc --- /dev/null +++ b/challenge-114/paulo-custodio/python/ch-2.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 + +# Challenge 114 +# +# TASK #2 - Higher Integer Set Bits +# Submitted by: Mohammad S Anwar +# You are given a positive integer $N. +# +# Write a script to find the next higher integer having the same number of +# 1 bits in binary representation as $N. +# +# Example +# Input: $N = 3 +# Output: 5 +# +# Binary representation of $N is 011. There are two 1 bits. So the next higher +# integer is 5 having the same the number of 1 bits i.e. 101. +# +# Input: $N = 12 +# Output: 17 +# +# Binary representation of $N is 1100. There are two 1 bits. So the next higher +# integer is 17 having the same number of 1 bits i.e. 10001. + +import sys + +def num_1bits(n): + return sum([int(x) for x in "{:b}".format(n)]) + +def next_same_1bits(n): + num1s = num_1bits(n) + while True: + n += 1 + if num_1bits(n)==num1s: + return n + +print(next_same_1bits(int(sys.argv[1]))) diff --git a/challenge-114/paulo-custodio/test.pl b/challenge-114/paulo-custodio/test.pl deleted file mode 100755 index ba6c37260b..0000000000 --- a/challenge-114/paulo-custodio/test.pl +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env perl -use Modern::Perl; -use Test::More; -require '../../challenge-001/paulo-custodio/test.pl'; -- cgit From d12a3c58624c219f252e34b926797aa1b68a69fa Mon Sep 17 00:00:00 2001 From: Paulo Custodio Date: Wed, 3 Nov 2021 16:10:13 +0000 Subject: use Modern::Perl --- challenge-001/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-001/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-002/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-002/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-005/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-005/paulo-custodio/perl/ch-2.pl | 5 +---- challenge-006/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-006/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-007/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-007/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-008/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-008/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-009/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-009/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-010/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-010/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-011/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-011/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-012/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-012/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-013/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-013/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-013/paulo-custodio/test.pl | 4 +--- challenge-014/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-014/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-014/paulo-custodio/test.pl | 4 +--- challenge-015/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-015/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-015/paulo-custodio/test.pl | 4 +--- challenge-016/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-016/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-016/paulo-custodio/test.pl | 4 +--- challenge-017/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-017/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-017/paulo-custodio/test.pl | 4 +--- challenge-018/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-018/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-018/paulo-custodio/test.pl | 4 +--- challenge-019/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-019/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-019/paulo-custodio/test.pl | 4 +--- challenge-020/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-020/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-020/paulo-custodio/test.pl | 4 +--- challenge-021/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-021/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-021/paulo-custodio/test.pl | 4 +--- challenge-022/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-022/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-022/paulo-custodio/test.pl | 4 +--- challenge-023/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-023/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-023/paulo-custodio/test.pl | 4 +--- challenge-024/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-024/paulo-custodio/test.pl | 4 +--- challenge-025/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-025/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-025/paulo-custodio/test.pl | 4 +--- challenge-026/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-026/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-026/paulo-custodio/test.pl | 4 +--- challenge-076/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-076/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-076/paulo-custodio/test.pl | 4 +--- challenge-077/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-077/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-077/paulo-custodio/test.pl | 4 +--- challenge-078/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-078/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-078/paulo-custodio/test.pl | 4 +--- challenge-079/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-079/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-079/paulo-custodio/test.pl | 4 +--- challenge-080/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-080/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-080/paulo-custodio/test.pl | 4 +--- challenge-081/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-081/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-081/paulo-custodio/test.pl | 4 +--- challenge-082/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-082/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-082/paulo-custodio/test.pl | 4 +--- challenge-083/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-083/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-083/paulo-custodio/test.pl | 4 +--- challenge-084/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-084/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-084/paulo-custodio/test.pl | 4 +--- challenge-085/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-085/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-085/paulo-custodio/test.pl | 4 +--- challenge-086/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-086/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-086/paulo-custodio/test.pl | 4 +--- challenge-087/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-087/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-087/paulo-custodio/test.pl | 4 +--- challenge-088/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-088/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-088/paulo-custodio/test.pl | 4 +--- challenge-092/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-092/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-093/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-093/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-094/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-094/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-094/paulo-custodio/test.pl | 4 +--- challenge-095/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-095/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-095/paulo-custodio/test.pl | 4 +--- challenge-096/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-096/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-096/paulo-custodio/perl/ch-2a.pl | 4 +--- challenge-097/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-097/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-098/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-098/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-099/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-099/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-100/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-100/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-101/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-101/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-102/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-102/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-103/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-103/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-104/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-104/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-105/paulo-custodio/perl/ch-1.pl | 4 +--- challenge-105/paulo-custodio/perl/ch-2.pl | 4 +--- challenge-105/paulo-custodio/t/bc.t | 4 +--- 132 files changed, 132 insertions(+), 397 deletions(-) diff --git a/challenge-001/paulo-custodio/perl/ch-1.pl b/challenge-001/paulo-custodio/perl/ch-1.pl index f8a9a4ee24..4305519c76 100644 --- a/challenge-001/paulo-custodio/perl/ch-1.pl +++ b/challenge-001/paulo-custodio/perl/ch-1.pl @@ -7,9 +7,7 @@ # ‘Perl Weekly Challenge’. Also print the number of times the character ‘e’ # is found in the string. -use strict; -use warnings; -use 5.030; +use Modern::Perl; my $s = @ARGV ? "@ARGV" : "Perl Weekly Challenge"; say(($s =~ tr/e/E/), " ", $s); diff --git a/challenge-001/paulo-custodio/perl/ch-2.pl b/challenge-001/paulo-custodio/perl/ch-2.pl index f17660f213..210d1364ca 100644 --- a/challenge-001/paulo-custodio/perl/ch-2.pl +++ b/challenge-001/paulo-custodio/perl/ch-2.pl @@ -8,9 +8,7 @@ # ‘fizz’ and any divisible by 5 by the word ‘buzz’. Those numbers that are both # divisible by 3 and 5 become ‘fizzbuzz’. -use strict; -use warnings; -use 5.030; +use Modern::Perl; my $n = shift || 20; for (1 .. $n) { diff --git a/challenge-002/paulo-custodio/perl/ch-1.pl b/challenge-002/paulo-custodio/perl/ch-1.pl index bb82c75446..8bafbe57a7 100644 --- a/challenge-002/paulo-custodio/perl/ch-1.pl +++ b/challenge-002/paulo-custodio/perl/ch-1.pl @@ -5,9 +5,7 @@ # Challenge #1 # Write a script or one-liner to remove leading zeros from positive numbers. -use strict; -use warnings; -use 5.030; +use Modern::Perl; my($N) = @ARGV; $N =~ s/^0+(\d)/$1/; diff --git a/challenge-002/paulo-custodio/perl/ch-2.pl b/challenge-002/paulo-custodio/perl/ch-2.pl index 487857b096..bad58bb556 100644 --- a/challenge-002/paulo-custodio/perl/ch-2.pl +++ b/challenge-002/paulo-custodio/perl/ch-2.pl @@ -7,9 +7,7 @@ # representation, using the characters 0-9 and A-Y. Dave Jacoby came up # with nice description about base35, in case you needed some background. -use strict; -use warnings; -use 5.030; +use Modern::Perl; use constant { BASE => 35 }; my @digits = ('0'..'9','A'..'Z'); diff --git a/challenge-005/paulo-custodio/perl/ch-1.pl b/challenge-005/paulo-custodio/perl/ch-1.pl index c2dedd115b..cd33db9b46 100644 --- a/challenge-005/paulo-custodio/perl/ch-1.pl +++ b/challenge-005/paulo-custodio/perl/ch-1.pl @@ -8,9 +8,7 @@ # create a hash of all words in dictionary where key is sorted list of letters # therefore two anagrams have the same key -use strict; -use warnings; -use 5.030; +use Modern::Perl; # get input my($word) = @ARGV; diff --git a/challenge-005/paulo-custodio/perl/ch-2.pl b/challenge-005/paulo-custodio/perl/ch-2.pl index 3707709bef..59ab0fb365 100644 --- a/challenge-005/paulo-custodio/perl/ch-2.pl +++ b/challenge-005/paulo-custodio/perl/ch-2.pl @@ -8,10 +8,7 @@ # create a hash of all words in dictionary where key is sorted list of letters # therefore two anagrams have the same key -use strict; -use warnings; -use 5.030; - +use Modern::Perl; # read dictionary, count number of keys, i.e. anagrams my %anagrams; diff --git a/challenge-006/paulo-custodio/perl/ch-1.pl b/challenge-006/paulo-custodio/perl/ch-1.pl index 94fc7119bb..726898318c 100644 --- a/challenge-006/paulo-custodio/perl/ch-1.pl +++ b/challenge-006/paulo-custodio/perl/ch-1.pl @@ -7,9 +7,7 @@ # same in the compact form. For example, if you pass "1,2,3,4,9,10,14,15,16" # then it should print the compact form like "1-4,9,10,14-16". -use strict; -use warnings; -use 5.030; +use Modern::Perl; my @nums = sort {$a<=>$b} split /\D+/, "@ARGV"; while (@nums) { diff --git a/challenge-006/paulo-custodio/perl/ch-2.pl b/challenge-006/paulo-custodio/perl/ch-2.pl index 053b9e377e..748a86aaa5 100644 --- a/challenge-006/paulo-custodio/perl/ch-2.pl +++ b/challenge-006/paulo-custodio/perl/ch-2.pl @@ -10,9 +10,7 @@ # gives only 15 to 17 significant decimal digits # Therefore must use the bignum library -use strict; -use warnings; -use 5.030; +use Modern::Perl; use Math::BigFloat; my $accuracy = 128; diff --git a/challenge-007/paulo-custodio/perl/ch-1.pl b/challenge-007/paulo-custodio/perl/ch-1.pl index 397e5aeaa7..5055e7c2ef 100644 --- a/challenge-007/paulo-custodio/perl/ch-1.pl +++ b/challenge-007/paulo-custodio/perl/ch-1.pl @@ -7,9 +7,7 @@ # A niven number is a non-negative number that is divisible by the sum of its # digits. -use strict; -use warnings; -use 5.030; +use Modern::Perl; sub solve { my($max) = @_; diff --git a/challenge-007/paulo-custodio/perl/ch-2.pl b/challenge-007/paulo-custodio/perl/ch-2.pl index e4510e5786..b5c3fde14f 100644 --- a/challenge-007/paulo-custodio/perl/ch-2.pl +++ b/challenge-007/paulo-custodio/perl/ch-2.pl @@ -36,9 +36,7 @@ # to a random from the word list) or isnt in the word list, return an empty # list. -use strict; -use warnings; -use 5.030; +use Modern::Perl; # get arguments sub get_args { diff --git a/challenge-008/paulo-custodio/perl/ch-1.pl b/challenge-008/paulo-custodio/perl/ch-1.pl index 7aa272bd0a..41a8010327 100644 --- a/challenge-008/paulo-custodio/perl/ch-1.pl +++ b/challenge-008/paulo-custodio/perl/ch-1.pl @@ -8,9 +8,7 @@ # except itself). Please check Wiki for more information. This challenge was # proposed by Laurent Rosenfeld. -use strict; -use warnings; -use 5.030; +use Modern::Perl; # check if number is prime sub is_prime { diff --git a/challenge-008/paulo-custodio/perl/ch-2.pl b/challenge-008/paulo-custodio/perl/ch-2.pl index 3dd165177d..09e628d446 100644 --- a/challenge-008/paulo-custodio/perl/ch-2.pl +++ b/challenge-008/paulo-custodio/perl/ch-2.pl @@ -8,9 +8,7 @@ # lines of text so that if they were printed, the text would be centered, and # return the modified lines. -use strict; -use warnings; -use 5.030; +use Modern::Perl; sub center { my(@lines) = @_; diff --git a/challenge-009/paulo-custodio/perl/ch-1.pl b/challenge-009/paulo-custodio/perl/ch-1.pl index 91efe2ef54..bbcc219e00 100644 --- a/challenge-009/paulo-custodio/perl/ch-1.pl +++ b/challenge-009/paulo-custodio/perl/ch-1.pl @@ -6,9 +6,7 @@ # Write a script that finds the first square number that has at least 5 distinct # digits. This was proposed by Laurent Rosenfeld. -use strict; -use warnings; -use 5.030; +use Modern::Perl; sub num_diff_digits { my($n) = @_; diff --git a/challenge-009/paulo-custodio/perl/ch-2.pl b/challenge-009/paulo-custodio/perl/ch-2.pl index 7ef887ef13..92345e0f38 100644 --- a/challenge-009/paulo-custodio/perl/ch-2.pl +++ b/challenge-009/paulo-custodio/perl/ch-2.pl @@ -13,9 +13,7 @@ # ranking number, and the next item(s) receive the immediately following # ranking number. -use strict; -use warnings; -use 5.030; +use Modern::Perl; # in: list of numbers # out: list of items with the same value reverse-ordered by value diff --git a/challenge-010/paulo-custodio/perl/ch-1.pl b/challenge-010/paulo-custodio/perl/ch-1.pl index 29f084a0c3..a259f7de67 100644 --- a/challenge-010/paulo-custodio/perl/ch-1.pl +++ b/challenge-010/paulo-custodio/perl/ch-1.pl @@ -7,9 +7,7 @@ # numeral CCXLVI, it should return 246. Similarly, for decimal number 39, it # should return XXXIX. Checkout wikipedia page for more information. -use strict; -use warnings; -use 5.030; +use Modern::Perl; my %ROMAN = ( M => 1000, D => 500, C => 100, L => 50, X => 10, V => 5, I => 1 ); my $RE = qr/[MDCLXVI]/i; diff --git a/challenge-010/paulo-custodio/perl/ch-2.pl b/challenge-010/paulo-custodio/perl/ch-2.pl index a55e5512d9..85cbea9272 100644 --- a/challenge-010/paulo-custodio/perl/ch-2.pl +++ b/challenge-010/paulo-custodio/perl/ch-2.pl @@ -6,9 +6,7 @@ # Write a script to find Jaro-Winkler distance between two strings. For more # information check wikipedia page. -use strict; -use warnings; -use 5.030; +use Modern::Perl; sub jaro_similarity { my($s1, $s2) = @_; diff --git a/challenge-011/paulo-custodio/perl/ch-1.pl b/challenge-011/paulo-custodio/perl/ch-1.pl index 5580fa104a..a9f070fd4b 100644 --- a/challenge-011/paulo-custodio/perl/ch-1.pl +++ b/challenge-011/paulo-custodio/perl/ch-1.pl @@ -8,9 +8,7 @@ # the boiling point of water is 212 °F and 100 °C. This challenge was proposed # by Laurent Rosenfeld. -use strict; -use warnings; -use 5.030; +use Modern::Perl; use Math::Calculus::NewtonRaphson; diff --git a/challenge-011/paulo-custodio/perl/ch-2.pl b/challenge-011/paulo-custodio/perl/ch-2.pl index 7898121151..07a67ff5ac 100644 --- a/challenge-011/paulo-custodio/perl/ch-2.pl +++ b/challenge-011/paulo-custodio/perl/ch-2.pl @@ -7,9 +7,7 @@ # if the size is 4, then create Identity Matrix 4x4. For more information about # Indentity Matrix, please read the wiki page. -use strict; -use warnings; -use 5.030; +use Modern::Perl; my $size = shift || 4; my @i; diff --git a/challenge-012/paulo-custodio/perl/ch-1.pl b/challenge-012/paulo-custodio/perl/ch-1.pl index e868d19cc0..becd512f62 100644 --- a/challenge-012/paulo-custodio/perl/ch-1.pl +++ b/challenge-012/paulo-custodio/perl/ch-1.pl @@ -8,9 +8,7 @@ # Euclid Number that is not prime. This challenge was proposed by # Laurent Rosenfeld. -use strict; -use warnings; -use 5.030; +use Modern::Perl; # check if number is prime sub is_prime { diff --git a/challenge-012/paulo-custodio/perl/ch-2.pl b/challenge-012/paulo-custodio/perl/ch-2.pl index 8aa3015ae9..dec1f466f2 100644 --- a/challenge-012/paulo-custodio/perl/ch-2.pl +++ b/challenge-012/paulo-custodio/perl/ch-2.pl @@ -13,9 +13,7 @@ # and the path separator is /. Your script should return /a/b as common # directory path. -use strict; -use warnings; -use 5.030; +use Modern::Perl; # extract a common prefix, if one exists sub extract_common_prefix { diff --git a/challenge-013/paulo-custodio/perl/ch-1.pl b/challenge-013/paulo-custodio/perl/ch-1.pl index 95f0f97eb7..b058f16c12 100644 --- a/challenge-013/paulo-custodio/perl/ch-1.pl +++ b/challenge-013/paulo-custodio/perl/ch-1.pl @@ -19,9 +19,7 @@ # 2019/11/29 # 2019/12/27 -use strict; -use warnings; -use 5.030; +use Modern::Perl; use constant Friday => 5; sub is_leap { diff --git a/challenge-013/paulo-custodio/perl/ch-2.pl b/challenge-013/paulo-custodio/perl/ch-2.pl index 9471d36b87..de43826352 100644 --- a/challenge-013/paulo-custodio/perl/ch-2.pl +++ b/challenge-013/paulo-custodio/perl/ch-2.pl @@ -12,9 +12,7 @@ # F ( n ) = n − M ( F ( n − 1 ) ) , n > 0 # M ( n ) = n − F ( M ( n − 1 ) ) , n > 0. -use strict; -use warnings; -use 5.030; +use Modern::Perl; sub F { my($n) = @_; diff --git a/challenge-013/paulo-custodio/test.pl b/challenge-013/paulo-custodio/test.pl index 68d0aee8ba..91c463d690 100644 --- a/challenge-013/paulo-custodio/test.pl +++ b/challenge-013/paulo-custodio/test.pl @@ -1,8 +1,6 @@ #!/usr/bin/perl -use strict; -use warnings; -use 5.030; +use Modern::Perl; use Test::More; is capture("perl perl/ch-1.pl 2019"), <new; diff --git a/challenge-014/paulo-custodio/test.pl b/challenge-014/paulo-custodio/test.pl index ab9951feb0..0a5cd72e18 100644 --- a/challenge-014/paulo-custodio/test.pl +++ b/challenge-014/paulo-custodio/test.pl @@ -1,8 +1,6 @@ #!/usr/bin/perl -use strict; -use warnings; -use 5.030; +use Modern::Perl; use Test::More; # build list of words for testing diff --git a/challenge-015/paulo-custodio/perl/ch-1.pl b/challenge-015/paulo-custodio/perl/ch-1.pl index 291c3f7fe9..725c43e52c 100644 --- a/challenge-015/paulo-custodio/perl/ch-1.pl +++ b/challenge-015/paulo-custodio/perl/ch-1.pl @@ -16,9 +16,7 @@ # Strong Prime number p(n) when p(n) > [ p(n-1) + p(n+1) ] / 2 # Weak Prime number p(n) when p(n) < [ p(n-1) + p(n+1) ] / 2 -use strict; -use warnings; -use 5.030; +use Modern::Perl; # check if number is prime sub is_prime { diff --git a/challenge-015/paulo-custodio/perl/ch-2.pl b/challenge-015/paulo-custodio/perl/ch-2.pl index bdb1cf3d11..204e8d1d4f 100644 --- a/challenge-015/paulo-custodio/perl/ch-2.pl +++ b/challenge-015/paulo-custodio/perl/ch-2.pl @@ -6,9 +6,7 @@ # Write a script to implement Vigenre cipher. The script should be able encode # and decode. Checkout wiki page for more information. -use strict; -use warnings; -use 5.030; +use Modern::Perl; my($op, $key, @text) = @ARGV; if ($op && $op =~ /^enc/i) { diff --git a/challenge-015/paulo-custodio/test.pl b/challenge-015/paulo-custodio/test.pl index bafdc5a374..6959f9ba6e 100644 --- a/challenge-015/paulo-custodio/test.pl +++ b/challenge-015/paulo-custodio/test.pl @@ -1,9 +1,7 @@ #!/usr/bin/perl -use strict; -use warnings; +use Modern::Perl; use Test::More; -use 5.030; is capture("perl perl/ch-1.pl"), < 58; diff --git a/challenge-016/paulo-custodio/test.pl b/challenge-016/paulo-custodio/test.pl index e2c3f98adc..1017049192 100644 --- a/challenge-016/paulo-custodio/test.pl +++ b/challenge-016/paulo-custodio/test.pl @@ -1,9 +1,7 @@ #!/usr/bin/perl -use strict; -use warnings; +use Modern::Perl; use Test::More; -use 5.030; is capture("perl perl/ch-1.pl binary"), < 7; sub is_leap { diff --git a/challenge-019/paulo-custodio/perl/ch-2.pl b/challenge-019/paulo-custodio/perl/ch-2.pl index 0c9cc1ecc3..dfe7ddaf5f 100644 --- a/challenge-019/paulo-custodio/perl/ch-2.pl +++ b/challenge-019/paulo-custodio/perl/ch-2.pl @@ -5,9 +5,7 @@ # Task #2 # Write a script that can wrap the given paragraph at a specified column using the greedy algorithm. -use strict; -use warnings; -use 5.030; +use Modern::Perl; my $text = ""; while (<>) { diff --git a/challenge-019/paulo-custodio/test.pl b/challenge-019/paulo-custodio/test.pl index 16841dbd77..1ead292820 100644 --- a/challenge-019/paulo-custodio/test.pl +++ b/challenge-019/paulo-custodio/test.pl @@ -1,9 +1,7 @@ #!/usr/bin/perl -use strict; -use warnings; +use Modern::Perl; use Test::More; -use 5.030; use Path::Tiny; is capture("perl perl/ch-1.pl"), < -11, 13, -13, 12. -use strict; -use warnings; -use 5.030; +use Modern::Perl; my($n, @seq) = @ARGV; say join(", ", nth_forward_diff($n, @seq)), "."; diff --git a/challenge-023/paulo-custodio/perl/ch-2.pl b/challenge-023/paulo-custodio/perl/ch-2.pl index f04995c7c7..62f450ba8d 100644 --- a/challenge-023/paulo-custodio/perl/ch-2.pl +++ b/challenge-023/paulo-custodio/perl/ch-2.pl @@ -7,9 +7,7 @@ # decomposition of a number is defined as a list of prime numbers which when # all multiplied together, are equal to that number. For example, the Prime decomposition of 228 is 2,2,3,19 as 228 = 2 * 2 * 3 * 19. -use strict; -use warnings; -use 5.030; +use Modern::Perl; my($n) = @ARGV; say join(", ", prime_decomposition($n)), "."; diff --git a/challenge-023/paulo-custodio/test.pl b/challenge-023/paulo-custodio/test.pl index 734731a2b9..bc90aec76b 100644 --- a/challenge-023/paulo-custodio/test.pl +++ b/challenge-023/paulo-custodio/test.pl @@ -1,9 +1,7 @@ #!/usr/bin/perl -use strict; -use warnings; +use Modern::Perl; use Test::More; -use 5.030; use Path::Tiny; is capture("perl perl/ch-1.pl 1 5 9 2 8 1 6"), "4, -7, 6, -7, 5.\n"; diff --git a/challenge-024/paulo-custodio/perl/ch-2.pl b/challenge-024/paulo-custodio/perl/ch-2.pl index 6c85b9ba4d..6e90773eed 100644 --- a/challenge-024/paulo-custodio/perl/ch-2.pl +++ b/challenge-024/paulo-custodio/perl/ch-2.pl @@ -16,9 +16,7 @@ # Solution: store the inverted index in a SQLite database, use DBI to access it -use strict; -use warnings; -use 5.030; +use Modern::Perl; use Path::Tiny; use DBI; use DBD::SQLite; diff --git a/challenge-024/paulo-custodio/test.pl b/challenge-024/paulo-custodio/test.pl index 34227f7310..1eed5b9682 100644 --- a/challenge-024/paulo-custodio/test.pl +++ b/challenge-024/paulo-custodio/test.pl @@ -1,8 +1,6 @@ #!/usr/bin/perl -use strict; -use warnings; -use 5.030; +use Modern::Perl; use Path::Tiny; use Test::More; use WWW::Mechanize; diff --git a/challenge-025/paulo-custodio/perl/ch-1.pl b/challenge-025/paulo-custodio/perl/ch-1.pl index 56f61e00fe..22f59dca77 100644 --- a/challenge-025/paulo-custodio/perl/ch-1.pl +++ b/challenge-025/paulo-custodio/perl/ch-1.pl @@ -5,9 +5,7 @@ # Generate a longest sequence of the following English Pokemon names where # each name starts with the last letter of previous name. -use strict; -use warnings; -use 5.030; +use Modern::Perl; my @names = qw( audino bagon baltoy banette bidoof braviary bronzor carracosta charmeleon cresselia croagunk darmanitan deino emboar emolga diff --git a/challenge-025/paulo-custodio/perl/ch-2.pl b/challenge-025/paulo-custodio/perl/ch-2.pl index d3c931defa..bcf471022a 100644 --- a/challenge-025/paulo-custodio/perl/ch-2.pl +++ b/challenge-025/paulo-custodio/perl/ch-2.pl @@ -6,9 +6,7 @@ # Create script to implement Chaocipher. Please checkout wiki page for more # information. -use strict; -use warnings; -use 5.030; +use Modern::Perl; my $left = "HXUCZVAMDSLKPEFJRIGTWOBNYQ"; my $right = "PTLNBQDEOYSFAVZKGJRIHWXUMC"; diff --git a/challenge-025/paulo-custodio/test.pl b/challenge-025/paulo-custodio/test.pl index b79f15819f..eb06b45b8e 100644 --- a/challenge-025/paulo-custodio/test.pl +++ b/challenge-025/paulo-custodio/test.pl @@ -1,9 +1,7 @@ #!/usr/bin/perl use strict; -use warnings; -use Test::More; -use 5.030; +use Modern::Perl; is capture("perl perl/ch-1.pl"), <= 3 or die "need at least 3 words\n"; say length(join('', @ARGV[1 .. $#ARGV-1])); diff --git a/challenge-083/paulo-custodio/perl/ch-2.pl b/challenge-083/paulo-custodio/perl/ch-2.pl index 05b97833c3..0332afc373 100644 --- a/challenge-083/paulo-custodio/perl/ch-2.pl +++ b/challenge-083/paulo-custodio/perl/ch-2.pl @@ -26,9 +26,7 @@ # Explanation: # Flipping the sign of just one element 12 gives the result 0 i.e. (-12) + (2) + (10) = 0 -use strict; -use warnings; -use 5.030; +use Modern::Perl; my @A = @ARGV; say count_flips(@A); diff --git a/challenge-083/paulo-custodio/test.pl b/challenge-083/paulo-custodio/test.pl index aafadba07d..a990681a37 100644 --- a/challenge-083/paulo-custodio/test.pl +++ b/challenge-083/paulo-custodio/test.pl @@ -1,9 +1,7 @@ #!/usr/bin/perl -use strict; -use warnings; +use Modern::Perl; use Test::More; -use 5.030; is capture("perl/ch-1.pl The Weekly Challenge"), "6\n"; is capture("perl/ch-1.pl The purpose of our lives is to be happy"), "23\n"; diff --git a/challenge-084/paulo-custodio/perl/ch-1.pl b/challenge-084/paulo-custodio/perl/ch-1.pl index 6f74882bcc..c81e86db18 100644 --- a/challenge-084/paulo-custodio/perl/ch-1.pl +++ b/challenge-084/paulo-custodio/perl/ch-1.pl @@ -22,9 +22,7 @@ # Input: 1231230512 # Output: 0 -use strict; -use warnings; -use 5.030; +use Modern::Perl; my($n) = @ARGV; say reverse_int($n); diff --git a/challenge-084/paulo-custodio/perl/ch-2.pl b/challenge-084/paulo-custodio/perl/ch-2.pl index 944c40fdb4..000dfe2589 100644 --- a/challenge-084/paulo-custodio/perl/ch-2.pl +++ b/challenge-084/paulo-custodio/perl/ch-2.pl @@ -40,9 +40,7 @@ # # Output: 0 -use strict; -use warnings; -use 5.030; +use Modern::Perl; # read matrix from input my @m; diff --git a/challenge-084/paulo-custodio/test.pl b/challenge-084/paulo-custodio/test.pl index bd756c7627..91fde37cc1 100644 --- a/challenge-084/paulo-custodio/test.pl +++ b/challenge-084/paulo-custodio/test.pl @@ -1,9 +1,7 @@ #!/usr/bin/perl -use strict; -use warnings; +use Modern::Perl; use Test::More; -use 5.030; my $in = "in.txt"; diff --git a/challenge-085/paulo-custodio/perl/ch-1.pl b/challenge-085/paulo-custodio/perl/ch-1.pl index 9ef7e530d4..a471b54e85 100644 --- a/challenge-085/paulo-custodio/perl/ch-1.pl +++ b/challenge-085/paulo-custodio/perl/ch-1.pl @@ -18,9 +18,7 @@ # Input: @R = (0.5, 1.1, 0.3, 0.7) # Output: 1 as 1 < 0.5 + 1.1 + 0.3 < 2 -use strict; -use warnings; -use 5.030; +use Modern::Perl; my @R = @ARGV; @R >= 3 or die "Need at least 3 values\n"; diff --git a/challenge-085/paulo-custodio/perl/ch-2.pl b/challenge-085/paulo-custodio/perl/ch-2.pl index 650cf42210..c0a16a4221 100644 --- a/challenge-085/paulo-custodio/perl/ch-2.pl +++ b/challenge-085/paulo-custodio/perl/ch-2.pl @@ -18,9 +18,7 @@ # Input: 125 # Output: 1 as 125 = 5 ** 3 -use strict; -use warnings; -use 5.030; +use Modern::Perl; # Sieve of Eratosthenes my @sieve; diff --git a/challenge-085/paulo-custodio/test.pl b/challenge-085/paulo-custodio/test.pl index b8bb5e03c7..b32170a073 100644 --- a/challenge-085/paulo-custodio/test.pl +++ b/challenge-085/paulo-custodio/test.pl @@ -1,9 +1,7 @@ #!/usr/bin/perl -use strict; -use warnings; +use Modern::Perl; use Test::More; -use 5.030; is capture("perl/ch-1.pl 1.2 0.4 0.1 2.5"), "1\n"; is capture("perl/ch-1.pl 0.2 1.5 0.9 1.1"), "0\n"; diff --git a/challenge-086/paulo-custodio/perl/ch-1.pl b/challenge-086/paulo-custodio/perl/ch-1.pl index df2be9681a..9164d0b630 100644 --- a/challenge-086/paulo-custodio/perl/ch-1.pl +++ b/challenge-086/paulo-custodio/perl/ch-1.pl @@ -20,9 +20,7 @@ # Input: @N = (10, 30, 20, 50, 40) and $A = 15 # Output: 0 -use strict; -use warnings; -use 5.030; +use Modern::Perl; # input: list of numbers, last is the difference my @N = @ARGV; diff --git a/challenge-086/paulo-custodio/perl/ch-2.pl b/challenge-086/paulo-custodio/perl/ch-2.pl index c62cba0caf..d13376b053 100644 --- a/challenge-086/paulo-custodio/perl/ch-2.pl +++ b/challenge-086/paulo-custodio/perl/ch-2.pl @@ -45,9 +45,7 @@ # [ 2 4 8 ] [ 9 5 7 ] [ 1 3 6 ] # [ 7 6 3 ] [ 4 1 8 ] [ 2 5 9 ] -use strict; -use warnings; -use 5.030; +use Modern::Perl; use Clone 'clone'; # read input, replace blanks by zero diff --git a/challenge-086/paulo-custodio/test.pl b/challenge-086/paulo-custodio/test.pl index 55c504cc12..529f841c6c 100644 --- a/challenge-086/paulo-custodio/test.pl +++ b/challenge-086/paulo-custodio/test.pl @@ -1,9 +1,7 @@ #!/usr/bin/perl -use strict; -use warnings; +use Modern::Perl; use Test::More; -use 5.030; my $in = "in.txt"; diff --git a/challenge-087/paulo-custodio/perl/ch-1.pl b/challenge-087/paulo-custodio/perl/ch-1.pl index 4eefa05ce5..3564e6be41 100644 --- a/challenge-087/paulo-custodio/perl/ch-1.pl +++ b/challenge-087/paulo-custodio/perl/ch-1.pl @@ -18,9 +18,7 @@ # Input: @N = (20, 19, 9, 11, 10) # Output: (9, 10, 11) -use strict; -use warnings; -use 5.030; +use Modern::Perl; my @seq = longest_seq(@ARGV); if (@seq) { diff --git a/challenge-087/paulo-custodio/perl/ch-2.pl b/challenge-087/paulo-custodio/perl/ch-2.pl index 88b4e95bd6..561a2d11c7 100644 --- a/challenge-087/paulo-custodio/perl/ch-2.pl +++ b/challenge-087/paulo-custodio/perl/ch-2.pl @@ -39,9 +39,7 @@ # [ 1 1 1 1 ] # [ 1 1 1 1 ] -use strict; -use warnings; -use 5.030; +use Modern::Perl; # read matrix from input my @m; diff --git a/challenge-087/paulo-custodio/test.pl b/challenge-087/paulo-custodio/test.pl index c40cc915b4..6d84250030 100644 --- a/challenge-087/paulo-custodio/test.pl +++ b/challenge-087/paulo-custodio/test.pl @@ -1,9 +1,7 @@ #!/usr/bin/perl -use strict; -use warnings; +use Modern::Perl; use Test::More; -use 5.030; my $in = "in.txt"; diff --git a/challenge-088/paulo-custodio/perl/ch-1.pl b/challenge-088/paulo-custodio/perl/ch-1.pl index ca3549ec7a..d6dfe94e73 100644 --- a/challenge-088/paulo-custodio/perl/ch-1.pl +++ b/challenge-088/paulo-custodio/perl/ch-1.pl @@ -31,9 +31,7 @@ # $M[2] = 2 x 1 x 3 = 6 # $M[3] = 2 x 1 x 4 = 8 -use strict; -use warnings; -use 5.030; +use Modern::Perl; my @N = @ARGV; my @M = array_product(@N); diff --git a/challenge-088/paulo-custodio/perl/ch-2.pl b/challenge-088/paulo-custodio/perl/ch-2.pl index 298e47054f..af4b0c2c28 100644 --- a/challenge-088/paulo-custodio/perl/ch-2.pl +++ b/challenge-088/paulo-custodio/perl/ch-2.pl @@ -24,9 +24,7 @@ # Output: # [ 1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10 ] -use strict; -use warnings; -use 5.030; +use Modern::Perl; # read matrix from input my @m; diff --git a/challenge-088/paulo-custodio/test.pl b/challenge-088/paulo-custodio/test.pl index 7ca32dfa2c..e2a07e0555 100644 --- a/challenge-088/paulo-custodio/test.pl +++ b/challenge-088/paulo-custodio/test.pl @@ -1,9 +1,7 @@ #!/usr/bin/perl -use strict; -use warnings; +use Modern::Perl; use Test::More; -use 5.030; my $in = "in.txt"; diff --git a/challenge-092/paulo-custodio/perl/ch-1.pl b/challenge-092/paulo-custodio/perl/ch-1.pl index 49a153e10b..22c464c456 100644 --- a/challenge-092/paulo-custodio/perl/ch-1.pl +++ b/challenge-092/paulo-custodio/perl/ch-1.pl @@ -19,9 +19,7 @@ # Input: $A = "sum"; $B = "add" # Output: 0 -use strict; -use warnings; -use 5.030; +use Modern::Perl; say isomorphic(@ARGV); diff --git a/challenge-092/paulo-custodio/perl/ch-2.pl b/challenge-092/paulo-custodio/perl/ch-2.pl index c21ff45f55..05c8c6bf1a 100644 --- a/challenge-092/paulo-custodio/perl/ch-2.pl +++ b/challenge-092/paulo-custodio/perl/ch-2.pl @@ -18,9 +18,7 @@ # Input $S = (1,5), (7,9); $N = (10,11) # Output: (1,5), (7,9), (10,11) -use strict; -use warnings; -use 5.030; +use Modern::Perl; my @intervals; # set of all intervals add_interval(parse($_)) for @ARGV; diff --git a/challenge-093/paulo-custodio/perl/ch-1.pl b/challenge-093/paulo-custodio/perl/ch-1.pl index 9c49b4a883..9cb3d3789a 100644 --- a/challenge-093/paulo-custodio/perl/ch-1.pl +++ b/challenge-093/paulo-custodio/perl/ch-1.pl @@ -28,9 +28,7 @@ # Input: (1,1), (2,2), (3,1), (1,3), (5,3) # Output: 3 -use strict; -use warnings; -use 5.030; +use Modern::Perl; # get points (@ARGV<4 || @ARGV&1==1) and die "Usage: ch-1.pl x y x y x y ...\n"; diff --git a/challenge-093/paulo-custodio/perl/ch-2.pl b/challenge-093/paulo-custodio/perl/ch-2.pl index 78a8b5f5b8..ca3f6ddb13 100644 --- a/challenge-093/paulo-custodio/perl/ch-2.pl +++ b/challenge-093/paulo-custodio/perl/ch-2.pl @@ -29,9 +29,7 @@ # Output: 26 # as sum three paths (1->2->4), (1->3->5