A #fractran model in #rakulang
my $c=True;
while $c {
for @p ->(\t,\n) {
$c=True;
for n.keys ->\v {
if a{v}:exists and a{v}>=n{v}
or t{v}:exists and t{v}>=n{v}
{
$c=True
} else {
$c=False;last
}
}
if $c {
for a.keys ->\v {
if t{v}:exists {a{v}+=t{v}}
if n{v}:exists {a{v}-=n{v}}
}
for t.keys ->\v {
if not a{v}:exists {a{v}=t{v}}
}
last
}
}
}