aboutsummaryrefslogtreecommitdiff
path: root/challenge-114
diff options
context:
space:
mode:
authorPaulo Custodio <pauloscustodio@gmail.com>2021-06-07 20:38:17 +0100
committerPaulo Custodio <pauloscustodio@gmail.com>2021-06-07 20:38:17 +0100
commit1117ab37226ead53080f0e4354d590bae7a3844f (patch)
tree211ef8e3d9a049efc94eeefd20f961c2a0ced1be /challenge-114
parentcbe3668fd46f9244396c587fb755f2ca983316d8 (diff)
downloadperlweeklychallenge-club-1117ab37226ead53080f0e4354d590bae7a3844f.tar.gz
perlweeklychallenge-club-1117ab37226ead53080f0e4354d590bae7a3844f.tar.bz2
perlweeklychallenge-club-1117ab37226ead53080f0e4354d590bae7a3844f.zip
remove tabs
Diffstat (limited to 'challenge-114')
-rw-r--r--[-rwxr-xr-x]challenge-114/paulo-custodio/perl/ch-1.pl22
-rw-r--r--[-rwxr-xr-x]challenge-114/paulo-custodio/perl/ch-2.pl34
2 files changed, 28 insertions, 28 deletions
diff --git a/challenge-114/paulo-custodio/perl/ch-1.pl b/challenge-114/paulo-custodio/perl/ch-1.pl
index 1acdabc3d2..c543df4a7e 100755..100644
--- a/challenge-114/paulo-custodio/perl/ch-1.pl
+++ b/challenge-114/paulo-custodio/perl/ch-1.pl
@@ -1,18 +1,18 @@
#!/usr/bin/env perl
# 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
@@ -22,14 +22,14 @@ my $N = shift || 0;
say next_palindrome($N);
sub is_palindrome {
- my($n) = @_;
- return reverse($n)==$n;
+ my($n) = @_;
+ return reverse($n)==$n;
}
sub next_palindrome {
- my($n) = @_;
- while (1) {
- $n++;
- return $n if is_palindrome($n);
- }
+ my($n) = @_;
+ while (1) {
+ $n++;
+ return $n if is_palindrome($n);
+ }
}
diff --git a/challenge-114/paulo-custodio/perl/ch-2.pl b/challenge-114/paulo-custodio/perl/ch-2.pl
index fcae901dc9..c76fcaf286 100755..100644
--- a/challenge-114/paulo-custodio/perl/ch-2.pl
+++ b/challenge-114/paulo-custodio/perl/ch-2.pl
@@ -1,24 +1,24 @@
#!/usr/bin/env perl
# 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
+#
+# 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.
@@ -28,17 +28,17 @@ my $N = shift || 0;
say next_same_1bits($N);
sub num_1bits {
- my($n) = @_;
- my $sum = 0;
- map {$sum += $_} split //, sprintf("%b", $n);
- return $sum;
+ my($n) = @_;
+ my $sum = 0;
+ map {$sum += $_} split //, sprintf("%b", $n);
+ return $sum;
}
sub next_same_1bits {
- my($n) = @_;
- my $num1s = num_1bits($n);
- while (1) {
- $n++;
- return $n if num_1bits($n) == $num1s;
- }
+ my($n) = @_;
+ my $num1s = num_1bits($n);
+ while (1) {
+ $n++;
+ return $n if num_1bits($n) == $num1s;
+ }
}