Talk:Cyclops numbers

From Rosetta Code
Revision as of 13:46, 28 June 2021 by Nigel Galloway (talk | contribs) (Nice recursive solution)

Don't forget that '0' is a Cyclops number

It has an odd number of digits (namely 1) and it's middle (and only) digit is '0'.

It's also classified as such in OEIS A134808 - Cyclops numbers. --PureFox (talk) 09:22, 24 June 2021 (UTC)

Indeed you are correct. Thanks. --Thundergnat (talk) 10:19, 24 June 2021 (UTC)

Nice recursive solution

The cartesian product cP N G, where N and G are lists of integers, returns a list of tuples (n,g) where n and g are all the members of N and G ordered by n then g. If digits is the list of integers from 1 to 9 then I can define cyclops r s where r is initialized to 100 and s to digits as follows:

 for n in cP s s output r*n+g
 cyclops (r*10) (cP s digits mapped to 10*n+g)