[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: [QUIZ] Fuzzy Time (#99

Gavin Kistner

10/27/2006 4:01:00 PM

From: ara.t.howard@noaa.gov [mailto:ara.t.howard@noaa.gov]
> > Requirement #2: The time shown by the clock must randomly
> > vary +/- 5 minutes from reality. For example, if the time
> > is actually 10:37, the program might output "10:3~" or
> > "10:4~" (but not "10:2~" or "10:5~").
> >
> > Requirement #3: The time on the clock should continuously
> > increase. If the time shows "10:4~" it must continue to
> > show "10:4~" until it shows "10:5~". (It can't show
> > "10:4~", then "10:3~" for a bit and then come back to
> > "10:4~".)

> it seems like #2 and #3 contradict one another. imagine it's
> 10:45 and, through randomness, you choose to vary the clock
> by +5, therefore displaying 10:5~, you will not be able to
> change the output again until 10:55, and then only because
> the upper bould will have rolled over into the next hour.
> here it is in table form

That's correct; why do you call this a contradiction?

The observer has no knowledge that you happened to be a full 5 minutes
ahead of schedule. Internally, your model might be:

Actual Internal Displayed
10:44 10:47 10:4~
10:45 10:50 10:5~
10:46 10:50 10:5~
10:47 10:51 10:5~
10:48 10:52 10:5~
10:49 10:52 10:5~
10:50 10:52 10:5~
10:51 10:52 10:5~
10:52 10:52 10:5~
10:53 10:52 10:5~
10:54 10:52 10:5~
10:55 10:54 10:5~
10:56 10:55 10:5~
10:57 11:00 11:0~

To be clear, by "+/- 5 minutes" I meant "it is not tied to the current
time, but must not deviate by more than 5 minutes from reality", not "It
must be exactly either 5 minutes ahead or 5 minutes behind the actual
time."


> so the combined effect means that it's acceptable to display
> the same time~
> for twenty straight minutes - is that really the a desired
> potential effect?

It is. Time flies when you're coding Ruby, and stands still when you're
doing work. :)

Think about it this way:

In order to not know what time it really is, you cannot always display
the tens digit for exactly 10 minutes in a row. (If you did, the user
would simply have a precise-but-inaccurate clock that was a little fast
or slow.) Thus, you have to be able to sometimes show the tens for less
than ten minutes, and sometimes for greater than ten minutes.

It seemed odd to me that varying by only +/- 5 minutes allows the same
tens digit to be displayed for 20 minutes, but that's the way the math
comes out. :)

1 Answer

Ara.T.Howard

10/27/2006 4:34:00 PM

0