Sunday Times Teaser 2827 – Password

by Graham Smithers

Published: 27 November 2016 (link)

My computer password consists of different digits written in decreasing order.

I can rearrange the digits to form a perfect cube.  A further rearrangement gives a perfect square.  Another rearrangement gives a prime number.  A further rearrangement gives a number that is divisible by the number of digits in the password.  Yet another rearrangement gives a number that is divisible by all but one of its digits.

What is my password?

5 Comments Leave one →

2. Here’s my solution.

I’ve used some useful routines from the enigma.py library [ https://www.magwag.plus.com/jim/enigma.html ].

• I should say that I didn’t write code to ensure that all the 6 mentioned arrangements of digits were different (which I think is implied by the puzzle text), as there was only one possible solution anyway, and looking at the arrangements found by the program it is certainly possible to find 6 different arrangements satisfying the conditions of the problem.

3. Tony Smith permalink

Hi Brian
(1) I think your program would work without the tests for divisibility by 3 and restriction to at most one of 0,3,6,9. If I am right, how would this affect running time?
(2) Part of the analysis by John Crabtree on your other website shows quickly that the password can only have 4 or 5 digits (he seems to have tested 7 digits despite showing that this would give divisibility by 3).
Knowing this, your range of cube roots would be much smaller. How would this affect running time?
(3) Using a bit more of John’s analysis shows that only 13 cube roots need to be tested. Would you be able to write a simpler/quicker program to do this?

Best wishes
Tony (non-programming reader and occasional correspondent)