Python Challenge: Bagels

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 5933 Views - Last Post: 13 January 2013 - 12:26 PM Rate Topic: -----

#16 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10567
  • View blog
  • Posts: 39,121
  • Joined: 27-December 08

Re: Python Challenge: Bagels

Posted 11 January 2013 - 12:30 AM

I've been contemplating this problem some more and came up with a good AI. I revised my BagelChallenge class because it wasn't accounting for leading 0's correctly, which was causing some problems in the AI. I included some commentary along with the code in the spoiler.

Spoiler

Was This Post Helpful? 3
  • +
  • -

#17 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7749
  • View blog
  • Posts: 13,106
  • Joined: 19-March 11

Re: Python Challenge: Bagels

Posted 12 January 2013 - 05:05 PM

Here's my entry, with a naive but effective solver.
I'd like to try to improve the solver, since I know it's not very good, but this will do for now:


Spoiler

Was This Post Helpful? 1
  • +
  • -

#18 Nallo  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 163
  • View blog
  • Posts: 255
  • Joined: 19-July 09

Re: Python Challenge: Bagels

Posted 13 January 2013 - 09:11 AM

So here is mine. Same approach as macosxnerd but in Python:

Spoiler


Takes an average of 12.2 guesses. Worst case is 16. I think there is room for improvement though.

This post has been edited by Nallo: 13 January 2013 - 09:14 AM

Was This Post Helpful? 1
  • +
  • -

#19 Nallo  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 163
  • View blog
  • Posts: 255
  • Joined: 19-July 09

Re: Python Challenge: Bagels

Posted 13 January 2013 - 12:26 PM

next try. Down to 12 guesses worst case and 11 on average. Albeit with heavy brute force calculation >.</>

Spoiler


Edit: On second thought I could get rid of the computation. Do it just once and afterwards use a lookup table. After all my first 10 guesses are always the same and there can only be 3 answers (not counting won). So a lookup table would only have 3^10 entries ... pretty small.

This post has been edited by Nallo: 14 January 2013 - 10:42 AM

Was This Post Helpful? 2
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2