]> www.fi.muni.cz Git - aoc.git/commitdiff
Day 25: dummy open-coding
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Fri, 25 Dec 2020 07:01:23 +0000 (08:01 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Fri, 25 Dec 2020 07:01:23 +0000 (08:01 +0100)
49.pl [new file with mode: 0755]

diff --git a/49.pl b/49.pl
new file mode 100755 (executable)
index 0000000..eeeead3
--- /dev/null
+++ b/49.pl
@@ -0,0 +1,35 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+my ($val1, $val2) = (1, 1);
+my $iter = 0;
+my $subj1 = 7;
+my $subj2 = 7;
+my ($pub1, $pub2) = @ARGV;
+
+while (++$iter) {
+       $val1 *= $subj1;
+       $val2 *= $subj2;
+       $val1 %= 20201227;
+       $val2 %= 20201227;
+       if ($val1 == $pub1) {
+               print "$iter loops for subj1\n";
+               $val1 = $pub2;
+               for (2 .. $iter) {
+                       $val1 *= $pub2;
+                       $val1 %= 20201227;
+               }
+               print "key=$val1\n";
+       }
+       if ($val2 == $pub2) {
+               print "$iter loops for subj2\n";
+               $val2 = $pub1;
+               for (2 .. $iter) {
+                       $val2 *= $pub1;
+                       $val2 %= 20201227;
+               }
+               print "key=$val2\n";
+       }
+}
+