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

Home > General
Digital Time (Posted on 2014-09-10) Difficulty: 3 of 5
The display on a 24 hour digital clock, having the format HH:MM:SS, reads 09:40:41.

What will the clock display precisely 20140 digit changes later? How about exactly 201400 digit changes later?

*** For example, the change from 09:59:59 to 10:00:00 will be construed as 6 digit changes.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

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

Function mform$(x, t$)
  a$ = Format$(x, t$)
  If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
  mform$ = a$
End Function

Private Sub Form_Load()
 ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 DoEvents
 
 Open "digital time check.txt" For Output As #2
 
 h = 9: m = 40: s = 41
 Do
   s = s + 1
   ct = ct + 1
   If s Mod 10 = 0 Then ct = ct + 1
   If s = 60 Then
    m = m + 1
    s = 0
    ct = ct + 1
    If m Mod 10 = 0 Then ct = ct + 1
    If m = 60 Then
     h = h + 1
     m = 0
     ct = ct + 1
     If h Mod 10 = 0 Then ct = ct + 1
     If h = 24 Then h = 0: ct = ct + 1: midnct = midnct + 1
    End If
   End If
   Print #2, mform(h, " 00") & ":" & mform(m, "00") & ":" & mform(s, "00") & "    " & Str(ct - prevct)
   prevct = ct
   If ct > 20139 And did1 = 0 Then
    did1 = 1
    Text1.Text = Text1.Text & ct & mform(h, " 00") & ":" & mform(m, "00") & ":" & mform(s, "00") & Str(midnct) & crlf
    DoEvents
   End If
   If ct > 201399 And did2 = 0 Then
    did2 = 1
    Text1.Text = Text1.Text & ct & mform(h, " 00") & ":" & mform(m, "00") & ":" & mform(s, "00") & Str(midnct) & crlf
    DoEvents
    Exit Do
   End If
 Loop

 Close

 Text1.Text = Text1.Text & crlf & " done"
End Sub

finds

20140 14:40:45 0
201401 11:41:20 2

meaning that 20140 digit changes have occurred by 14:40:45, which the clock reads at the conclusion of those 20140 changes.

But also, it requires 201401 digit changes to get to 11:41:20, two days later (two midnights have past--that's what the lone 2 at the end signifies). One second before that, only 201399 digit changes had taken place at that time. If the digit changes are taking place simultaneously, then there is no time at which 201400 digit changes have taken place.

If, however, the digit changes take place sequentially, in the same order (right-to-left) that we would ordinarily add a second and do the carry to the left, then the clock would read a temporarily incorrect 11:41:10 for an instant during the transition from 11:41:19 to 11:41:20.  If, however, the new digits are calculated internally, and then displayed sequentially, left-to-right, the instantaneous erroneous time woutd be 11:41:29 at the 201400-digit-change count.

Checks were done through the file produced, for correct increments of digit count:

 09:40:48     1
 09:40:49     1
 09:40:50     2
 09:40:51     1
 09:40:52     1
 
 ...
 
  09:40:58     1
  09:40:59     1
  09:41:00     3
  09:41:01     1
  09:41:02     1
 
 ...
 
  09:49:58     1
  09:49:59     1
  09:50:00     4
  09:50:01     1
  09:50:02     1
  
  ...
  
  10:59:58     1
  10:59:59     1
  11:00:00     5
  11:00:01     1
  11:00:02     1 
  
  ...
  
   19:59:58     1
   19:59:59     1
   20:00:00     6
   20:00:01     1
   20:00:02     1
   20:00:03     1
   
      ...
      
   23:59:58     1
   23:59:59     1
   00:00:00     6
   00:00:01     1
   00:00:02     1
   00:00:03     1


  Posted by Charlie on 2014-09-10 12:07:42
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (14)
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