#java: return true if the integer is the concatenation of two square numbers.

6 messages · Page 1 of 1 (latest)

gray sedge
#

for example:
return true for 136 (1 and 36)
return true for 2549 (25 and 49)
return true for 2500 (25 and 100)

What would be a possible logic to solve this?

rugged turret
#

Main thing I can think of is splitting on every possible position and checking if the values are both squares

#

I would also use a pregenerated list of numbers to check against to improve computation speeds

fading dirge
midnight pelican
#

square root % 1 == 0 on both halfs of the number?

#

could get 25 from 2549 by doing / 100 and get 49 by doing % 2500