aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-05-11 09:08:47 +0100
committerGitHub <noreply@github.com>2020-05-11 09:08:47 +0100
commit4538163cddaeac0b53df2b7fba8dd50829c2d762 (patch)
tree89e0d4c3e26310659593f2862a82ba3d4bd32cf6
parent6105594aef4d38ef0e7d56036198464eeb6f3dd1 (diff)
parent2ba20ad6932958c5f8d4f26e88517b574a489136 (diff)
downloadperlweeklychallenge-club-4538163cddaeac0b53df2b7fba8dd50829c2d762.tar.gz
perlweeklychallenge-club-4538163cddaeac0b53df2b7fba8dd50829c2d762.tar.bz2
perlweeklychallenge-club-4538163cddaeac0b53df2b7fba8dd50829c2d762.zip
Merge pull request #1697 from fluca1978/pwc60
Pwc60
-rw-r--r--challenge-060/luca-ferrari/blog-1.txt1
-rw-r--r--challenge-060/luca-ferrari/blog-2.txt1
-rw-r--r--challenge-060/luca-ferrari/raku/ch-1.p652
-rw-r--r--challenge-060/luca-ferrari/raku/ch-2.p642
4 files changed, 96 insertions, 0 deletions
diff --git a/challenge-060/luca-ferrari/blog-1.txt b/challenge-060/luca-ferrari/blog-1.txt
new file mode 100644
index 0000000000..65897b37c5
--- /dev/null
+++ b/challenge-060/luca-ferrari/blog-1.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2020/05/11/PerlWeeklyChallenge60.html#task1
diff --git a/challenge-060/luca-ferrari/blog-2.txt b/challenge-060/luca-ferrari/blog-2.txt
new file mode 100644
index 0000000000..7fd82f71f4
--- /dev/null
+++ b/challenge-060/luca-ferrari/blog-2.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2020/05/11/PerlWeeklyChallenge60.html#task2
diff --git a/challenge-060/luca-ferrari/raku/ch-1.p6 b/challenge-060/luca-ferrari/raku/ch-1.p6
new file mode 100644
index 0000000000..f052ce5bb4
--- /dev/null
+++ b/challenge-060/luca-ferrari/raku/ch-1.p6
@@ -0,0 +1,52 @@
+#!env raku
+
+# Write a script that accepts a number and returns the Excel Column Name it represents and vice-versa.
+
+# Excel columns start at A and increase lexicographically
+# using the 26 letters of the English alphabet,
+# A..Z. After Z, the columns pick up an extra “digit”,
+# going from AA, AB, etc.,
+# which could (in theory) continue to an arbitrary number of digits.
+# In practice, Excel sheets are limited to 16,384 columns.
+#
+#
+# Example
+# Input Number: 28 Output: AB
+# Input Column Name: AD Output: 30
+
+
+
+sub MAIN( $what ) {
+ my @letters = 'A' .. 'Z';
+ my @column-name;
+
+
+ # numeric value to be converted into a letter
+ if $what ~~ Int && $what > 0 && $what <= 16_384 {
+ my $column = $what.Int;
+
+
+ while ( $column > @letters.elems ) {
+ @column-name.push: @letters[ $column / @letters.elems - 1 ];
+ $column = $column % @letters.elems;
+ }
+
+ @column-name.push: @letters[ $column - 1 ];
+ say "Cell $what is { @column-name.join }";
+ }
+ elsif $what ~~ Str {
+ my $column;
+ my $multiplier = 0;
+ # string, try to find the cell number
+ for $what.comb.reverse -> $current_letter {
+ $column += @letters.first( $current_letter, :k ) + 1 + ( @letters.elems - 1 ) * $multiplier++;
+ }
+
+ say "Cell $what is $column";
+ }
+
+
+
+
+
+}
diff --git a/challenge-060/luca-ferrari/raku/ch-2.p6 b/challenge-060/luca-ferrari/raku/ch-2.p6
new file mode 100644
index 0000000000..72d024e444
--- /dev/null
+++ b/challenge-060/luca-ferrari/raku/ch-2.p6
@@ -0,0 +1,42 @@
+#!env raku
+
+
+
+
+# Write a script that accepts list of positive numbers (@L) and two positive numbers $X and $Y.
+#
+# The script should print all possible numbers made by concatenating
+# the numbers from @L, whose length is exactly $X
+# but value is less than $Y.
+# Example
+#
+# Input:
+#
+# @L = (0, 1, 2, 5);
+# $X = 2;
+# $Y = 21;
+#
+# Output:
+#
+# 10, 11, 12, 15, 20
+
+
+
+sub MAIN ( ){
+ my @L = (0, 1, 2, 5);
+ my $x = 2;
+ my $y = 21;
+ my @LL;
+
+ # start from the very beginning of the list limiting
+ # the numbers in the range of $y
+ for ( 1 x $x ) - 1 ..^ $y {
+
+ # see if the numbers "grep" the list
+ my $found = 0;
+ $found++ if $_ == any( @L ) for $_.comb;
+ @LL.push: $_ if $_.comb.elems == $found;
+ }
+
+ say @LL.join( ', ' );
+}