### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,115)
- misc (2)
- project euler (2)
- puzzle (29)
- site news (43)
- tantalizer (29)
- teaser (3)

### Site Stats

- 166,357 hits

Programming Enigma Puzzles

12 July 2017

Posted by on **From New Scientist #1121, 21st September 1978** [link]

The new method of rewarding goals scored in football matches goes from strength to strength. In this method 10 points are given for a win, 5 points for a draw and 1 point for each goal scored. Once can get some idea of the success of the method from the fact that in the latest competition between 5 teams, when some of the matches had been played, each team had scored at least 1 goal in every match. They are eventually going to play each other once.

The points were as follows:

A 11

B 8

C 12

D 5

E 43Not more than 9 goals were scored in any match.

What was the score in each match?

[puzzle70]

Advertisements

%d bloggers like this:

See also:

Puzzle 78andEnigma 239.Here I’ve used a simple MiniZinc model to solve this problem. The

mzn-g12fdsolver executes it in 110ms.Solution:The scores in the played matches are: AvB = 2-2; AvE = 4-5; BvE = 1-3; CvD = 2-1; DvE = 4-5. The remaining matches are not yet played.Here’s another MiniZinc model, using a matrix for the scores (which seemed more natural for me).

@hakank: Thanks for your post. Sorry you had problems (at one time I hoped that WordPress.com would allow the ability to edit (or even preview) comments, but it never happened).

I took the code from the link you posted and incorporated it into the original comment, using:

[code language="text"]...[/code]tags to preserve the code. (See [ https://en.support.wordpress.com/code/posting-source-code/ ] for a list of supported languages). I deleted the followup comments where you were trying to sort it out. Hope that’s OK.

@jim Thanks for this. And sorry for messing things up. I’ll try to remember that it should be “code” and not “pre” that I should use. And I’ll test it right away with a new comment on the Picat code. 🙂

And here’s the same approach in Picat: http://hakank.org/picat/football_five_teams_new_method.pi

Solved in about 15millis.

Here’s the Picat code mentioned above:

@hakank: Thanks for the pointer to Picat. It looks interesting. I’ve downloaded it and I’ll have a closer look at it later.

@jim: Yes, Picat is an interesting language. I’m kind of involved with Picat and co-authored the book “Constraint Solving and Planning with Picat” together with Neng-Fa Zhou (creator of Picat) and Jonathan Frumann in 2015. The book is now free to download: PDF via http://picat-lang.org/picatbook2015.html (I was the main author of the two Constraint Programming chapters). Here’s my Picat page with some programs in different areas of interest: http://hakank.org/picat/ .

MiniZinc has better support for some type of constraints (e.g. element: z = x[y] where x, y, and z are all decision variables) and also has support for many different FlatZinc solvers, among them Picat. Picat, on the other hand, is a complete programming language where one can write traditional “imperative” loops (which MiniZinc don’t allow). So MiniZinc and Picat are both favourite languages, and nowadays I tend to implement models in both languages.