Enigmatic Code

Programming Enigma Puzzles

Enigma 251: Could deece be love?

From New Scientist #1398, 23rd February 1984 [link]

“… She loves me … she loves me not … she loves me …”

The voice, Alice decided, was coming from behind the privet hedge. Peering over she saw a squat figure rolling a cube. He stopped and appeared to concentrate deeply as he counted on his fingers. “She loves me not!” he declared suddenly, and he picked up the cube to throw again. Alice coughed politely and the figure looked up. It was the red knight.

“Bless me!” he exclaimed.

“Oh, I do hope I didn’t disturb you, it’s just I did wonder …”

“What I was doing? Well I’m playing a game with this deece, of course!”

“Deece?” enquired Alice.

“Gracious, surely you know what a deece is. Like dice only it has two ‘sixes’ and no ‘one’.”

“But that’s cheating.”

“Not at all, it makes things much more exciting. Now where was I? Oh yes, I keep rolling the deece until the product of all the throws contains the number of the last throw. So if my score was 120 and I threw a three then the matter would be resolved.”

“The matter?”

“Courtship, my girl. Whether she loves me or not.”

Alice felt it wrong to ask who “she” was.

“What is your score now?” she asked, changing the subject.

“Why, one thousand five hundred and … confound it, you’ve made me forget the rest. Let’s see, this last throw was … yes … and the one before it was a three …”

Alice sensing some arithmetic in the air, decided that it was time to leave.

What, meanwhile, were the throws that the knight had made so far, in the correct order?


10 responses to “Enigma 251: Could deece be love?

  1. Jim Randell 17 January 2015 at 8:25 am

    This puzzle doesn’t seem to have a unique solution, in fact I think it is worded quite confusingly.

    My initial thoughts were that the game is played until the total product (expressed in decimal) (strictly) includes the digit that is showing on the deece. And when this happens the matter of whether or not she loves him is resolved (presumably as “she loves me”). But why then does the puzzle open with the text “… she loves me … she loves me not … she loves me …”? As if we got to “she loves me” the game would be over. So, I decided to ignore the opening text and look for possible sequences that are not completed games, where the total product is 15xx.

    That’s what this Python 3 program does. It runs in 65ms.

    from enigma import printf
    # find partial games where the product is < 1600
    # return (<sequence>, <product>, <complete>)
    def solve(s, p):
      # throw the deece
      for d in (2, 3, 4, 5, 6):
        pd = p * d
        sd = s + [d]
        if pd < 1600:
          # are we done?
          spd = str(pd)
          r = (len(spd) > 1 and str(d) in spd)
          yield (sd, pd, r)
          if not r:
            # continue playing
            yield from solve(sd, pd)
    for (s, p, r) in solve([], 1):
      if not(r) and 1499 < p < 1600 and len(s) > 2 and s[-2] == 3:
        printf("s={s} p={p} r={r}")

    Solution: There are three possible sequences:

    2, 2, 2, 4, 2, 4, 3, 2 (8 throws),
    2, 4, 4, 2, 4, 3, 2 (7 throws),
    4, 2, 4, 2, 4, 3, 2 (7 throws).

    In each case the final product is 1536, and the sequence of products ends … 8 -> (4) -> 32 -> (2) -> 64 -> (4) -> 256 -> (3) -> 768 -> (2) -> 1536.

    But the sequences differ in how the product 8 is achieved.

    The published solution is the one consisting of 8 throws, but I see no reason to exclude the other two sequences, so I’m marking this puzzle as flawed.

  2. Hugh Casement 17 January 2015 at 10:19 am

    Multiply flawed, I would say. First there’s the “she loves me, she loves me not” which lays a false trail. I too was puzzled by the fact that 1536 does not contain 2. I feel that puzzles, like Alice, should say what they mean. Eastaway has caused us trouble before, hasn’t he?
    Furthermore, it seems a little improbable that a die with 6 on two faces would be rolled seven or eight times and never show a 6. It would have been rather more plausible to tell us that it had two 2s — or, if that’s giving away too much, “no 1 and two of something else instead”.
    And I always thought it was the white knight who was eccentric!

  3. Jim Olson 17 January 2015 at 9:40 pm

    I was troubled by this enigma for the same reasons – there are three different sequences that satisfy the text. This maybe a stretch but the sequence beginning with three straight two’s is the unique solution because it has only one sequence as opposed to a 2,4 or 4,2 beginning which obviously have two possible starts.

  4. Brian Gladman 17 January 2015 at 10:09 pm

    As is usual in ‘loves me, loves me not’ games, I assumed that, while the game continues, all odd rounds are ‘loves me’ and all even rounds are ‘loves me’ not (hence the first sentence). And since the last round played when Alice intervened was ‘loves me not’, I concluded that this was an even round.

    # generate sequences (seq) with products (prod) below 1600
    def throw(prod, seq):
      if prod < 1600:
        # yield sequences with products above 1500
        if prod >= 1500:
          yield prod, seq
        # thow again if the product does not contain the last digit thrown
        if prod < 10 or str(seq[-1]) not in str(prod):
          for d in (2, 3, 4, 5, 6):
            yield from throw(prod * d, seq + [d])
    for prod, seq in throw(1, []):
      if seq[-2] == 3 and not len(seq) % 2:
        print(prod, seq)
    • Jim Randell 17 January 2015 at 10:33 pm

      Yes. That makes some sort of sense. We play the game until the product (strictly) includes the number shown on the deece, and (assuming we start with “she loves me” on the first throw) the parity of the number of throws give us the outcome (“she loves me” or “she loves me not”).

      So we’re looking for a partial sequence that is a non-terminal game (“he picks up the dice to throw again”), the current product is 15xx, the throw before last was a 3, and there have been an even number of throws (“she loves me not!”).

      And indeed if we add an additional constraint on the generated sequences of [[ len(s) % 2 == 0 ]], there is only a single solution, and it is the published solution.

      It also explains why the number 1 had to be dropped from the deece.

      So I expect that is what the setter had in mind, but I think I’ll leave the puzzle marked as flawed as it should really explain itself sufficiently to arrive at the solution without the need to make such assumptions.

      • Brian Gladman 17 January 2015 at 11:21 pm

        I agree that the phrase ‘the product of all the throws contains the number of the last throw’ could have been more carefully worded, But I don’t think there was much wrong with expecting the reader to have an implicit knowledge of how ‘love me, love me not’ games are played (maybe I am showing my age, but I well remember these being played in the 1950’s).

        And once such games are understood, the fact that the interrupted round is even and non-terminal is clear enough from the in text. Which leads me to think that ‘flawed’ is a bit on the harsh side.

        For completeness here is my modified version that includes the non-terminal test:

        # generate sequences (seq) with products (prod) below 1600
        def throw(prod, seq):
          # continue while the product is less than 1600 and does not contain
          # the last digit thrown
          if prod < 1600 and (prod < 10 or str(seq[-1]) not in str(prod)):
            # yield only even length sequences that are non-terminal, have
            # products above 1500 and a penultimate die throw of 3
            if prod >= 1500 and not len(seq) % 2 and seq[-2] == 3:
              yield prod, seq
            # add another die throw to the sequence
            for d in (2, 3, 4, 5, 6):
              yield from throw(prod * d, seq + [d])
        for prod, seq in throw(1, []):
          print(prod, seq)
        • Jim Randell 18 January 2015 at 12:00 am

          I’m familiar with the game, but played by picking the petals off flowers, not using dice (or deece), so it didn’t jump out at me that it was the same kind of game at all. But there was plenty of opportunity to clarify what the rules of the game being used in the puzzle are. We’re left to work out for ourselves what the “product contains the number of the last throw” means, and come up with a reason why the game doesn’t always end after the first throw, and also to infer that the outcome is determined by the parity of the throws. And all this takes place in an Alice in Wonderland world where things are often oddly different from the real world.

          I think, it would be a reasonable interpretation to say the game doesn’t really start until the second throw (so we have non-trivial products), but then if we start with “she loves me” we are looking for a solution with an odd number of throws, of which there are two.

          For the most part Enigma puzzles are fairly precise about what they are asking, even though they often embroider the core of the problem with extraneous narrative. This one is flawed in the sense that, although it has plenty of extraneous narrative it doesn’t specify the problem sufficiently.

          Maybe he should have just asked for the value of the final product, and then we wouldn’t need to know the unexplained rules of the game.

  5. Brian Gladman 17 January 2015 at 10:18 pm

    Technically I think Jim is right to check for a round that is not terminal (as well as being an even one).

  6. Tessa Fullwood 20 January 2015 at 5:27 pm

    slightly put off that the red knight begins reciting after he throws the dice the second time. Otherwise not flawed in my view. If he reflects the ‘ee’ s in deece to get d66ce, then he has a dice with 2 sixes and no 1 – very Alice in Wonderland.

    • Jim Randell 20 January 2015 at 6:18 pm

      I was misled by the text into thinking that the “she loves me not” declaration was dependent on the outcome of the calculation (as that’s when the knight says it). But in fact it seems that it depends only on the number of throws (and alternates). This makes me think that the “she loves me not” declaration as he picks up the deece to throw again should be attached to the throw he is about to make (but never actually makes during the text), not the throw he has just made. Which, if we start with “she loves me” for the first throw would mean the knight has made an odd number of throws and there are two sequences which would fit the bill.

      If we want an even number of throws (to give the published solution), we would either start with “she loves me not” for the first throw (which would be unusual), or don’t count the first throw (which would mean we didn’t have to deal with non-trivial products, but is not mentioned).

      I think the puzzle text really should unambiguously explain the rules of the game and not leave it to be guessed by the solver (and they’re not clear, even if we know the published answer).

      I guess you could argue that as there are three possible sequences which could be the solution and one of them has a different number of throws to the other two, then this must be the answer so that there is a unique solution, but we would normally expect there to be text saying something along the lines of “if I told you how many throws the knight had made you would be able to work out the sequence of throws”.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: