### Random Post

### Recent Posts

- Puzzle 69: Division: letters for digits
- Enigma 1106: Not a square unused
- Enigma 405: Uncle bungles the answer
- Enigma 401: Uncle bungles the answer
- Puzzle 70: Football five teams: new method
- Enigma 1107: Factory work
- Enigma 404: Regular timepiece
- Tantalizer 477: Precognition
- Enigma 1108: Every vote counts
- Enigma 403: Taking stock

### Recent Comments

geoffrounce on Enigma 1755: Sudoprime II | |

saracogluahmet on Enigma 1740: Sudoprime | |

Jim Randell on Enigma 1740: Sudoprime | |

geoffrounce on Enigma 1740: Sudoprime | |

geoffrounce on Enigma 1730: Prime positi… |

### Archives

### Categories

- article (11)
- enigma (1,087)
- misc (2)
- project euler (2)
- puzzle (23)
- site news (42)
- tantalizer (23)
- teaser (3)

### Site Stats

- 159,095 hits

A slightly longer program would be more efficient, but this one is concise and only takes 40ms.

Solution:The numerical triangular grid is shown below:435 = T(29), 465 = T(30), 595 = T(34), 36 = T(8).

MMa code below, I didn’t generate any 2 digit numbers, just tested to see if the digits in place (3,6) were triangular. Ran in 15 ms.

Paul

For those not familiar with MMa here is a breakdown of the code, even though it is spread over 3 lines (for ease of viewing) it is only 1 line in MMa, though it could have been split over 2 maybe 3. The code is read from the inner most comands to outside,

the first part is

Table[(i(i+1))/2,{i,14,44}], this creates a list of the triangular numbers in braces, i.e.

{105, 120… 990}

We can then create another list by the next command ‘Subsets’ this wraps around the previous list like, Subsets[……….],{3}], this now generates another list of the previous list taken 3 at a time in this form {105, 120, 136}, {105, 120, 153} etc.

The next ‘wrapper’ is IntegerDigits and the command ‘/@’. the command is short for Map where IntegerDigits is Mapped across all the list converting it into another list in this form

{{1,0,5},{1,2,0},{1,3,6}},{{1,0,5},{1,2,0},{1,5,3}}

The last command is wrapped around all that, which is Cases, Cases is quite powerful which basically says find all cases that match some criteria, the format is

Cases[…. …..],

{{a_,b_,c_},{d_,e_,f_},{g_,h_,i_}}/;

a==d&&c==g&&f==i&&IntegerQ[Sqrt[8(10c+f)+1]]&&b!=0]

The {{a_,b_,c_},{d_,e_,f_},{g_,h_,i_}} part is representing {{1,0,5},{1,2,0},{1,3,6}} where the letters Map to the digits, then the tests after /;. The tests here are just comparisons == is equals to, != is Not equal to and the double && is and, (||) is Or, I mentioned powerful because the testing could be virtually any test including results from solving equations solved in situ.

I also mentioned a few cases of lists being created, Now in this instance the results of those lists are lost as the new lists are created from it, we could however keep them if we needed to work on them at some other part in the program simply by inserting a variable name for the lists, so we could have inserted say

a=Table[(i(i+1))/2,{i,14,44}], this would have saved the list of numbers to ‘a’. This is where multiple lines would come in as the first part would be created as ‘a’ and then referenced to ‘a’ in a second line like

b=Subsets[a, {3}] etc.

Hope you didn’t mind all this and by all means delete it if you wish.

Paul.

Thanks for the explanation. I quite often find the Mathematica solutions a bit tricky to untangle.

Here’s a direct formulation of the problem using the

SubstitutedExpression()general alphametic solver from theenigma.pylibrary.It executes from the command line in 96ms.