Each turn, you receive information about the tile placed on the board:
A higher resolution is required to access the IDE
- 6
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
The Goal
Your task is to implement a scoring calculator for a game called Entanglement. According to the given rules, your program must determine how many points the player earns and which path they follow.
Rules
The game is played on a hexagonal grid.
The player places one hexagonal tile at a time.
Each tile has 12 entrances numbered
Gameplay:
- The game starts on the base tile at position
[0, 0] , at entrance7 . - Each turn, the player places a new tile on the empty cell directly ahead (first move:
[0, -1] ). - After placing a tile, the player follows the connected path.
- The path continues until it reaches an empty cell, the board edge, or returns to the base tile.
- The game ends once the path reaches the board edge or the base tile.
Scoring:
Each turn consists of placing one tile and following the resulting path. For every segment of the path passed through during this turn, the player scores
Examples:
- If the path passes through
1 segment this turn, the score increases by1 - If the path passes through
2 segments this turn, the score increases by3 (1 +2 ) - If the path passes through
3 segments this turn, the score increases by6 (1 +2 +3 ) - If the path passes through
4 segments this turn, the score increases by10 (1 +2 +3 +4 ) - If the path passes through
5 segments this turn, the score increases by15 (1 +2 +3 +4 +5 ) - and so on...
Coordinate System:
The board has a fixed size, with all cells located at most
y increases towards the south
x increases towards the north-east
Additional Info
- This puzzle is inspired by the logic game Entanglement.
- Source code available on GitHub.
- Design available on Figma.
Game Input / Output
Line 1: The current total score.
Line 2: A list of semicolon-separated (
x y entranceA entranceB, representing a visited tile at position [x, y] and the two entrances connected on that tile.
Turn output example:
0 -1 3 7 – first segment: the player starts this turn at[0, -1] and connects entrances3 and7 .0 -2 0 5 – second segment: the player continues at[0, -2] and connects entrances0 and5 .1 -2 10 8 – third segment: the player ends this turn at[1, -2] and connects entrances10 and8 .
Note 1: The referee will trim spaces around
Note 2: Path segment entrances are unordered: (
Response time for subsequent turns: ≤
A higher resolution is required to access the IDE