commit 728869ca17873b2c0804dcb4570285f74f91597c
parent 7c3fcf9760bc31510bd993ea47e8e1affdad26d1
Author: Samir Parikh <noreply@samirparikh.com>
Date: Thu, 12 May 2022 17:22:13 +0000
get all tests to pass
Diffstat:
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/secret-handshake/SecretHandshake.pm b/secret-handshake/SecretHandshake.pm
@@ -6,7 +6,23 @@ our @EXPORT_OK = qw<handshake>;
sub handshake {
my ($number) = @_;
- return undef;
+ my %handshake;
+ @handshake{ (0 .. 4) } = (
+ "wink",
+ "double blink",
+ "close your eyes",
+ "jump"
+ );
+ my @events;
+ my @code = split //, scalar reverse sprintf ("%05b", $number);
+
+ foreach (0 .. 3) {
+ push @events => $handshake{ $_ } if $code[ $_ ];
+ }
+
+ @events = reverse @events if $code[ 4 ];
+
+ return \@events;
}
1;