------art_55730_10520573.1162183117524
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,

attached is my FuzzyTime.rb solution and a corresponding Unit Test
file. Thanks for the quiz, I look forward to any feedback. I didn't
have time to do the extra credit tasks :-(

On 10/27/06, Ruby Quiz <james / grayproductions.net> wrote:
> The three rules of Ruby Quiz:
>
> 1.  Please do not post any solutions or spoiler discussion for this quiz until
> 48 hours have passed from the time on this message.
>
> 2.  Support Ruby Quiz by submitting ideas as often as you can:
>
> http://www.rubyquiz.com/
>
> 3.  Enjoy!
>
> Suggestion:  A [QUIZ] in the subject of emails about the problem helps everyone
> on Ruby Talk follow the discussion.  Please reply to the original quiz message,
> if you can.
>
> --------------------
>
> by Gavin Kistner
>
>         The Background
>         ---------------------------------------------------------------------
>
> Last night I was having trouble falling asleep, and was staring at my digital
> alarm clock (as I do so often under that circumstance). Something on the bedside
> table was occluding the minutes digit, however, so all I could tell is that it
> was "10 4". (Oddly, my alarm clock has no ":" between the hours and minutes.)
>
> "How nice!" I thought. "An imposed vagueness to keep me from obsessing on
> exactly what time it is! Should I really be worried about the exact time?
> Shouldn't I be more relaxed? Shouldn't a 10-minute precision in life be enough
> to keep me roughly on time, without obsessing on exacting promptitude?"
>
> I realized that if I kept staring at the clock (as I did), and I were to observe
> it changing from "10 4" to "10 5", that I would, at that moment, know exactly
> what time it is.
>
> "Bah" I thought, "so much for that idea."
>
> And then I thought some more. I thought of bad ideas: analog watches where the
> hand erratically swings forward and backward, digital clocks that showed random
> times near the correct time. And then I dreamed of the watch I wanted to own...
>
>         The Challenge
>         ---------------------------------------------------------------------
>
> Requirement #1: Write a Ruby program that shows the current time, but only the
> 'tens' part of the minutes. For example, if the time is 10:37, then the program
> might output "10:3~"
>
> 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~".)
>
> Putting the three requirements together, the left column below shows the actual
> time and the next three columns show the possible outputs from three different
> runs of the same program:
>
>         10:35    10:3~    10:4~    10:3~
>         10:36    10:3~    10:4~    10:3~
>         10:37    10:3~    10:4~    10:3~
>         10:38    10:3~    10:4~    10:3~
>         10:39    10:4~    10:4~    10:3~
>         10:40    10:4~    10:4~    10:3~
>         10:41    10:4~    10:4~    10:3~
>         10:42    10:4~    10:4~    10:3~
>         10:43    10:4~    10:4~    10:3~
>         10:44    10:4~    10:4~    10:3~
>         10:45    10:4~    10:4~    10:4~
>         10:46    10:4~    10:4~    10:5~
>         10:47    10:4~    10:4~    10:5~
>         10:48    10:4~    10:4~    10:5~
>         10:49    10:4~    10:4~    10:5~
>         10:50    10:4~    10:4~    10:5~
>         10:51    10:4~    10:4~    10:5~
>         10:52    10:5~    10:4~    10:5~
>         10:53    10:5~    10:4~    10:5~
>         10:54    10:5~    10:4~    10:5~
>         10:55    10:5~    10:5~    10:5~
>         10:56    10:5~    10:5~    11:0~
>         10:57    10:5~    10:5~    11:0~
>         10:58    10:5~    10:5~    11:0~
>         10:59    10:5~    10:5~    11:0~
>         11:00    10:5~    10:5~    11:0~
>         11:01    10:5~    10:5~    11:0~
>
>         Testing your Output
>         ---------------------------------------------------------------------
>
> You should supply a FuzzyTime class that supports the following:
>
>         ft  uzzyTime.new                      # Start at the current time
>         ft  uzzyTime.new(Time.at(1161104503)) # Start at a specific time
>
>         p ft.to_s                               # to_s format
>         #"10:5~"
>
>         p ft.actual, ft.actual.class            # Reports real time as Time
>         #Tue Oct 17 11:01:36 -0600 2006
>         #Time
>
>         ft.advance( 60 * 10 )                   # Manually advance time
>         puts ft                                 # by a specified number of
>         #11:0~                               # seconds.
>
>         sleep( 60 * 10 )
>
>         ft.update              # Automatically update the time based on the
>         puts ft                # time that has passed since the last call
>         #11:1~              # to #initialize, #advance or #update
>
> Your class and output will be tested with code like the following:
>
>         def test_output
>           # Initialize with a well-known time
>           ft  uzzyTime.new( Time.at( ... ) )
>
>           60.times do
>             @legal   ..       # Find the array of legal output strings
>             @output  t.to_s
>
>             assert_block "#@output not one of #@legal.inspect" do
>               @legal.include?( @output )
>             end
>
>             sleep( rand( 30 ) )
>             ft.update
>           end
>
>           60.times do
>             @legal   ..       # Find the array of legal output strings
>             @output  t.to_s
>
>             assert_block "#@output not one of #@legal.inspect" do
>               @legal.include?( @output )
>             end
>
>             ft.advance( rand( 30 ) )
>           end
>         end
>
>         Extra Credit
>         ---------------------------------------------------------------------
>
>         * Provide a self-running application that shows the time somehow.
>         (ASCII in the terminal, some GUI window, etc.)
>
>         * Allow your class to be customized to display 12- or 24-hour time.
>
>         * Allow your class to be customized to change how close to reality
>         it must display. (+/- 3 minutes, +/- 12 minutes, etc.)
>
>         * Allow your class to be customized to change how roughly it displays
>         the time (e.g. 1 minute, 10 minute, 1 hour intervals).
>
>         * Ensure that the transition from one digit to the next occurs
>         randomly across the range of -5 to +5. (So, while the digit might
>         change 5 minutes before or 5 minutes after the real transition, on
>         average the change should occur around the transition itself.)
>         You might need to assume that your update/advance method will be
>         called with a certain regularity (e.g. once per second, once every
>         7 seconds, once every 30 seconds, etc.)
>
>         * Come up with your own technique of displaying time that
>         (a) is always 'close' to right, but (b) never allows a
>         watchful person to ever know exactly what time it is.
>
>         Things to Keep in Mind
>         ---------------------------------------------------------------------
>
>         * You need to be able to handle the transition across hour/day
>         boundaries. (10:5~ might change to 11:0~ when the real time is still
>         10:58, or might continue to display 10:5~ when the real time is
>         11:04. On a 24-hour click, you also need to be able to wrap from
>         23:5~ to 00:0~)
>
>         * For testing purposes of the real-time #update advancing, you might
>         find it easier to work with minutes and seconds instead of hours and
>         minutes.
>
>         * Requirement #3 is, well, a requirement. Repeated #update/#to_s
>         calls to a FuzzyTime instance should never show an earlier time
>         (unless 24 hours occurred between #update calls ;).
>
>


-- 
Caleb

"There is no theory of evolution, just a list of creatures Chuck
Norris allows to live."

------art_55730_10520573.1162183117524
Content-Type: application/octet-stream; name=FuzzyTime.rb
Content-Transfer-Encoding: base64
X-Attachment-Id: f_etwdsl0s
Content-Disposition: attachment; filename="FuzzyTime.rb"

Y2xhc3MgRnV6enlUaW1lCiAgICAKICAgIGF0dHJfYWNjZXNzb3IoOnRpbWUsIDpmdXp6eV90aW1l
KQogICAgCiAgICBkZWYgaW5pdGlhbGl6ZShjdXJyZW50X3RpbWU9VGltZS5ub3csIGRldmlhdGlv
bj0zMDApCgkJQHRpbWUgPSBjdXJyZW50X3RpbWUKCQlAZnV6enlfdGltZSA9IGN1cnJlbnRfdGlt
ZQoJCUBkZXZpYXRpb24gPSBkZXZpYXRpb24KCWVuZAoKCWRlZiB0b19zCgkJQGZ1enp5X3RpbWUg
PSByYW5kb21fdGltZShAdGltZSwgQGZ1enp5X3RpbWUsIEBkZXZpYXRpb24pCgkJcyA9IEBmdXp6
eV90aW1lLnN0cmZ0aW1lKCIlSTolTSIpCgkJcy5nc3ViISgvKFtcZF1bXGRdOltcZF0pW1xkXS8p
IHsgfHN8ICQxKyJ+In0KCWVuZAoKCWRlZiBhY3R1YWwKCQlUaW1lLm5vdwoJZW5kCgoJZGVmIGFk
dmFuY2Uoc2Vjb25kcykKCQlAdGltZSA9IHRpbWUgKyBzZWNvbmRzCgllbmQKCglkZWYgdXBkYXRl
CgkJQHRpbWUgPSBUaW1lLm5vdwoJZW5kCgogICAgIAogICAgIyBDb21wYXJlcyB0d28gVGltZSBv
YmplY3RzIGluIGEgZnV6enkgbWFubmVyLiBUbyBiZSBlcXVhbCwgdGhleSBtdXN0IGhhdmUKICAg
ICMgdGhlIHNhbWUgdmFsdWVzIGZvciB0aGUgeWVhciwgbW9udGgsIGRheSwgYW5kIGhvdXIuIFRo
ZWlyIG1pbnV0ZQogICAgIyB2YWx1ZXMgbmVlZCB0byBmYWxsIGludG8gdGhlIHNhbWUgMTAtZGln
aXQgcmFuZ2UuCiAgICAjIEZvciBleGFtcGxlOiAKICAgICMgZnV6enlfY29tcGFyZSgyMDA2LzAx
LzAxIDAxOjE1OjUyLDIwMDYvMDEvMDEgMDE6MTY6NDEpCiAgICAjID0+MCAgCiAgICAjIGZ1enp5
X2NvbXBhcmUoMjAwNi8wMS8wMSAwMToxNTo1MiwyMDA2LzAxLzAxIDAxOjIxOjQxKQogICAgIyA9
Pi0xICAKICAgICMgZnV6enlfY29tcGFyZSgyMDA2LzAxLzAxIDAxOjE1OjUyLDIwMDYvMDEvMDEg
MDE6MDk6NDEpCiAgICAjID0+MSAgCiAgICBkZWYgZnV6enlfY29tcGFyZSh0aW1lMSwgdGltZTIp
CiAgICAgICAgaWYodGltZTEgPCB0aW1lMiAmJgogICAgICAgICAgICAodGltZTEueWVhciA8IHRp
bWUyLnllYXIgfHwgCiAgICAgICAgICAgIHRpbWUxLm1vbnRoIDwgdGltZTIubW9udGggfHwKICAg
ICAgICAgICAgdGltZTEuZGF5IDwgdGltZTIuZGF5IHx8CiAgICAgICAgICAgIHRpbWUxLmhvdXIg
PCB0aW1lMi5ob3VyIHx8IAogICAgICAgICAgICAoKHRpbWUxLm1pbiArIDEwKSAvIDEwKS5mbG9v
ciA8ICgodGltZTIubWluKzEwKSAvIDEwKS5mbG9vcikpCiAgICAgICAgICAgIHJldHVybiAtMQog
ICAgICAgIGVsc2lmKHRpbWUxID4gdGltZTIgJiYKICAgICAgICAgICAgKHRpbWUxLnllYXIgPiB0
aW1lMi55ZWFyIHx8IAogICAgICAgICAgICB0aW1lMS5tb250aCA+IHRpbWUyLm1vbnRoIHx8CiAg
ICAgICAgICAgIHRpbWUxLmRheSA+IHRpbWUyLmRheSB8fAogICAgICAgICAgICB0aW1lMS5ob3Vy
ID4gdGltZTIuaG91ciB8fCAKICAgICAgICAgICAgKHRpbWUxLm1pbiAvIDEwKS5mbG9vciA+ICh0
aW1lMi5taW4gLyAxMCkuZmxvb3IpKSAgICAgICAgICAgCiAgICAgICAgICAgIHJldHVybiAxIAog
ICAgICAgIGVsc2UKICAgICAgICAgICAgcmV0dXJuIDAgCiAgICAgICAgZW5kCiAgICBlbmQKICAg
IAogICAgI2dlbmVyYXRlcyBhIHJhbmRvbSB0aW1lIG9iamVjdCBiYXNlZCBvbiB0aGUgY3VycmVu
dF90aW1lCiAgICBkZWYgcmFuZG9tX3RpbWUodGltZSwgbWluX3RpbWVfYm91bmRhcnksIHNlY3M9
NjApCiAgICAgICAgcmFuZG9tX3NlY3MgPSByYW5kb20oc2VjcykKICAgICAgICBuZXdfZnV6enlf
dGltZSA9IG5pbAogICAgICAgIGlmKHN1YnRyYWN0X3RpbWU/KSAgCiAgICAgICAgICAgIG5ld19m
dXp6eV90aW1lID0gdGltZS1yYW5kb21fc2VjcwogICAgICAgIGVsc2UKICAgICAgICAgICAgbmV3
X2Z1enp5X3RpbWUgPSB0aW1lK3JhbmRvbV9zZWNzCiAgICAgICAgZW5kCiAgICAgICAgaWYgKGZ1
enp5X2NvbXBhcmUobmV3X2Z1enp5X3RpbWUsIG1pbl90aW1lX2JvdW5kYXJ5KSA9PSAtMSkKICAg
ICAgICAgICAgbmV3X2Z1enp5X3RpbWUgPSBtaW5fdGltZV9ib3VuZGFyeS5zdWNjICMgYWRkIHRo
ZSB0aW1lIGJhY2sKICAgICAgICBlbmQgICAgCiAgICAgICAgbmV3X2Z1enp5X3RpbWUgIAogICAg
ZW5kICAKICAgIAogICAgI3RoZSBmb2xsb3dpbmcgbWV0aG9kcyBmYWNpbGl0YXRlIHVuaXR0ZXN0
aW5nCiAgICBkZWYgc3VidHJhY3RfdGltZT8KICAgICAgICAocmFuZCgxMCkgJSAyKSA9PSAxCiAg
ICBlbmQgICAgICAKICAgIAogICAgZGVmIHJhbmRvbShzZWNvbmRzKQogICAgICAgIHJhbmQoc2Vj
b25kcykKICAgIGVuZAplbmQKCgo------art_55730_10520573.1162183117524
Content-Type: application/octet-stream; name=FuzzyTimeTest.rb
Content-Transfer-Encoding: base64
X-Attachment-Id: f_etwdszjr
Content-Disposition: attachment; filename="FuzzyTimeTest.rb"

cmVxdWlyZSAndGVzdC91bml0JwpyZXF1aXJlICdGdXp6eVRpbWUucmInCgpjbGFzcyBGdXp6eVRp
bWVUZXN0IDwgVGVzdDo6VW5pdDo6VGVzdENhc2UKICAgCiAgICBkZWYgc2V0dXAKICAgICAgICBA
ZXBvY2ggPSBUaW1lLmF0KDApI1dlZCBEZWMgMzEgMTk6MDA6MDAgQ1NUIDE5NjkKICAgIGVuZAog
ICAgCiAgICBkZWYgdGVzdF9hZHZhbmNlCiAgICAgICAgZnQgPSBGdXp6eVRpbWUubmV3KEBlcG9j
aCkjc2V0IHRpbWUgdG8gZXBvY2gKICAgICAgICBhc3NlcnRfZXF1YWwoQGVwb2NoLCBmdC50aW1l
KQogICAgICAgIGluY3JlbWVudCA9IDYwICogMTAKICAgICAgICBmdC5hZHZhbmNlKGluY3JlbWVu
dCkgI21vdmUgYWhlYWQgCiAgICAgICAgYXNzZXJ0X25vdF9lcXVhbChAZXBvY2gsIGZ0LnRpbWUp
CiAgICAgICAgYXNzZXJ0X2VxdWFsKEBlcG9jaCArIGluY3JlbWVudCwgZnQudGltZSkKICAgIGVu
ZAogICAgCiAgICBkZWYgdGVzdF91cGRhdGUKICAgICAgICBmdCA9IEZ1enp5VGltZS5uZXcoQGVw
b2NoKSNzZXQgdGltZSB0byBlcG9jaAogICAgICAgIGFzc2VydF9lcXVhbChAZXBvY2gsIGZ0LnRp
bWUpCiAgICAgICAgYXNzZXJ0X25vdF9lcXVhbChAZXBvY2gsIGZ0LnVwZGF0ZSkKICAgICAgICBh
c3NlcnRfbm90X2VxdWFsKEBlcG9jaCwgZnQudGltZSkKICAgIGVuZCAgICAKICAgIAogICAgZGVm
IHRlc3RfdG9fcwogICAgICAgIGZ0ID0gRnV6enlUaW1lLm5ldyhAZXBvY2gpI3NldCB0aW1lIHRv
IGVwb2NoCiAgICAgICAgYXNzZXJ0X21hdGNoKC8wWzZ8N106WzV8MF1+LywgZnQ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uZXcoQGVwb2NoKQogICAgICAgIGZ0LnRvX3MK
ICAgICAgICAyNDAudGltZXMgZG8KICAgICAgICAgICAgCiAgICAgICAgICAgIHByZXZfZnV6enlf
dGltZSA9IFRpbWUuYXQoZnQuZnV6enlfdGltZS50b19pKSNnZXQgdGhlIHByZXZpb3VzbHkgcHJp
bnRlZCB0aW1lIHZhbHVlCiAgICAgICAgICAgIGZ0LmFkdmFuY2UoNjApI2FkdmFuY2UgY2xvY2sg
MSBtaW51dGUKICAgICAgICAgICAgZnQudG9fcwogICAgICAgICAgICBjdXJyX2Z1enp5X3RpbWUg
PSBmdC5mdXp6eV90aW1lCiAgICAgICAgICAgIAogICAgICAgICAgICAjcmVxIzM6IHRoZSBwcmV2
IGhvdXIgc2hvdWxkIGFsd2F5cyBiZSA8PSBjdXJyZW50IGhvdXIKICAgICAgICAgICAgYXNzZXJ0
KHByZXZfZnV6enlfdGltZS5ob3VyIDw9IGN1cnJfZnV6enlfdGltZS5ob3VyKQogICAgICAgICAg
ICAKICAgICAgICAgICAgI3JlcSMzOiBpZiB0aGUgaG91ciBpcyB0aGUgc2FtZSwgdGhlbiB0aGUg
CiAgICAgICAgICAgICNwcmV2X21pbnV0ZS1jdXJyX21pbnV0ZSA8PTEwICAgIAogICAgICAgICAg
ICBpZihwcmV2X2Z1enp5X3RpbWUuaG91ciA9PSBjdXJyX2Z1enp5X3RpbWUuaG91ciAmJiAKICAg
ICAgICAgICAgICAgICgoY3Vycl9mdXp6eV90aW1lLm1pbiAvIDEwKS5mbG9vciA8ICAocHJldl9m
dXp6eV90aW1lLm1pbiAvIDEwKS5mbG9vcikpCiAgICAgICAgICAgICAgICBjdXJyZW50ID0gY3Vy
cl9mdXp6eV90aW1lLnN0cmZ0aW1lKCIlSTolTSIpCiAgICAgICAgICAgICAgICBwcmV2aW91cyA9
IHByZXZfZnV6enlfdGltZS5zdHJmdGltZSgiJUk6JU0iKQogICAgICAgICAgICAgICAgZmFpbCgi
Q3VycmVudCBUaW1lOiN7Y3VycmVudH0gY2Fubm90IGJlIDwgdGhhbiBQcmV2aW91cyBUaW1lOiAj
e3ByZXZpb3VzfSIpCiAgICAgICAgICAgIGVuZAogICAgICAgICAgICAKICAgICAgICAgICAgI1Ro
ZSBkaWZmZXJlbmNlIGJldHdlZW4gdGhlIGN1cnJlbnQgbWludXRlcyBhbmQgcHJldmlvdWVzIG1p
bnV0ZXMgY2Fubm90CiAgICAgICAgICAgICNiZSBncmVhdGVyIHRoYW4gMTAKICAgICAgICAgICAg
aWYocHJldl9mdXp6eV90aW1lLmhvdXIgPT0gY3Vycl9mdXp6eV90aW1lLmhvdXIpIAogICAgICAg
ICAgICAgICAgZGlmZiA9IGN1cnJfZnV6enlfdGltZS5taW4gLSBwcmV2X2Z1enp5X3RpbWUubWlu
CiAgICAgICAgICAgICAgICBhc3NlcnQoZGlmZiA+PSAtMTApCiAgICAgICAgICAgICAgICBhc3Nl
cnQoZGlmZiA8PSAxMCkKICAgICAgICAgICAgZW5kCiAgICAgICAgZW5kICAgIAogICAgZW5kCiAg
ICAKICAgIGRlZiB0ZXN0X291dHB1dF91cGRhdGUKICAgICAgICBmdCA9IEZ1enp5VGltZS5uZXco
QGVwb2NoKQogICAgICAgIGZ0LnRvX3MKICAgICAgICAyNDAudGltZXMgZG8KICAgICAgICAgICAg
CiAgICAgICAgICAgIHByZXZfZnV6enlfdGltZSA9IFRpbWUuYXQoZnQuZnV6enlfdGltZS50b19p
KSNnZXQgdGhlIHByZXZpb3VzbHkgcHJpbnRlZCB0aW1lIHZhbHVlCiAgICAgICAgICAgIGZ0LnVw
ZGF0ZQogICAgICAgICAgICBmdC50b19zCiAgICAgICAgICAgIGN1cnJfZnV6enlfdGltZSA9IGZ0
LmZ1enp5X3RpbWUKICAgICAgICAgICAgCiAgICAgICAgICAgICNyZXEjMzogdGhlIHByZXYgaG91
ciBzaG91bGQgYWx3YXlzIGJlIDw9IGN1cnJlbnQgaG91cgogICAgICAgICAgICBhc3NlcnQocHJl
dl9mdXp6eV90aW1lLmhvdXIgPD0gY3Vycl9mdXp6eV90aW1lLmhvdXIpCiAgICAgICAgICAgIAog
ICAgICAgICAgICAjcmVxIzM6IGlmIHRoZSBob3VyIGlzIHRoZSBzYW1lLCB0aGVuIHRoZSAKICAg
ICAgICAgICAgI3ByZXZfbWludXRlLWN1cnJfbWludXRlIDw9MTAgICAgCiAgICAgICAgICAgIGlm
KHByZXZfZnV6enlfdGltZS5ob3VyID09IGN1cnJfZnV6enlfdGltZS5ob3VyICYmIAogICAgICAg
ICAgICAgICAgKChjdXJyX2Z1enp5X3RpbWUubWluIC8gMTApLmZsb29yIDwgIChwcmV2X2Z1enp5
X3RpbWUubWluIC8gMTApLmZsb29yKSkKICAgICAgICAgICAgICAgIGN1cnJlbnQgPSBjdXJyX2Z1
enp5X3RpbWUuc3RyZnRpbWUoIiVJOiVNIikKICAgICAgICAgICAgICAgIHByZXZpb3VzID0gcHJl
dl9mdXp6eV90aW1lLnN0cmZ0aW1lKCIlSTolTSIpCiAgICAgICAgICAgICAgICBmYWlsKCJDdXJy
ZW50IFRpbWU6I3tjdXJyZW50fSBjYW5ub3QgYmUgPCB0aGFuIFByZXZpb3VzIFRpbWU6ICN7cHJl
dmlvdXN9IikKICAgICAgICAgICAgZW5kCiAgICAgICAgICAgIAogICAgICAgICAgICAjVGhlIGRp
ZmZlcmVuY2UgYmV0d2VlbiB0aGUgY3VycmVudCBtaW51dGVzIGFuZCBwcmV2aW91ZXMgbWludXRl
cyBjYW5ub3QKICAgICAgICAgICAgI2JlIGdyZWF0ZXIgdGhhbiAxMAogICAgICAgICAgICBpZihw
cmV2X2Z1enp5X3RpbWUuaG91ciA9PSBjdXJyX2Z1enp5X3RpbWUuaG91cikgCiAgICAgICAgICAg
ICAgICBkaWZmID0gY3Vycl9mdXp6eV90aW1lLm1pbiAtIHByZXZfZnV6enlfdGltZS5taW4KICAg
ICAgICAgICAgICAgIGFzc2VydChkaWZmID49IC0xMCkKICAgICAgICAgICAgICAgIGFzc2VydChk
aWZmIDw9IDEwKQogICAgICAgICAgICBlbmQKICAgICAgICBlbmQgICAgCiAgICBlbmQgICAgCmVu
ZAoKCg------art_55730_10520573.1162183117524--