Le Monde puzzle [#818]
The current puzzle is as follows:
Define the symmetric of an integer as the integer obtained by inverting the order of its digits, eg 4321 is the symmetric of 1234. What are the numbers for which the square is equal to the symmetric of the square of the symmetric?
I first consulted stackexchange to find a convenient R function to create the symmetric:
int2digit=function(x){ as.numeric(sapply(sequence(nchar(x)), function(y) substr(x, y, y)))} digit2int=function(a){ as.numeric(paste(a,collapse=""))} flip=function(x){ digit2int(rev(int2digit(x)))}
and then found that all integers but the multiples of 10 are symmetric! only some integers involving 1,2,3 and sometimes zero would work:
> for (i in 1:1000){ + if (i^2==flip(flip(i)^2)) print(i)} [1] 1 [1] 2 [1] 3 [1] 11 [1] 12 [1] 13 [1] 21 [1] 22 [1] 31 [1] 101 [1] 102 [1] 103 [1] 111 [1] 112 [1] 113 [1] 121 [1] 122 [1] 201 [1] 202 [1] 211 [1] 212 [1] 221 [1] 301 [1] 311
If I am not (again) confused, the symmetric integers would be those (a) not ending with zero and (b) only involving digits whose products are all less than 10.
May 9, 2013 at 2:35 pm
[…] Le Monde Puzzle 818 […]
May 2, 2013 at 7:02 pm
[…] article was first published on Xi'an's Og » R, and kindly contributed to […]
May 2, 2013 at 6:28 pm
[…] article was originally published on Xi’an’s Og, and kindly contributed to Zyhhwg Data […]
May 2, 2013 at 1:13 am
What am I missing?
14*14 = 196
41*41 = 1681
Isn’t this a counterexample to your claim?
May 2, 2013 at 6:40 am
thanks, I indeed made a (sickbed) mistake in checking for those symmetric solutions…
May 1, 2013 at 11:38 pm
‘all integers but the multiples of 10 are symmetric!’
? This is not true!
May 2, 2013 at 6:39 am
yes, thanks!, this is a lesson: never try R coding while under (hospital) drugs!