------art_32179_339682.1157293141324
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Attached is my solution (shiawase_kazu_keikaku.rb and also available
at http://www.makenai.net/tmp/shiawase_kazu_keikaku.rb ):

It's definitely not going to win any speed contests, but I'm happy
enough that it's short and fairly readable. I didn't try to
over-optimize - after all, I had two days to run the happiness of
1..1,000,000 and it took quite a long time, but not nearly that long!

The second file (sekeol_happy.rb and also available at
http://www.makenai.net/tmp/sekeol_happy.rb ) is being submitted on
behalf of my coworker, Sekeol Kim. Unfortunately, he didn't leave me
any commentary other than the request that I submit the file for him
after the deadline lapsed.

Thanks!

-Pawel

------art_32179_339682.1157293141324
Content-Type: application/x-ruby; name=shiawase_kazu_keikaku.rb
Content-Transfer-Encoding: base64
X-Attachment-Id: f_erni6ce9
Content-Disposition: attachment; filename="shiawase_kazu_keikaku.rb"

Y2xhc3MgSW50ZWdlcgogIAogIGRlZiBkaWdpdHMoIGJhc2U9MTAgKQogICAgdG9fcyggYmFzZSAp
LnNwbGl0KCcnKS5tYXAgeyB8Y3wgYy50b19pKCBiYXNlICkgfQogIGVuZAogIAogIGRlZiBoYXBw
eT8oIGJhc2U9MTAgKQogICAgc2Vlbl9udW1iZXJzID0gW10KICAgIG4gPSBzZWxmCiAgICBsb29w
IGRvCiAgICAgIG4gPSBuLmRpZ2l0cyggYmFzZSApLmluamVjdCgwKSB7IHxzdW0sbnwgc3VtICsg
KG4gKiogMikgfQogICAgICByZXR1cm4gdHJ1ZSBpZiBuID09IDEKICAgICAgeWllbGQgbiBpZiBi
bG9ja19naXZlbj8KICAgICAgcmV0dXJuIGZhbHNlIGlmIHNlZW5fbnVtYmVycy5pbmNsdWRlPygg
biApCiAgICAgIHNlZW5fbnVtYmVycyA8PCBuCiAgICBlbmQKICBlbmQKICAKICBkZWYgaGFwcGlu
ZXNzKCBiYXNlPTEwICkKICAgIG51bWJlcnMgPSBbXQogICAgc2VsZi5oYXBweT8oIGJhc2UgKSB7
IHxufCBudW1iZXJzIDw8IG4gfQogICAgbnVtYmVycy5zZWxlY3QgeyB8bnwgbi5oYXBweT8oIGJh
c2UgKSB9Lmxlbmd0aAogIGVuZAogIAplbmQKCmlmICQwID09IF9fRklMRV9fCiAgCiAgKDIuLjM2
KS5lYWNoIGRvIHxiYXNlfAogICAgcHV0cyAiSGFwcHkgbnVtYmVycyBiZXR3ZWVuIDIgYW5kIDEw
MCBpbiBiYXNlICN7YmFzZX06IgogICAgcHV0cyAoMi4uMTAwKS5zZWxlY3QgeyB8bnwgbi5oYXBw
eT8oYmFzZSkgfS5qb2luKCcsICcpCiAgICBwdXRzCiAgZW5kCiAgCiAgcHV0cyAiU2Vla2luZyBv
dXQgdGhlIGhhcHBpZXN0IGJhc2UgMTAgbnVtYmVyIGJldHdlZW4gMSBhbmQgMSwwMDAsMDAwLi4i
CiAgcHV0cyAiKEhpdCBDVFJMLUMgaWYgeW91IGRvbid0IGhhdmUgYW4gaG91ciBvciBzbyB0byBz
cGFyZS4pIgogIGJlZ2luCiAgICBoYXBwaWVzdF9udW1iZXIgPSAoMS4uMTAwMDAwMCkuaW5qZWN0
KDApIHsgfG1lbW8sbnwgbWVtby5oYXBwaW5lc3MgPj0gbi5oYXBwaW5lc3MgPyBtZW1vIDogbiB9
CiAgICBwdXRzICJBbmQgdGhlIGFuc3dlciBpcy4uLiAje2hhcHBpZXN0X251bWJlcn0gd2l0aCBh
IGhhcHBpbmVzcyBzY29yZSBvZiAje2hhcHBpZXN0X251bWJlci5oYXBwaW5lc3N9LiIKICByZXNj
dWUgSW50ZXJydXB0CiAgICBwdXRzCiAgICBwdXRzICJPaywgSSBkb24ndCBibGFtZSB5b3UuIFRo
ZSBhbnN3ZXIgd291bGQgaGF2ZSBiZWVuIDc4OTk5IHdpdGggYSBoYXBwaW5lc3Mgc2NvcmUgb2Yg
Ni4iCiAgZW5kCgplbmQ------art_32179_339682.1157293141324
Content-Type: application/x-ruby; name=sekeol_happy.rb
Content-Transfer-Encoding: base64
X-Attachment-Id: f_erni6nqo
Content-Disposition: attachment; filename="sekeol_happy.rb"

Y2xhc3MgSW50ZWdlcgogICAgQEBoYXBweSA9IEhhc2gubmV3IHt8aCxrfCBoW2sudG9fa2V5XSA9
IGsudG9faS5oYXBwaW5lc3N9CiAgICBOUyA9IFswLCAxLCA0LCA5LCAxNiwgMjUsIDM2LCA0OSwg
NjQsIDgxXQoKICAgIGRlZiBoYXBwaW5lc3MKICAgICAgICByZXR1cm4gQEBoYXBweVt0b19rZXld
IGlmIEBAaGFwcHkuaGFzX2tleT8odG9fa2V5KQogICAgICAgIHcsIGVycmxldiA9IFtzZWxmXSwg
ZmFsc2UKICAgICAgICBoID0gMAogICAgICAgIHVudGlsIGVycmxldgogICAgICAgICAgICB3IDw8
IHdbLTFdLmhhcHBpbmVzc19zdGVwCiAgICAgICAgICAgIGsgPSB3Wy0xXS50b19rZXkKICAgICAg
ICAgICAgaWYgQEBoYXBweS5oYXNfa2V5PyhrKQogICAgICAgICAgICAgICAgdyArPSAoQEBoYXBw
eVtrXSkKICAgICAgICAgICAgICAgIGVycmxldiA9IHRydWUKICAgICAgICAgICAgZW5kCiAgICAg
ICAgICAgIGVycmxldiA9IChbMCwyLDMsNCw1LDYsOCw5XS5pbmNsdWRlPyh3Wy0xXSkgfHwgKHcu
dW5pcS5sZW5ndGggPCB3Lmxlbmd0aCkpCiAgICAgICAgZW5kCiAgICAgICAgQEBoYXBweVt0b19r
ZXldID0gdwogICAgZW5kCgogICAgZGVmIGhhcHB5PzsgaGFwcGluZXNzWy0xXT09MTsgZW5kCiAg
ICBwcm90ZWN0ZWQKICAgIGRlZiBkaWdpdGl6ZTsgc2VsZi50b19zLnNwbGl0KC8vKS5jb2xsZWN0
IHt8eHwgeC50b19pfS5kZWxldGVfaWYge3x4fCB4Lnplcm8/fTsgZW5kCiAgICBkZWYgaGFwcGlu
ZXNzX3N0ZXA7IHJldHVybiAwIGlmIGRpZ2l0aXplLm5pbD87IGRpZ2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