The Monthly Hole: Numerology


Goal

Reduce an integer to its ``Secret Number''.

Enter the mystical world of numerology to find the true soul of an integer! OK, we are not numerologists, but we did find this process in a magazine and thought it could provide some interesting solutions. Actually, the only aspect of numerology that we appreciate is the Perl-Monk-like name of its originator, Edgar Cayce, the Sleeping Prophet of Virginia Beach.


Example

Here is the process:

  1. The first and only argument will be a number. Step through the digits two by two in sequence, adding each pair together. The number 1234 would be handled this way: 1+2, 2+3, 3+4.

  2. If a pair's result is higher than 9, add the digits of the results to obtain a number between 0 and 9 (inclusive).

  3. Concatenate all of the results to obtain a new number. The new number should be shorter by one digit than the previous number.

  4. Repeat steps 1 to 3 until you get a single digit (this is the ``Secret Number'').

Here is an example, let's begin with 8169.

Step 1: 8+1=9, 1+6=7, 6+9=15
Step 2: 15 is higher than 9, so 1+5=6
Step 3: Result = "9"."7"."6" = 976

Step 1: 9+7=16, 7+6=13
Step 2: 16 is higher than 9, so 1+6=7
Step 2: 13 is higher than 9, so 1+3=4
Step 3: Result = "7"."4" = 74

Step 1: 7+4=11
Step 2: 11 is higher than 9, so 1+1=2
Step 3: Result = "2" = 2
Step 4: Done

Thus, the ``Secret Number'' of 8169 is 2.


Rules


Deadline

The game starts March 1st (00:00 GMT) and ends March 8th (00:00 GMT).


Test program

A test program is provided to help screen entries.

Any program that passes the test program should be submitted. If you are surprised that your solution passed the test program, please submit it anyway! That will help us identify bugs in the test program.

For the test program to work correctly, you will have to name your script secret.pl and place it in the same directory as your test program. Run the test program:

  $ perl tpr01.pl

to verify that your entry is valid.

Passing the test program does not assure your solution is valid. The referees have the final say.


Submitting

You can submit your solution here (you'll notice it's the same page as the Leaderboard). Do not publish your solutions anywhere. That will spoil the game, as your solutions are meant to be secret. All solutions will be published at the end of the game.


Leaderboard

You can track your ranking through the leaderboard here. Beginners are encouraged to enter and there is a separate leaderboard for them.


Feedback

We encourage you to send your ideas for holes, tips and tiebreakers to golf@theperlreview.com.


Referees

Dave Hoover <squirrel@cpan.org>

Jérôme Quelin <jquelin@wanadoo.fr>