Issue 98 - Project Euler

The problem is this:

Replacing each of the letters of the word CARE with 1, 2, 9, and 6, respectively, we construct a square number: 1296 = 36 ^ (2). It is noteworthy that, using the same digital permutations, the RACE anagram also forms a square number: 9216 = 96 ^ (2). We will call CARE (and RACE) a square pair of params and further indicate that leading zeros are not allowed and another letter cannot have the same numerical value as another letter.

Using word.txt (right-click and “Save link / target as ...”), a 16K text file containing almost two thousand common English words will find all square pairs of anagrams (the palindrome word is NOT considered to be an anagram itself).

What is the largest square number formed by any member of such a pair?

NOTE. All generated anagrams should be contained in this text file.

I don’t understand how to display CARE before 1296? How it works? or all permutation mappings intended for verification, i.e. all letters in 1-9?

+3
source share
4 answers

In short: yes, all permutations should be checked.

+3
source

All letter assignments are allowed. So C = 1, A = 2, R = 3, E = 4 is a possible assignment ... except that 1234 is not a square, so that would be nice.

, ? A = 6, E = 5, T = 2, TEA= 256 = 16² EAT= 625 = 25². (TEA = 256, EAT = 625) .

( , , , , . , , .)

+5

, :

  • ​​
  • , .

. 68 4, 216 5,... "" , , .

"" . .

+1

. . , Project Euler, , , , , , , , .

, , , (TM). , , "" , , - .

, , , 1 . 1 , . , , , .. - , , , .

There are many innovative solutions, but the first thing you think about, especially the one you think about when Project Euler describes the problem, is likely to be wrong.

So how can you approach this problem? There are probably too many permutations, but maybe you can figure out something with the mapping and matching of the mappings?

(Trying not to give it all away.)

+1
source

Source: https://habr.com/ru/post/1778524/


All Articles