Skip to content

Sunday Times Teaser 3097 – Crazy Golf

by Brian Gladman on January 28, 2022

by Angela Newing

Published Sunday January 30 2022 (link)

Ian was trying to entertain John and Ken, his 2 young nephews, in the local park, which had a 9-hole crazy golf course. He decided to play a round with each of them separately, and gave them money for each hole he lost on a rising scale. He would pay £1 if he lost the first hole (or the first hole after winning one), then £2 if he lost the next consecutive hole, and £3 for the third, and so on.

In the event, Ian won only 5 holes in total between the two rounds, including the first hole against John and the last hole against Ken. There were no ties. At the reckoning after both rounds, both boys received equal amounts of money.

How much did it cost Uncle Ian?

From → Uncategorized

6 Comments Leave one →
  1. Brian Gladman permalink

    This version is slower but outputs the results of the rounds of crazy golf involved.

  2. John Z permalink

    This should be quite fast

    • Brian Gladman permalink

      Nice to see you back John. You are right that it is fast – too fast to measure with Python’s profile tool.

      You could simplify it a little by using a set for ‘iloss’ since you don’t make any use of indexing other than for storage.

  3. John Z permalink

    Taking into account your comment about using a set instead of a list and using combinations instead of nested for loops to avoid using exit.

    • Brian Gladman permalink

      Hi John, Your version can certainly be used to produce a very short and fast solution!

  4. John Z permalink

    Indeed! You beat me to it. This is what I was about to post:

Leave a Reply

Note: HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS