Here's an admittedly somewhat odd-ball pass time:  create a generator
that hides in "x" in some deeply nested data structure, then come up
with a key for retrieving that "x" (might be a buried treasure!).

For example:

If:

x = "Yes!"

maze =  
[(),(),{'a':0},([[{'a':1,'b':{('a','b'):{('a','b'):[[{'a':1,'b':{('a','b'):[(),(),{'a':0},([[{'a':1,'b':[[{'a':1,'b':{('a','b'):x,
('c','d'):2}},0],(1,)]},0],(1,)],)], ('c','d'):2}},0],(1,)],
('c','d'):2}, ('c','d'):2}},0],(1,)],)]

then:

maze[3][0][0][0]["b"][("a","b")][("a","b")][0][0]["b"][("a","b")][3][0][0][0]["b"][0][0]["b"][("a","b")]
would be a solution.

Another example:

>>> maze =  
>>> [[{'a':1,'b':[[{'a':1,'b':[(),(),{'a':0},([(),(),{'a':0},([(),(),{'a':0},([[{'a':1,'b':[[{'a':1,'b':[[{'a':1,'b':[(),(),{'a':0},([(),(),{'a':0},(x,)],)]},0],(1,)]},0],(1,)]},0],(1,)],)],)],)]},0],(1,)]},0],(1,)]

Solution:

>>> maze[0][0]["b"][0][0]["b"][3][0][3][0][3][0][0][0]["b"][0][0]["b"][0][0]["b"][3][0][3][0]
'Yes!'

OK, I warned you this was dumb.

The fun part was writing a generator to spit out maze/solution pairs.

Kirby
_______________________________________________
Edu-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/edu-sig

Reply via email to