Giter Club home page Giter Club logo

robot-go's Introduction

Robot Coding Test

Problem Description

  • The application is a simulation of a toy robot moving on a 5 x 5 unit tabletop
  • There are no obstructions on the table surface
  • The robot is free to roam the surface of the table but must be prevented from falling to destruction
  • Each position of the table is referred to by an X,Y coordinate
  • The robot can face NORTH, SOUTH, EAST, or WEST
  • The origin of the table is the south west most corner
  • All erroneous commands are ignored
  • All commands received before a valid PLACE command are ignored

Commands

The commands that the robot accepts are as follows:

Command Description
PLACE X,Y,F Places the robot at X,Y position facing in the F direction
MOVE Moves the robot one unit in the direction it is currently facing
LEFT Rotates the robot 90 degress to the left
RIGHT Rotates the robot 90 degress to the right
REPORT Prints the current position of the robot to stdout in the format "X,Y,F"

Solution Description

My solution to the above problem has been written in Go. This is my first real Go application so I'm sure that in many ways my solution is not really idiomatic.

Running the Application

The easiest way to run the application is with go run as follows:

# Entering a command at a time (use Ctrl-D to quit)
$ go run main.go
PLACE 0,0,NORTH
MOVE
REPORT
0,1,NORTH

# Redirecting standard input
$ go run main.go < test_resources/input.txt                                                    โŽ
0,0,NORTH
0,1,NORTH
...

# Using a heredoc
$ go run main.go <<EOF
heredoc> PLACE 0,0,NORTH
heredoc> MOVE
heredoc> REPORT
heredoc> EOF
0,1,NORTH

Running the Tests

The solution has both unit and acceptance tests. The following commands can be used to run the tests:

# Run all the tests
$ go test ./...

robot-go's People

Stargazers

James Hanks avatar

Watchers

James Cloos avatar James Hanks avatar  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.