📜 ⬆️ ⬇️

Golf from Moscow.pm for everyone



All with friday! Following the recent meeting of Moscow.pm, I want to invite everyone to compete in solving the problem.

Golf (eng. Golf) - a sports game in which individual participants or teams compete, pounding a small ball into special holes with club strikes, trying to complete the allotted distance in the minimum number of strokes.
Wikipedia
')
The game I want to invite you to play is also called Golf. Its essence is to solve the problem for the minimum number of characters.

Domino Challenge: on Github

Domino is a game in which a chain of knuckles ("bones", "stones") is built, in contact with the halves with the same number of points. Thus, each knuckle is characterized by a pair of numbers, no matter in what order.
Wikipedia

Task. Find the longest ring that can be made from the list of knuckles offered to you or output 0 if they cannot be looped.

Input: A string of pairs of numbers from 0 to 6, separated by a space. Each pair is one knuckle.
Example: 01 11 12 22 31 32
Data is submitted to STDIN: cat data | golf.pl cat data | golf.pl
Sample answer: 11 12 22 23 31

You can check the functionality of the solution with the attached test suite, for now only for perl (send your pull requests):
prove test.pl

The size of the solution can be calculated using the golfcount.pl script:
perl golfcount.pl golf.pl

Please send solutions to dzirtik@gmail.com with the topic “Golf 1410”. The deadline for receiving decisions is October 31, 2014 23.59. The solution can be in any programming language. For the best decisions we have prepared prizes.

Source: https://habr.com/ru/post/239087/


All Articles