Skip to content

Instantly share code, notes, and snippets.

@cygx
Last active August 29, 2015 14:21
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 cygx/1e010facd65ddeb1065c to your computer and use it in GitHub Desktop.
Save cygx/1e010facd65ddeb1065c to your computer and use it in GitHub Desktop.
my int $s := -1;
while ++$s <= 9 {
next if $s == 0;
my int $e := -1;
while ++$e <= 9 {
next if $e == $s;
my int $n := -1;
while ++$n <= 9 {
next if $n == $s;
next if $n == $e;
my int $d := -1;
while ++$d <= 9 {
next if $d == $s;
next if $d == $e;
next if $d == $n;
my int $send := $s*1000 + $e*100 + $n*10 + $d;
my int $m := -1;
while ++$m <= 9 {
next if $m == 0;
next if $m == $s;
next if $m == $e;
next if $m == $n;
next if $m == $d;
my int $o := -1;
while ++$o <= 9 {
next if $o == $s;
next if $o == $e;
next if $o == $n;
next if $o == $d;
next if $o == $m;
my int $r := -1;
while ++$r <= 9 {
next if $r == $s;
next if $r == $e;
next if $r == $n;
next if $r == $d;
next if $r == $m;
next if $r == $o;
my int $more := $m*1000 + $o*100 + $r*10 + $e;
my int $y := -1;
while ++$y <= 9 {
next if $y == $s;
next if $y == $e;
next if $y == $n;
next if $y == $d;
next if $y == $m;
next if $y == $o;
next if $y == $r;
my int $money :=
$m*10000 + $o*1000 + $n*100 + $e*10 + $y;
next unless $send + $more == $money;
say("$send + $more == $money");
}
}
}
}
}
}
}
}
my int ($send, $more, $money);
loop (my int $s = 0; $s <= 9; ++$s) {
next if $s == 0;
loop (my int $e = 0; $e <= 9; ++$e) {
next if $e == $s;
loop (my int $n = 0; $n <= 9; ++$n) {
next if $n == any($s, $e);
loop (my int $d = 0; $d <= 9; ++$d) {
next if $d == any($s, $e, $n);
$send = :10[$s, $e, $n, $d];
loop (my int $m = 0; $m <= 9; ++$m) {
next if $m == any(0, $s, $e, $n, $d);
loop (my int $o = 0; $o <= 9; ++$o) {
next if $o == any($s, $e, $n, $d, $m);
loop (my int $r = 0; $r <= 9; ++$r) {
next if $r == any($s, $e, $n, $d, $m, $o);
$more = :10[$m, $o, $r, $e];
loop (my int $y = 0; $y <= 9; ++$y) {
next if $y == any($s, $e, $n, $d, $m, $o, $r);
$money = :10[$m, $o, $n, $e, $y];
next unless $send + $more == $money;
say "$send + $more == $money";
}
}
}
}
}
}
}
}
loop (my int $s = 1; $s <= 9; ++$s) {
loop (my int $e = 0; $e <= 9; ++$e) {
next if $e == $s;
loop (my int $n = 0; $n <= 9; ++$n) {
next if $n == $s;
next if $n == $e;
loop (my int $d = 0; $d <= 9; ++$d) {
next if $d == $s;
next if $d == $e;
next if $d == $n;
my int $send = :10[$s, $e, $n, $d];
loop (my int $m = 1; $m <= 9; ++$m) {
next if $m == $s;
next if $m == $e;
next if $m == $n;
next if $m == $d;
loop (my int $o = 0; $o <= 9; ++$o) {
next if $o == $s;
next if $o == $e;
next if $o == $n;
next if $o == $d;
next if $o == $m;
loop (my int $r = 0; $r <= 9; ++$r) {
next if $r == $s;
next if $r == $e;
next if $r == $n;
next if $r == $d;
next if $r == $m;
next if $r == $o;
my int $more = :10[$m, $o, $r, $e];
loop (my int $y = 0; $y <= 9; ++$y) {
next if $y == $s;
next if $y == $e;
next if $y == $n;
next if $y == $d;
next if $y == $m;
next if $y == $o;
next if $y == $r;
my int $money = :10[$m, $o, $n, $e, $y];
next unless $send + $more == $money;
say "$send + $more == $money";
}
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment