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

Home > Numbers
Neighboring tickets (Posted on 2015-03-26) Difficulty: 3 of 5
A continuous bus tickets' tape consists of one million tickets numbered from 000000 to 999999.
All tickets are white, except those in which the sum of digits in the even positions equals the sum of digits in the odd positions: those are blue.

What is the largest distance (in numbers) between 2 consecutive blue tickets?

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution Comment 2 of 2 |
DefDbl A-Z
Dim crlf$

Private Sub Form_Load()
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 
 prev = 0
 For n = 0 To 999999
  n1 = n: odd = 0: even = 0
  While n1 > 0
    d = n1 Mod 10
    p = (p + 1) Mod 2
    n1 = n1 \ 10
    If p Then odd = odd + d Else even = even + d
  Wend
  If odd = even Then
    dist = n - prev
    If dist >= maxd Then
      maxd = dist: max1 = prev: max2 = n
      Text1.Text = Text1.Text & maxd & Str(max1) & Str(max2) & crlf
    End If
    prev = n
  End If
 Next

 
 Text1.Text = Text1.Text & crlf & crlf
 


End Sub

finds two instances of the maximum, which is 990:

990 90090 91080
990 908919 909909

where the span in each case is followed by the two ticket numbers in question.

  Posted by Charlie on 2015-03-26 15:21:20
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 (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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