Code Monkey home page Code Monkey logo

software-sauna-code-challenge's Introduction

Software Sauna Code Challenge

Follow a path of characters & collect letters:

  • Start at the character @
  • Follow the path
  • Collect letters
  • Stop when you reach the character x

Assignment

Write a piece of code that takes a map of characters as an input and outputs the collected letters and the list of characters of the travelled path.

Input:

  • a map (2-dimensional array) of characters in a data format of your choice (can even be hard-coded as a global constant)

Output:

  • Collected letters
  • Path as characters

What we are looking for in the solution

  • readable code
    • small methods/functions/classes
    • good naming
    • minimise code duplication
    • separation of logic and scaffolding (e.g. walking around is separated from loading the map)
  • automated tests
    • high-level tests (i.e. acceptance tests) which test that the program gives correct output for a given input, according to examples specified below
    • unit tests which test small bits of logic separated from the rest of the program, e.g. advancing the current location based on the current direction

About testing

At Software Sauna automated tests are a first-class citizen. This is why we encourage you to try writing some tests, even if you're not accustomed to doing so. An easy win is to start with the example maps provided.

Specifications

Valid maps

A basic example

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

Expected result:

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

Go straight through intersections

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

Expected result:

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

Letters may be found on turns

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

Expected result:

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

Do not collect a letter from the same location twice

     +-O-N-+
     |     |
     |   +-I-+
 @-G-O-+ | | |
     | | +-+ E
     +-+     S
             |
             x

Expected result:

  • Letters GOONIES
  • Path as characters @-G-O-+|+-+|O||+-O-N-+|I|+-+|+-I-+|ES|x

Keep direction, even in a compact space

 +-L-+
 |  +A-+
@B+ ++ H
 ++    x

Expected result:

  • Letters BLAH
  • Path as characters @B+++B|+-L-+A+++A-+Hx

Ignore stuff after end of path

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

Expected result:

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

Invalid maps

Missing start character

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

Expected result: Error

Missing end character

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

Expected result: Error

Multiple starts

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

  x-B-+
      |
      @

Expected result: Error

Fork in path

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

Expected result: Error

Broken path

   @--A-+
        |
         
        B-x

Expected result: Error

Multiple starting paths

  x-B-@-A-x

Expected result: Error

Fake turn

  @-A-+-B-x

Expected result: Error

Notes

  • the only valid characters are all uppercase letters (A-Z) and other characters appearing in the example maps; anything else found must result in an error
  • turns can be letters or +
  • input examples are jagged matrices - rows (lines) don't contain the same number of elements (characters): this is a valid form of input so keep that in mind

software-sauna-code-challenge's People

Contributors

danchyy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.