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

Home > Numbers
Hours of Operation (Posted on 2014-11-12) Difficulty: 2 of 5
While on a walk the other day I passed an auto body shop whose hours were 9:15am - 4:30pm. Aside from the oddly specific opening hour, I noticed that, between the two times, no digits were repeated.

(a) If I assume that I'm using a 12-hour clock, and that I'm never open at midnight, what are the longest and shortest hours of operation I can have that still have no repeated digits in my two times?

(b) What if I'm using a 24-hour clock?

[NOTE: assume no leading zeros for the hour, but leading zeros in the minute in order to always have a two-digit minutes value.]

No Solution Yet Submitted by Paul    
Rating: 3.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Some Thoughts Longest for 12-hour clock: computer solution Comment 8 of 8 |
DefDbl A-Z
Dim crlf$, fct(20, 1)


Private Sub Form_Load()
 ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 DoEvents
 
 
 For st = 1 To 1439
   For fin = st + 1 To 1439
     s$ = conv$(st)
     f$ = conv$(fin)
     d$ = s$ + f$
     good = 1
     For i = 1 To Len(d$) - 1
       If InStr(Mid(d$, i + 1), Mid(d$, i, 1)) > 0 Then good = 0
     Next
     If good Then
       If fin - st >= mx Then
         mx = fin - st
         Text1.Text = Text1.Text & mx & "  " & s$ & "  " & f$ & crlf
         DoEvents
       End If
     End If
   Next
 Next

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

Function conv$(n)
  x = n
  If x >= 720 Then x = x - 720
  h = x \ 60: m = x Mod 60
  If h = 0 Then h = 12
  ms$ = LTrim(Str(m)): If Len(ms$) < 2 Then ms$ = Right("000" + ms$, 2)
  hs$ = LTrim(Str(h))
  conv$ = hs$ + ms$
End Function

shows

1315  1203  958

meaning 1315 minutes between 12:03 am and 9:58 pm.

  Posted by Charlie on 2014-11-13 08:15:01
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 (6)
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