Post Reply 
MC: Ping-Pong Cubes
05-22-2018, 08:46 PM (This post was last modified: 06-23-2018 09:09 PM by Valentin Albillo.)
Post: #4
RE: MC: Ping-Pong Cubes
.
Hi, Joe:

(05-22-2018 03:16 PM)Joe Horn Wrote:  The first 5 Ping-Pong Cubes are:
[...]
Your mini-challenge, should you choose to accept it, is to write an HP calculator program that finds the first ten Ping-Pong Cubes. Don't worry; the 10th one is not very large.

Easy as pie. The following 4-liner (159 bytes) I've written for the HP-71B plus HP's String LEX does the job and finds all 10 such numbers less than 1,000 in 0.43 sec. under J-F's Emu71:

      1  A$="10101010101" @ FOR I=10 TO 999 @ IF NOT FNP(I) THEN 2 ELSE IF FNP(I^3) THEN DISP I;I^3
      2  NEXT I
      3  DEF FNP(N) @ N$=STR$(VAL(REPLACE$(STR$(N),"9","1"))+VAL(A$[1,LEN(STR$(N))]))
      4  IF SPAN(N$,"13579") THEN FNP=NOT SPAN(N$,"02468") ELSE FNP=1

      >SETTIME 0 @ CALL @ TIME

        18  5832
        23  12167
        85  614125
        87  658503
       101  1030301
       103  1092727
       301  27270901
       303  27818127
       363  47832147
       725  381078125

            0.43 sec.

FNP is a 2-line user-defined function that returns 1 (True) if its argument is a PPN and 0 (False) if it isn't. Notice that it doesn't use any kind of looping at all, it gets the answer straight away, in linear time.

Looking for all such numbers less than 10,000 takes less than 5 seconds but finds no additional ones.

Quote:A much bigger challenge, which has eluded me thus far, is to find the 11th Ping-Pong Cube. It must be very large, if it even exists.

My program would find it in principle but it's limited to the 12-digit native floating point results so searching for N>=10,000 would take multiprecision computations. I'll give it a try if I find the time.

Regards.
V.
.
P.S.: Edited to feature an improved version (4 lines instead of 5 and also somewhat faster).

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
MC: Ping-Pong Cubes - Joe Horn - 05-22-2018, 03:16 PM
RE: MC: Ping-Pong Cubes - Didier Lachieze - 05-22-2018, 03:52 PM
RE: MC: Ping-Pong Cubes - Joe Horn - 05-22-2018, 04:05 PM
RE: MC: Ping-Pong Cubes - Valentin Albillo - 05-22-2018 08:46 PM
RE: MC: Ping-Pong Cubes - Didier Lachieze - 05-23-2018, 12:14 PM
RE: MC: Ping-Pong Cubes - Werner - 05-24-2018, 01:19 PM
RE: MC: Ping-Pong Cubes - DavidM - 05-25-2018, 08:20 PM
RE: MC: Ping-Pong Cubes - ijabbott - 05-25-2018, 10:55 PM
RE: MC: Ping-Pong Cubes - Valentin Albillo - 05-25-2018, 11:45 PM
RE: MC: Ping-Pong Cubes - pier4r - 05-26-2018, 06:47 AM
RE: MC: Ping-Pong Cubes - Valentin Albillo - 05-26-2018, 11:31 PM
RE: MC: Ping-Pong Cubes - pier4r - 05-27-2018, 08:13 AM
RE: MC: Ping-Pong Cubes - DavidM - 05-26-2018, 05:01 PM
RE: MC: Ping-Pong Cubes - Joe Horn - 05-27-2018, 05:06 AM
RE: MC: Ping-Pong Cubes - David Hayden - 05-27-2018, 04:48 PM
RE: MC: Ping-Pong Cubes - ijabbott - 05-27-2018, 06:50 PM
RE: MC: Ping-Pong Cubes - pier4r - 05-27-2018, 09:19 PM
RE: MC: Ping-Pong Cubes - brickviking - 05-27-2018, 10:33 PM
RE: MC: Ping-Pong Cubes - Juan14 - 05-26-2018, 08:19 PM
RE: MC: Ping-Pong Cubes - DavidM - 05-27-2018, 03:02 PM
RE: MC: Ping-Pong Cubes - brickviking - 05-27-2018, 10:05 AM
RE: MC: Ping-Pong Cubes - ijabbott - 05-27-2018, 12:30 PM
RE: MC: Ping-Pong Cubes - DavidM - 05-27-2018, 02:50 PM
RE: MC: Ping-Pong Cubes - pier4r - 05-27-2018, 11:15 PM
RE: MC: Ping-Pong Cubes - ijabbott - 05-29-2018, 08:07 PM
RE: MC: Ping-Pong Cubes - Valentin Albillo - 06-01-2018, 01:16 AM
RE: MC: Ping-Pong Cubes - Warbucks - 06-03-2018, 04:26 AM
RE: MC: Ping-Pong Cubes - Joe Horn - 06-03-2018, 03:24 PM
RE: MC: Ping-Pong Cubes - Valentin Albillo - 06-14-2018, 03:07 PM
RE: MC: Ping-Pong Cubes - Joe Horn - 06-15-2018, 02:12 AM
RE: MC: Ping-Pong Cubes - Valentin Albillo - 06-20-2018, 09:30 PM
RE: MC: Ping-Pong Cubes - Joe Horn - 06-21-2018, 02:50 AM
RE: MC: Ping-Pong Cubes - Valentin Albillo - 06-21-2018, 09:29 PM
RE: MC: Ping-Pong Cubes - ijabbott - 06-03-2018, 05:42 AM
RE: MC: Ping-Pong Cubes - pier4r - 06-03-2018, 12:29 PM
RE: MC: Ping-Pong Cubes - Werner - 06-15-2018, 04:52 AM
RE: MC: Ping-Pong Cubes - Joe Horn - 06-15-2018, 03:37 PM
RE: MC: Ping-Pong Cubes - ijabbott - 06-17-2018, 10:33 AM
RE: MC: Ping-Pong Cubes - brickviking - 06-21-2018, 03:22 AM
RE: MC: Ping-Pong Cubes - pier4r - 06-21-2018, 06:24 AM
RE: MC: Ping-Pong Cubes - Joe Horn - 06-22-2018, 04:40 AM
RE: MC: Ping-Pong Cubes - Valentin Albillo - 06-25-2018, 08:45 PM
RE: MC: Ping-Pong Cubes - ijabbott - 06-25-2018, 09:48 PM
RE: MC: Ping-Pong Cubes - Valentin Albillo - 06-26-2018, 09:43 PM
RE: MC: Ping-Pong Cubes - rprosperi - 06-27-2018, 12:38 AM
RE: MC: Ping-Pong Cubes - Massimo Gnerucci - 06-27-2018, 06:58 AM
RE: MC: Ping-Pong Cubes - Jim Horn - 06-26-2018, 10:10 PM
RE: MC: Ping-Pong Cubes - Joe Horn - 06-26-2018, 10:23 PM
RE: MC: Ping-Pong Cubes - brickviking - 06-27-2018, 04:41 AM
RE: MC: Ping-Pong Cubes - Joe Horn - 06-27-2018, 05:23 AM
RE: MC: Ping-Pong Cubes - Valentin Albillo - 06-27-2018, 09:29 PM



User(s) browsing this thread: 1 Guest(s)