Previous page Next page Navigation bar

Puzzles

Prior to 2001 Puzzles

6 February 2000 (Different Cubes)

The problem statement from the Ole Miss Problems of the Week page is:

Find a two-digit number such that: the digits are different, the cube of the two-digit number is a five-digit number, all the digits of the five-digit cube are different, and all the digits of the five-digit cube are different from the original two-digit number.

Well, “find” has frequently indiciated to us that we need to write a calculator program to search for whatever is to be found. Should we do that in this case?

Of course we should! Bring out the CFX-9850G or FX-7400G, then!

Let us interpret the problem, first. We want a two digit number for which the cube is a five digit number. That means the two digit number is between 22 (213 is only 9261) and 46 (473 is 103823). And we want all the digits of the number and its cube to be distinct. If we form a single number that is the number appended to its cube, and then count the number of times each digit is used in this constructed number, we can tell whether digits are repeated. If no digits are repeated in the constructed number, we have a winner — I mean a solution to the problem.

That is enough of a description to start on the program. We will just loop through numbers between 22 and 46, inclusive, cube the number, append the original number to the cube, and count the incidence of digits. This program is available both here and as a text file with .CAT file contents. And, as always, semicolon (“;”) starts a comment not to be entered into the calculator.

Program P020600 (149 bytes):

; Variables:
;   A is candidate number
;   B is cube of candidate number
;   C is candidate number appended to cube
;   D is duplicate digits flag
;   E is digit being examined
;   F is count of appearances of digit being examined
;   List 1[x+1] is count of digit x in C
; Symbols:
;   -> is assignment arrow
;   ^ is exponentiation operator
;   <> is not equals relational
;   / is division operator
;   => is conditional jump operator
;   _ is display triangle
 
For 22->A To 46    ; Loop through all candidate numbers
A^3->B             ;   Form the cube of the number
100B+A->C          ;   Append the original number to the cube
Seq(0,D,1,10,1)->List 1
                   ;   Zero a list to count digit incidence
0->D               ;   Zero a "duplicates" flag
While C<>0         ;   Loop through digits of combined number
10Frac (C/10)->E   ;     Extract the low order digit
Int (C/10)->C      ;     Remove the low order digit
E+1->E             ;     Add 1 to digit to get list element index
List 1[E]->F       ;     Get previous digit count
F+1->F             ;     Increment previous digit count
F->List 1[E]       ;     Store new digit count
F<>1=>1->D         ;     If new digit count > 1, digits are duplicated
WhileEnd           ;   [End of loop through digits]
D=0=>A_            ;   If no digits are duplicated, display number
Next               ; [End of loop through candidate numbers]
"Done"             ; Display end message

Now we run this program, and it yields the output:

27
Done

As a check, we compute 273, which is 19683. Indeed, all digits in the two numbers are distinct.

There’s probably an analytic way to do this problem, but I’m having a real difficult time getting motivated to figure it out.

[ Previous page | Top of page | Next page ]

Previous page Top of page Next page Navigation bar

Copyright © 2001 Brian Hetrick
Page last updated 25 November 2001.

Brian’s Casio Calculator Corner

Home

Programs

Tutorial

Puzzles

Index

2001/2002

Previous years

Index

3 December 2000

27 October 2000

16 April 2000

9 April 2000

19 March 2000

13 February 2000

6 February 2000

28 November 1999

12 September 1999

8 August 1999

25 July 1999

11 July 1999

30 May 1999

4 April 1999

29 April 1996

In memoriam: Dijkstra

Site Information

Your Privacy

Site Map

E-mail

Site Technical Data