YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← 06-28 Increasing Efficiency Solution

Get Embed Code
1 Language

Showing Revision 1 created 06/29/2012 by Amara Bot.

  1. Here's what I did. I introduced two global variables--the previous hand and previous results.

  2. I am making a cache, like a memoization cache, but it's only for one hand,
  3. because we're only dealing with one hand at a time.
  4. Then I say, we then find_prefixes if the hand that you were given is equal
  5. to the previous hand, then return the previous results.
  6. I'm only going to update the previous hand and the previous results
  7. in the case where the prefix is the empty string.
  8. And that's how I know I'm at the top level call when the prefix is the empty string.
  9. For all the recursive calls, the prefix will be something else.
  10. I'm only storing away the results when I'm at the top level call
  11. and I'm updating previous hand and previous results.
  12. With that, efficiency improvement to find prefixes, now when I do timedcalls
  13. of row plays for this fairly complex row, it's only about a thousandth of a second.
  14. If I had a complete board that was similarly complex and say fifteen rows or so in the board,
  15. then it'd still be around one or two hundredths of a second and that's pretty good performance.