Skip to content

Instantly share code, notes, and snippets.

@tuomasj
Last active October 13, 2020 10:31
Show Gist options
  • Save tuomasj/8061c6940d74d3ab55bbea582e6c8f24 to your computer and use it in GitHub Desktop.
Save tuomasj/8061c6940d74d3ab55bbea582e6c8f24 to your computer and use it in GitHub Desktop.

Talented Code Challenge

  • Path following algorithm in ASCII Map
  • Find the position of character '@'
  • Follow the path, stop when character 'x' is reached

Code Challenge

Write a piece of code that takes ASCII map as an input and outputs the letters and the path that algorithm travelled.

  • Input:
    • ASCII map
  • Output:
    • Collected letters
    • Path as characters

Map 1

  @---A---+
          |
  x-B-+   C
      |   |
      +---+

Expected result:

  • Letters ACB
  • Path as characters @---A---+|C|+---+|+-B-x

Map 2

  @
  | C----+
  A |    |
  +---B--+
    |      x
    |      |
    +---D--+

Expected result:

  • Letters ABCD
  • Path as characters @|A+---B--+|+----C|-||+---D--+|x

Map 3

  @---+
      B
K-----|--A
|     |  |
|  +--E  |
|  |     |
+--E--Ex C
   |     |
   +--F--+

Expected result:

  • Letters BEEFCAKE
  • Path as characters @---+B||E--+|E|+--F--+|C|||A--|-----K|||+--E--Ex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment