The eight-digit number 23421314 has two 1's, two 2's, two 3's, and two 4's. The two 1's are separated by one digit, the two 2's are separated by two digits, the two 3's are separated by three digits, and the two 4's are separated by four digits.
Now imagine a 14-digit number that contains two 1's, two 2's, two 3's,
two 4's, two 5's, two 6's, and two 7's, such that the 1's are separated
by one digit, the 2's are separated by two digits, and so on, up to the
7's being separated by seven digits. Actually, there are 52 such numbers;
can you find the highest and lowest of them?
Solution to the Problem:
The lowest number is 14156742352637 andthe highest is 74151643752362.
Tom Dressen sent in the following program to solve the problem:
def search(num, digit): for i in range(len(num)-digit-1): if num[i] == 0 and num[i+digit+1] == 0: num[i] = num[i+digit+1] = digit if digit*2 == len(num): print num else: search(num, digit+1) num[i] = num[i+digit+1] = 0 search([0]*14, 1)
James Alarie and Richard Johnson sent in all 52 numbers:
01: 14156742352637 02: 14167345236275 03: 15146735423627 04: 15163745326427 05: 15167245236473 06: 15173465324726 07: 16135743625427 08: 16172452634753 09: 17125623475364 10: 17126425374635 11: 23627345161475 12: 23726351417654 13: 24723645317165 14: 25623745361417 15: 26325734615147 16: 26327435614175 17: 26721514637543 18: 27423564371516 19: 34573641512762 20: 34673245261715 21: 35723625417164 22: 35743625427161 23: 36713145627425 24: 37463254276151 25: 41617435263275 26: 41716425327635 27: 45671415362732 28: 46171435623725 29: 46171452632753 30: 46357432652171 31: 51716254237643 32: 52462754316137 33: 52472654131763 34: 52642753461317 35: 52732653417164 36: 53647352462171 37: 53672352461714 38: 56171354632742 39: 57141653472362 40: 57236253471614 41: 57263254376141 42: 57416154372632 43: 61517346532472 44: 62742356437151 45: 71316435724625 46: 71416354732652 47: 72452634753161 48: 72462354736151 49: 72632453764151 50: 73161345726425 51: 73625324765141 52: 74151643752362
Correctly solved by:
1. James Alarie |
University of Michigan -- Flint Flint, Michigan |
2. Kristofer Friman | Mullhyttan, Sweden |
3. Richard Johnson | LaJolla, California |
4. Akash Patel | Columbus, Georgia |
5. John Beasley | Winchester, Virginia |
6. John Funk | Ventura, California |
7. Viktor Bergqvist | Tullängsskolan, Sweden |
8. Nina Karlsson | Tullängsskolan, Örebro, Sweden |
9. Jeffrey Gaither | Winchester, Virginia |
10. Tom Dressen | --------- |
11. Britney Ford | Winchester, Virginia |
12. Ashleigh Rogers | Winchester, Virginia |
13. Laura LaRusso | Winchester, Virginia |
14. Patrick Wingfield | Winchester, Virginia |
15. Jason Storer | Winchester, Virginia |
16. Misty Carlisle | Winchester, Virginia |
17. David Wong | Winchester, Virginia |
18. Brad Stillwagon | Winchester, Virginia |
19. Victor Karlsson | Tullängskolan, örebro, Sweden |
20. Chris McCormick | Winchester, Virginia |
21. Andrew Oliver | Winchester, Virginia |
22. Nate Wilson | Winchester, Virginia |