Skip to content

Instantly share code, notes, and snippets.

@colomon
Created July 1, 2014 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colomon/fea0ec14fbf3ad02c5ed to your computer and use it in GitHub Desktop.
Save colomon/fea0ec14fbf3ad02c5ed to your computer and use it in GitHub Desktop.
sub is-happy($n) {
state %memory = 1 => True;
return %memory{$n} if %memory{$n}:exists;
%memory{$n} = False;
%memory{$n} = is-happy([+] $n.comb.map(* ** 2));
}
say (1..100).grep({ is-happy($_) });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment