In other words, the computer would become more intelligent as more replies were added. Of course, this assumes that the user was faithful in entering replies and had a sufficiently good set of distinguising questions to separate out one type of animal from another.C> Is your animal smaller than a breadbox? U> n C> Is your animal a cat? U> n C> What is your animal? U> sparrow C> Please enter a question that would be true for a bird, but false fo +r a cat: U> Does your animal have wings? # Next iter # C> Is your animal smaller than a breadbox? U> n C> Does your animal have wings? U> Y C> Is your animal a sparrow? U> n C> What is your animal? U> chicken C> Please enter a question that would be true for a chicken, but false + for a sparrow: U> Can your animal fly? # ETC... #
Now, for the golf: Write an engine that does the above in as few characters as possible. Of course, to help, you've got 4 'free' functions that you can use:
Everything else inside the code block that does this will count as strokes to the golf score. You can use any data structure that you like. No extra modules, however, but the program need not be strict or -w compliant.
Update As tilly's solution indicates, I missed one 'free' function, the g() function which does the final guess (as described in the problem statement). Also, indirectly replying to tilly, assume the free functions return 0 or 1 for false or thuth, respectively. (I'm figuring the 0 value is more useful for further golfing). Also, don't worry about 'a' vs 'an'. Assume that you can decide which is appropriate in the free functions, and doesn't need to be handled by your golf sub.
-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com
||
"You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important
|
---|
Replies are listed 'Best First'. | |
---|---|
Re (tilly) 1: (Golf) The Animal Game
by tilly (Archbishop) on Jan 23, 2002 at 02:21 UTC | |
by jarich (Curate) on Jan 23, 2002 at 05:36 UTC | |
Re: (Golf) The Animal Game
by dragonchild (Archbishop) on Jan 23, 2002 at 02:18 UTC | |
by jarich (Curate) on Jan 23, 2002 at 06:35 UTC | |
by dragonchild (Archbishop) on Jan 23, 2002 at 21:57 UTC | |
by dragonchild (Archbishop) on Jan 23, 2002 at 22:03 UTC | |
Re: (Golf) The Animal Game
by redsquirrel (Hermit) on Jan 23, 2002 at 21:42 UTC | |
Re: (Golf) The Animal Game
by particle (Vicar) on Jan 24, 2002 at 03:29 UTC | |
Re: (Golf) The Animal Game
by Anonymous Monk on Jan 23, 2002 at 22:56 UTC | |
Re: (Golf) The Animal Game
by trs80 (Priest) on Jan 28, 2002 at 03:42 UTC |