From f44cb5def91924e03d7575253f1c26fa35dc6ba4 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Sun, 3 Dec 2017 20:40:18 -0500 Subject: [PATCH] day4 --- 2015/04/coins.pl | 13 +++++++++++++ 2015/04/coins2.pl | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 2015/04/coins.pl create mode 100644 2015/04/coins2.pl diff --git a/2015/04/coins.pl b/2015/04/coins.pl new file mode 100644 index 0000000..448ac55 --- /dev/null +++ b/2015/04/coins.pl @@ -0,0 +1,13 @@ +use 5.20.0; + +my $s = shift; + +use Digest::MD5 qw/ md5_hex /; + +my $i = 0; + +$i++ until md5_hex( $s . $i ) =~ /^0{5}/; + +say $i; + + diff --git a/2015/04/coins2.pl b/2015/04/coins2.pl new file mode 100644 index 0000000..bd54dfa --- /dev/null +++ b/2015/04/coins2.pl @@ -0,0 +1,13 @@ +use 5.20.0; + +my $s = shift; + +use Digest::MD5 qw/ md5_hex /; + +my $i = 0; + +$i++ until md5_hex( $s . $i ) =~ /^0{6}/; + +say $i; + +