I would say that the first thing to notice is that you can constrain the numbers from the right hand end, for example if you have defined D to be 3 and S to be 4 you know that T must be 7. In fact we know that (D+S)%10 == T, (ND+ES)%100 == NT and so on. So if we had some code that assigns values in that order and checks constraints at the earliest moment it would solve the problem. To show you what I mean suppose we had some code:

# Note the digits that are not yet assigned $un0 = "0123456789"; foreach $d (split(//,$un0)) { my $un1 = $un0; $un1 =~ s/$d//; foreach $s (split(//,$un1)) { my $un2 = $un1; $un2 =~ s/$s//; foreach $t (split(//,$un2)) { # Now we can check the first constraint next unless(($d + $s)%10 == $t); my $un3 = $un2; $un3 =~ s/$t//; foreach $n (split(//,$un3)) { my $un4 = $un3; $un4 =~ s/$n//; foreach $e (split(//,$un4)) { next unless(($n.$d + $e.$s)%100 == $n.$t); . . . # Having assigned everything see if # we have the correct answer if(($j.$a.$m.$e.$s + $b.$o.$n.$d) \ == ($a.$g.$e.$n.$t)) { print "B=$b A=$a ... goto success; } } } } } } print "Failed\n"; exit(0); success: print "Solved\n"; # Warning code not checked in any way!

Of course the next step is is to convert the problem into a similar piece of text (without the comments and strange indentation). Once we have the text we can evaluate it and get the answer. (I'll leave the fine details to you)


In reply to Re: Words that equal numbers by hawtin
in thread Words that equal numbers by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.