All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
5 conditions to get 2 results (Posted on 2010-10-21) Difficulty: 3 of 5
A number N fulfills the following conditions:
1, It consists of nine distinct digits.
2. The inclusive sum of digits between the digits 1 and 2 is 12.
3. The inclusive sum of digits between the digits 2 and 3 is 23.
4. The inclusive sum of digits between the digits 3 and 4 is 34.
5. The inclusive sum of digits between the digits 4 and 5 is 45.

What are the lowest and the highest values of N?

No Solution Yet Submitted by Ady TZIDON    
Rating: 2.5000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 2 of 3 |

472918365
563819274

are the only two results and are therefore the lowest and highest by default.

DECLARE SUB permute (a$)
CLS
a$ = "123456789": h$ = a$
DO
  a = INSTR(a$, "1")
  b = INSTR(a$, "2")
  c = INSTR(a$, "3")
  d = INSTR(a$, "4")
  e = INSTR(a$, "5")

  tot2 = 0
  tot3 = 0
  tot4 = 0
  tot5 = 0

  FOR i = a TO b STEP SGN(b - a): tot2 = tot2 + VAL(MID$(a$, i, 1)): NEXT
  IF tot2 = 12 THEN
  FOR i = b TO c STEP SGN(c - b): tot3 = tot3 + VAL(MID$(a$, i, 1)): NEXT
  IF tot3 = 23 THEN
  FOR i = c TO d STEP SGN(d - c): tot4 = tot4 + VAL(MID$(a$, i, 1)): NEXT
  IF tot4 = 34 THEN
  FOR i = d TO e STEP SGN(e - d): tot5 = tot5 + VAL(MID$(a$, i, 1)): NEXT
  IF tot5 = 45 THEN

    PRINT a$

  END IF
  END IF
  END IF
  END IF

  permute a$
LOOP UNTIL a$ = h$


  Posted by Charlie on 2010-10-21 23:40:50
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information