aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-200/arpad-toth/perl/ch-1.pl23
-rw-r--r--challenge-200/arpad-toth/perl/ch-2.pl105
2 files changed, 128 insertions, 0 deletions
diff --git a/challenge-200/arpad-toth/perl/ch-1.pl b/challenge-200/arpad-toth/perl/ch-1.pl
new file mode 100644
index 0000000000..b4725b1766
--- /dev/null
+++ b/challenge-200/arpad-toth/perl/ch-1.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use feature 'say';
+
+#usage : perl script 1 2 3 4
+
+my @o=@ARGV;
+push my @slc,$o[0],$o[1];
+sub sayno{say "no slice found"};
+sayno if scalar(@ARGV)<3;
+my $fl=0;
+
+#build slices
+while(scalar(@o)>=2){
+ my $delta=$o[1]-$o[0];
+ for(2..$#o){push @slc,$o[$_] and say "(@slc)" and $fl=1 if($o[$_]-$o[$_-1] == $delta) || last};
+ splice(@o,0,1);
+ undef(@slc);push @slc,$o[0],$o[1];
+}
+$fl==1 ? exit : sayno;
+
diff --git a/challenge-200/arpad-toth/perl/ch-2.pl b/challenge-200/arpad-toth/perl/ch-2.pl
new file mode 100644
index 0000000000..5ca6cef36c
--- /dev/null
+++ b/challenge-200/arpad-toth/perl/ch-2.pl
@@ -0,0 +1,105 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use feature 'say';
+
+#usage : perl script 2 0 0
+
+# line1
+for(0..$#ARGV){
+if($ARGV[$_] == 1
+or $ARGV[$_] == 4){&space7;if($_<$#ARGV){&space};if($_==$#ARGV){print "\n"}};
+
+if($ARGV[$_] == 2
+or $ARGV[$_] == 3
+or $ARGV[$_] == 5
+or $ARGV[$_] == 6
+or $ARGV[$_] == 7
+or $ARGV[$_] == 8
+or $ARGV[$_] == 9
+or $ARGV[$_] == 0){&draw_147;if($_<$#ARGV){&space};if($_==$#ARGV){print "\n"}};
+}
+
+# line23
+for(1..2){
+for(0..$#ARGV){
+if($ARGV[$_] == 5
+or $ARGV[$_] == 6){&draw_2356_l;if($_<$#ARGV){&space};if($_==$#ARGV){print "\n"}};
+
+if($ARGV[$_] == 1
+or $ARGV[$_] == 2
+or $ARGV[$_] == 3
+or $ARGV[$_] == 7){&draw_2356_r;if($_<$#ARGV){&space};if($_==$#ARGV){print "\n"}};
+
+if($ARGV[$_] == 4
+or $ARGV[$_] == 8
+or $ARGV[$_] == 9
+or $ARGV[$_] == 0){&draw_2356_b;if($_<$#ARGV){&space};if($_==$#ARGV){print "\n"}};
+}
+}
+
+# line4
+for(0..$#ARGV){
+if($ARGV[$_] == 2
+or $ARGV[$_] == 3
+or $ARGV[$_] == 4
+or $ARGV[$_] == 5
+or $ARGV[$_] == 6
+or $ARGV[$_] == 8
+or $ARGV[$_] == 9){&draw_147;if($_<$#ARGV){&space};if($_==$#ARGV){print "\n"}};
+
+if($ARGV[$_] == 1
+or $ARGV[$_] == 7
+or $ARGV[$_] == 0){&space7;if($_<$#ARGV){&space};if($_==$#ARGV){print "\n"}};
+}
+# line56
+for(1..2){
+for(0..$#ARGV){
+if($ARGV[$_] == 2){&draw_2356_l;if($_<$#ARGV){&space};if($_==$#ARGV){print "\n"}};
+
+if($ARGV[$_] == 1
+or $ARGV[$_] == 3
+or $ARGV[$_] == 4
+or $ARGV[$_] == 5
+or $ARGV[$_] == 7
+or $ARGV[$_] == 9){&draw_2356_r;if($_<$#ARGV){&space};if($_==$#ARGV){print "\n"}};
+
+if($ARGV[$_] == 6
+or $ARGV[$_] == 8
+or $ARGV[$_] == 0){&draw_2356_b;if($_<$#ARGV){&space};if($_==$#ARGV){print "\n"}};
+}
+}
+
+# line7
+for(0..$#ARGV){
+if($ARGV[$_] == 1
+or $ARGV[$_] == 4
+or $ARGV[$_] == 7){&space7;if($_<$#ARGV){&space};if($_==$#ARGV){print "\n"}};
+
+if($ARGV[$_] == 2
+or $ARGV[$_] == 3
+or $ARGV[$_] == 5
+or $ARGV[$_] == 6
+or $ARGV[$_] == 8
+or $ARGV[$_] == 9
+or $ARGV[$_] == 0){&draw_147;if($_<$#ARGV){&space};if($_==$#ARGV){print "\n"}};
+}
+
+# line1 - (2,3,5,6,7,8,9,0) - (-------)
+# line2,3 -left - (5,6) - (|)
+# line2,3 -right- (1,2,3,7) - (|)
+# line2,3 -both-(4,8,9,0) (| |)
+# line4 - (2,3,4,5,6,8,9) - (-------)
+# line5,6 -left - (2) - (|)
+# line5,6 -right - (1,3,4,5,7,9) (|)
+# line5,5 -both-(6,8,0) (| |)
+# line7 - (2,3,5,6,8,9,0) - (-------)
+
+sub draw_147{print "-"x7};
+sub draw_2356_l{printf"%-7s","|"};
+sub draw_2356_r{printf"%7s","|"};
+sub draw_2356_b{printf"%s","| |"};
+sub space{print " "};
+sub space7{print " "x7};
+