Enigmatic Code

Programming Enigma Puzzles

Enigma 1048: Rows and columns

From New Scientist #2204, 18th September 1999 [link]

A square field has its sides running north-south and east-west. The field is divided into an 8 × 8 array of plots. Some of the plots contain cauliflower. A line of plots running west to east is called a row and line of plots running north to south is called a column.

John selects a row and walks along it from west to east, writing down the content of each plot as he passes it; he writes E to denote an empty plot and C to denote a plot containing cauliflower; he writes down EECECCEC. He repeats this for the other seven rows and writes down ECEECCCE, ECECEECC, ECCECCEE, CEECEECC, CECECECE, CECCECEE and CCECEEEC. The order in which John visits the rows is not necessarily the order in which they occur in the field.

Similarly, Mark selects a column and walks along it from north to south, writing down the content of each plot as he passes it; he writes down EECECCCE. He repeats this for the other seven columns and writes down EECCEECC, ECECECEC, ECCECEEC, CEECCECE, CECECECE, CCEEECEC and CCECECEE. The order in which Mark visits the columns is not necessarily the order in which the occur in the field.

Draw a map of the field, showing which plots contain a cauliflower.

Enigma 1248 was also called “Rows and columns”.

News

There are now 1200 Enigma puzzles on the site (although there is the odd repeated puzzle, and at least one puzzle published was impossible and a revised version was published as a later Enigma, but the easiest way to count the puzzles is by the number of posts in the “enigma” category).

There is a full archive of Enigma puzzles from Enigma 1 (February 1979) to Enigma 461 (May 1988), and of the more recent puzzles from Enigma 1048 (September 1999) up to the final Enigma puzzle, Enigma 1780 (December 2013). Which means there are around 591 Enigma puzzles to go.

Also on the site there are currently 53 puzzles from the Tantalizer series, and 50 from the Puzzle series, that were published in New Scientist before the Enigma series started.

Happy Puzzling!

[enigma1048]

5 responses to “Enigma 1048: Rows and columns

  1. Jim Randell 20 August 2018 at 9:30 am

    It’s easy enough to check all arrangements of rows to see if they match the given columns.

    I used [[ itertools.Counter() ]] objects in to allow for repeated rows / columns (although in this case there are no duplicates).

    This Python program runs in 710ms.

    Run: [ @repl.it ]

    from collections import Counter
    from itertools import permutations
    from enigma import join, printf
    
    # rows and columns
    rows = 'EECECCEC ECEECCCE ECECEECC ECCECCEE CEECEECC CECECECE CECCECEE CCECEEEC'
    cols = 'EECECCCE EECCEECC ECECECEC ECCECEEC CEECCECE CECECECE CCEEECEC CCECECEE'
    
    # turn them into Counter objects
    rows = Counter(rows.split())
    cols = Counter(cols.split())
    
    # permute the rows and see if the columns match
    for rs in permutations(rows.elements()):
      if cols == Counter(map(join, zip(*rs))):
        # output solution
        for r in rs:
          printf("{r}", r=r.replace("E", "."))
        printf()
    

    Solution: The following diagram shows the locations of the plots containing cauliflowers:

    So (numbering the rows and columns from 1 to 8) the order the lists are given are:

    John: Row 6, Row 8, Row 3, Row 2, Row 7, Row 4, Row 1, Row 5.
    Mark: Col 8, Col 7, Col 5, Col 2, Col 1, Col 4, Col 6, Col 3.

    • Julian Gray 21 August 2018 at 9:31 am

      Jim, reckon the row and column numbers should be
      John: rows in order top to bottom 7, 4, 3, 6, 8, 1, 5 and 2
      Mark: columns in order left to right 5, 4, 8, 6, 3, 7, 2 and 1

      • Jim Randell 21 August 2018 at 10:00 am

        @Julian: I think maybe we are using different terminology to refer to the same diagram.

        I mean that John’s list (in the order he wrote it) consists of: Row 6, Row 8, Row 3, Row 2, Row 7, Row 4, Row 1, Row 5.

        I think you are saying if we consider the rows as they are laid out (going from North to South) we get: Row 1 = the 7th entry on John’s list, Row 2 = the 4th entry on John’s list, Row 3 = the 3rd entry on John’s list, Row 4 = the 6th entry on John’s list, Row 5 = the 8th entry on John’s list, Row 6 = the 1st entry on John’s list, Row 7 = the 5th entry on John’s list, Row 8 = the 2nd entry on John’s list.

        The solution is the same in both cases.

  2. Jim Olson 21 August 2018 at 5:56 pm

    Jim thanks for all the work you do on this site.

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: