# Train Tracks

Challenging
English

This mission is an adaptation of the "Tracks" game (from Simon Tatham's Portable Puzzle Collection ). If you are lost or just want to play, the game is available here .

You have to trace train tracks from "start" to "end" in a rectangular grid, respecting constraints:

• Each row and column must contain a given number of tracks.
• Some tracks are fixed and you must use them as they are. Their positions are given with the entry / exit directions (North / South / West / East). You can choose the entry.
• The exit direction of the start, and the entry direction of the end are fixed.
• The track may not cross itself.
You will have to return how you move from start to end with North / South / West / East directions.

• Rows (and columns) count constraints will be represented by a list of integers.
• Start (and end) will be represented by its coordinates, a tuple of two integers.
• Fixed tracks will be represented by a dictionary with coordinates (a tuple of two integers) as keys and a set of entry / exit directions as values.
Note: ``` (len(rows), len(columns)) ``` give the grid dimensions.

Input: Two lists of integers, two tuples of two integers and a dictionary (keys: a tuple of two integers; values: a set of one or two strings).

Output: A string.

Example:

```
Your moves from (3, 0) to (7, 6): "NNNESESEENENESSSESSWWSWWSEEE".
```
```train_tracks([4, 6, 5, 3, 1, 3, 3, 4],  # rows
[4, 2, 2, 3, 4, 5, 6, 3],  # columns
(3, 0),                    # start
(7, 6),                    # end
{(3, 0): {'N'},            # constraints
(4, 7): {'N', 'S'},
(6, 4): {'E', 'W'},
(7, 6): {'W'}},
) == 'NNNESESEENENESSSESSWWSWWSEEE'
```

To play the puzzles / tests yourself: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

Preconditions:

• All puzzles are solvable.
• 8 ≤ len(rows) ≤ 50 and 8 ≤ len(columns) ≤ 50.
• all(0 ≤ row < len(rows) and 0 ≤ col < len(columns) for row, col in constraints)
• all(dirs ≤ {'E', 'N', 'S', 'W'} and 1 ≤ len(dirs) ≤ 2 for dirs in constraints.values())
• {coords for coords, dirs in constraints.items() if len(dirs) == 1} == {start, end}

49
Settings
Code:
Other:
Invalid hot key. Each hot key should be unique and valid
Hot keys:
•  to Run Code: to Check Solution: to Stop:
CheckiO Extensions

CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.

In order to install CheckiO client you'll need installed Python (version at least 3.8)

Install CheckiO Client first:

`pip3 install checkio_client`

Configure your tool

`checkio --domain=py config --key=`

Sync solutions into your local folder

`checkio sync`

(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)

`checkio serv -d`

Alternatevly, you can install Chrome extension or FF addon

`checkio install-plugin`
`checkio install-plugin --ff`
`checkio install-plugin --chromium`

Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.

Pair Programming (Beta-version)

Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!

Waiting for Pair Programming to start...

You are trying to join a pair programming session that has not started yet.

Please wait for the session creator to join.

Waiting for Pair Programming to reconnect...

It looks like the creator of the pair programming session closed the editor window.

It might happen accidentally, so that you can wait for reconnection.