--------------020306090501000109060104
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

James Edward Gray II a ˝─rit :
> It's my fault this quiz was released late and I think it is a fun
> problem.  I don't want to cheat anyone out of a chance to solve it, so
> I'm extending the quiz one week.  I will summarize a week from tomorrow.
>
> James Edward Gray II
>
So here is my solution ... maybe not very optimal, but working ... I
just found not so easy to understand what he wanted exactly as an
interface ... and found disturbing to give a paper to implement
something different (yet similar and obviously inspired by the paper).

Pierre


--------------020306090501000109060104
Content-Type: application/x-ruby;
 name0111_gizmo.rb"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename0111_gizmo.rb"

Cm1vZHVsZSBTZWNyZXRBZ2VudDAwMTExQ29tbXVuaWNhdGlvbkdpem1vCgogIGNsYXNzIFVu
ZGVmaW5lZFJMRSA8IEV4Y2VwdGlvbgogIGVuZAoKICBkZWYgc2VsZi5ybGUgZGF0YQogICAg
Y291bnRlciA9IDAKICAgIGNvZGUgPSBbXQogICAgcmFpc2UgVW5kZWZpbmVkUkxFLm5ldyBp
ZiBkYXRhLmVtcHR5PyB8fCBkYXRhWy0xXQogICAgZGF0YS5lYWNoIGRvIHx2YWx1ZXwKICAg
ICAgaWYgdmFsdWUKICAgICAgICBjb3VudGVyICs9IDEKICAgICAgZWxzZQogICAgICAgIGNv
ZGUgPDwgY291bnRlcgogICAgICAgIGNvdW50ZXIgPSAwCiAgICAgIGVuZAogICAgZW5kCiAg
ICBjb2RlCiAgZW5kCgogIGRlZiBzZWxmLnVucmxlIGNvZGUKICAgIGRhdGEgPSBbXQogICAg
Y29kZS5lYWNoIGRvIHx2YWx1ZXwKICAgICAgZGF0YSArPSBbdHJ1ZV0qdmFsdWUgKyBbZmFs
c2VdCiAgICBlbmQKICAgIGRhdGEKICBlbmQKCiAgZGVmIHNlbGYuZW5jb2RlIGFycmF5LCBl
eHBvbmVudAogICAgYml0c3RyaW5nID0gcGFkZGluZyhleHBvbmVudC50b19zKDIpLCA4KQog
ICAgdG9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ID0gMiAqKiBleHBvbmVudAogICAgY291bnRfdG90
YWwgPSAwCiAgICB1bnRpbCBiaXRzdHJpbmcuZW1wdHk/CiAgICAgIGNvdW50X3RvdGFsICs9
IDEKICAgICAgYnl0ZSA9IGJpdHN0cmluZy5zbGljZSEgMAogICAgICBpZiBieXRlID09ID8x
CiAgICAgICAgY291bnQgKz0gMQogICAgICBlbHNlCiAgICAgICAgdmFsdWUgPSBjb3VudCAq
IGJhc2UKICAgICAgICBjb3VudF90b3RhbCArPSBuYl9iaXRzCiAgICAgICAgICByZW0gPSBi
aXRzdHJpbmcuc2xpY2UhKDAsbmJfYml0cykudG9faSAyCiAgICAgICAgY29kZSA8PCB2YWx1
ZSArIHJlbQogICAgICAgIGNvdW50ID0gMAogICAgICBlbmQKICAgIGVuZAogICAgdW5sZXNz
IChjb3VudF90b3RhbCAlIDgpLnplcm8/CiAgICAgIGJpdHN0cmluZy5zbGljZSEoMCwgOC0o
Y291bnRfdG90YWwlOCkpCiAgICBlbmQKICAgIGRlY29kZWQgPSB1bnJsZShjb2RlKQogICAg
ZGVjb2RlZC5wb3AKICAgIGlmIHJlbWFpbmluZwogICAgICBbZGVjb2RlZCxiaXRzdHJpbmdd
CiAgICBlbHNlCiAgICAgIGRlY29kZWQKICAgIGVuZAogIGVuZAoKICBjbGFzcyBFbmNvZGVy
CgogICAgYXR0cl9yZWFkZXIgOmV4cG9uZW50LCA6aW8KCiAgICBkZWYgaW5pdGlhbGl6ZSBl
eHBvbmVudCwgaW8KICAgICAgQGV4cG9uZW50ID0gZXhwb25lbnQKICAgICAgQGlvID0gaW8K
ICAgICAgQGRhdGEgPSBbXQogICAgZW5kCgogICAgZGVmIDw8IHRvX2VuY29kZQogICAgICBA
ZGF0YSA8PCB0b19lbmNvZGUKICAgIGVuZAoKICAgIGRlZiBmaW5pc2gKICAgICAgY29kZSA9
IFNlY3JldEFnZW50MDAxMTFDb21tdW5pY2F0aW9uR2l6bW8uZW5jb2RlKEBkYXRhLCBleHBv
bmVudCkKICAgICAgaW8gPDwgY29kZQogICAgZW5kCgogIGVuZAoKICBjbGFzcyBEZWNvZGVy
CgogICAgYXR0cl9yZWFkZXIgOmlvLCA6ZXhwb25lbnQKCiAgICBhdHRyX2FjY2Vzc29yIDpj
b2RlLCA6cXVvdGllbnQsIDpjb3VudCwgOmJhc2UsIDpjb250ZW50LCA6c3RhdGUKCiAgICBk
ZWYgaW5pdGlhbGl6ZSBpbwogICAgICBAaW8gPSBpbwogICAgICBAZXhwb25lbnQgPSBuaWwK
ICAgICAgc2VsZi5jb2RlID0gIiIKICAgICAgc2VsZi5jb3VudCA9IDAKICAgICAgc2VsZi5x
dW90aWVudCA9IDAKICAgICAgc2VsZi5zdGF0ZSA9IDpxdW90aWVudAogICAgICByZWFkX2V4
cG9uZW50CiAgICBlbmQKCiAgICBkZWYgcmVhZF9leHBvbmVudAogICAgICBpZiBleHBvbmVu
dC5uaWw/IGFuZCBub3QgaW8uZW9mPwogICAgICAgIGV4cCA9IGlvLnJlYWQoMSkKICAgICAg
ICBAZXhwb25lbnQgPSBleHAudW5wYWNrKCJCKiIpWzBdLnRvX2kgMgogICAgICAgIHNlbGYu
YmFzZSA9IDIgKiogZXhwb25lbnQKICAgICAgZW5kCiAgICBlbmQKCiAgICBkZWYgcmVhZAog
ICAgICByZWFkX2V4cG9uZW50CiAgICAgIHJldHVybiBbXSBpZiBpby5lb2Y/CiAgICAgIHZh
bHVlcyA9IFtdCiAgICAgIGNvZGUuY29uY2F0IGlvLnJlYWQudW5wYWNrKCJCKiIpWzBdCiAg
ICAgIHVudGlsIGNvZGUuZW1wdHk/CiAgICAgICAgY2FzZSBzdGF0ZQogICAgICAgIHdoZW4g
OnF1b3RpZW50CiAgICAgICAgICBieXRlID0gY29kZS5zbGljZSEgMAogICAgICAgICAgaWYg
Ynl0ZSA9PSA/MQogICAgICAgICAgICBzZWxmLmNvdW50ICs9IDEKICAgICAgICAgIGVsc2UK
ICAgICAgICAgICAgc2VsZi5xdW90aWVudCA9IGNvdW50ICogYmFzZQogICAgICAgICAgICBz
ZWxmLnN0YXRlID0gOnJlbWFpbmRlcgogICAgICAgICAgICBzZWxmLmNvdW50ID0gMAogICAg
ICAgICAgZW5kCiAgICAgICAgd2hlbiA6cmVtYWluZGVyCiAgICAgICAgICBpZiBjb2RlLmxl
bmd0aCA+PSBleHBvbmVudAogICAgICAgICAgICByZW0gPSBjb2RlLnNsaWNlISgwLGV4cG9u
ZW50KS50b19pIDIKICAgICAgICAgICAgbmIgPSBxdW90aWVudCArIHJlbQogICAgICAgICAg
ICB2YWx1ZXMuY29uY2F0KFt0cnVlXSpuYiArIFtmYWxzZV0pCiAgICAgICAgICAgIHNlbGYu
c3RhdGUgPSA6cXVvdGllbnQKICAgICAgICAgIGVsc2UKICAgICAgICAgICAgYnJlYWsKICAg
ICAgICAgIGVuZAogICAgICAgIGVuZAogICAgICBlbmQKICAgICAgdmFsdWVzCiAgICBlbmQK
CiAgZW5kCgplbmQK
--------------020306090501000109060104--