Coder Social home page Coder Social logo

ttt's Introduction

Build Status Maintainability

Tic-tac-toe

Play Tic-tac-toe from the terminal, against the computer.

Usage

In order to run the program, from a command line with Ruby and RubyGems available:

> ./bin/ttt

or to install and run it:

> gem build ttt_dclovell.gemspec
> gem install ttt_dclovell-#.#.#.gem
> ttt

Original task description

Your task is to write a program to play tic-tac-toe in the terminal. When the program is invoked, it must let the user pick whether to play as X or O, and then run through the game letting the user play against the computer. When it is the user's turn, you must display the current state of the board and give the user a choice of which square to play next. The game must stop when one player wins or when the board is full.

A typical session might look like this:

$ ./bin/ttt

Which player do you want to be? X or O?
O

          A   B   C

        +---+---+---+
    1   | X |   |   |
        +---+---+---+
    2   |   |   |   |
        +---+---+---+
    3   |   |   |   |
        +---+---+---+

Where do you want to move?
B2

          A   B   C

        +---+---+---+
    1   | X |   |   |
        +---+---+---+
    2   |   | O |   |
        +---+---+---+
    3   |   | X |   |
        +---+---+---+

Where do you want to move?
A3

          A   B   C

        +---+---+---+
    1   | X | X |   |
        +---+---+---+
    2   |   | O |   |
        +---+---+---+
    3   | O | X |   |
        +---+---+---+

Where do you want to move?
C1

          A   B   C

        +---+---+---+
    1   | X | X | O |
        +---+---+---+
    2   |   | O |   |
        +---+---+---+
    3   | O | X |   |
        +---+---+---+

O has won!

You are free to write the program however you like, and use any language, libraries and tools you think might be useful.

You should aim to write code that you would be happy to put into production and have other people maintain; we would rather see you write maintainable code than a messy but complete program.

If you are subsequently invited in for interview then we may discuss your solution with you. With this in mind you may wish to take brief notes as you work to aid your memory at a later date.

Good luck :)

ttt's People

Contributors

wbreeze avatar

Watchers

 avatar  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.