### Random Post

### Recent Posts

- Enigma 415: Buses galore
- Puzzle 65: Division: figures all wrong
- Enigma 1097: Chessboard triangles
- Enigma 414: Nicely bungled, Sir!
- Tantalizer 473: Pigeon post
- Enigma 1098: Soccer heroes
- Enigma 413: Quargerly dues
- Puzzle 66: Hopes and successes on the island
- Enigma 1099: Unconnected cubes
- Enigma 412: A triangular square

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,106)
- misc (2)
- project euler (2)
- puzzle (27)
- site news (43)
- tantalizer (27)
- teaser (3)

### Site Stats

- 164,268 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.