SEND + MORE = MONEY: Difference between revisions
Content added Content deleted
(→{{header|ALGOL 68}}: typo) |
(→{{header|Raku}}: Added Raku solution) |
||
Line 88: | Line 88: | ||
</syntaxhighlight>{{out}} 9567 + 1085 == 10652 |
</syntaxhighlight>{{out}} 9567 + 1085 == 10652 |
||
=={{header|Raku}}== |
|||
<syntaxhighlight lang="raku" line> |
|||
enum <D E M N O R S Y>; |
|||
sub find_solution ( ) { |
|||
for ('0'..'9').combinations(8) -> @c { |
|||
.return with @c.permutations.first: -> @p { |
|||
@p[M] !== 0 and |
|||
@p[ S,E,N,D].join |
|||
+ @p[ M,O,R,E].join |
|||
== @p[M,O,N,E,Y].join |
|||
} |
|||
} |
|||
} |
|||
my @s = find_solution(); |
|||
say " {@s[ S,E,N,D].join}"; |
|||
say " + {@s[ M,O,R,E].join}"; |
|||
say "== { @s[M,O,N,E,Y].join}"; |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
9567 |
|||
+ 1085 |
|||
== 10652 |
|||
</pre> |
|||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
<syntaxhighlight lang="ring"> |
<syntaxhighlight lang="ring"> |