From 57d29c68d000d86037b5d6a3699f6d7001667525 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Wed, 13 Dec 2017 10:28:31 -0500 Subject: [PATCH] day13 --- 13/1.pl | 16 ++++++++++++++++ 13/2.pl | 23 +++++++++++++++++++++++ 13/input.txt | 43 +++++++++++++++++++++++++++++++++++++++++++ 13/test | 4 ++++ 4 files changed, 86 insertions(+) create mode 100644 13/1.pl create mode 100644 13/2.pl create mode 100644 13/input.txt create mode 100644 13/test diff --git a/13/1.pl b/13/1.pl new file mode 100644 index 0000000..a58cd98 --- /dev/null +++ b/13/1.pl @@ -0,0 +1,16 @@ +use 5.20.0; + +use List::AllUtils qw/ /; +use experimental qw/ signatures postderef /; + +my %g = map { split ': ' } <>; + +my $score; + +for my $g ( keys %g ) { + next if $g % (2*($g{$g}-1)); + warn $g; + $score += $g * $g{$g}; +} + +say $score; diff --git a/13/2.pl b/13/2.pl new file mode 100644 index 0000000..9e2c3fb --- /dev/null +++ b/13/2.pl @@ -0,0 +1,23 @@ +use 5.20.0; + +use List::AllUtils qw/ /; +use experimental qw/ signatures postderef /; + +my %g = map { split ': ' } <>; + + +my $i = 1; + +until( pass($i) ) { + $i++; +} + +say '>>>',$i; + +sub pass($i) { + for my $g ( keys %g ) { + return unless ($i+$g) % (2*($g{$g}-1)); + } + return 1; +} + diff --git a/13/input.txt b/13/input.txt new file mode 100644 index 0000000..5055e90 --- /dev/null +++ b/13/input.txt @@ -0,0 +1,43 @@ +0: 4 +1: 2 +2: 3 +4: 5 +6: 8 +8: 4 +10: 6 +12: 6 +14: 6 +16: 10 +18: 6 +20: 12 +22: 8 +24: 9 +26: 8 +28: 8 +30: 8 +32: 12 +34: 12 +36: 12 +38: 8 +40: 10 +42: 14 +44: 12 +46: 14 +48: 12 +50: 12 +52: 12 +54: 14 +56: 14 +58: 14 +60: 12 +62: 14 +64: 14 +68: 12 +70: 14 +74: 14 +76: 14 +78: 14 +80: 17 +82: 28 +84: 18 +86: 14 diff --git a/13/test b/13/test new file mode 100644 index 0000000..0239024 --- /dev/null +++ b/13/test @@ -0,0 +1,4 @@ +0: 3 +1: 2 +4: 4 +6: 4