Giter Site home page Giter Site logo

aquila-interview's Introduction

Developer Interview Exercise

Task

Write a Java program that outputs a count of all the legal phone numbers that can be generated by moving a chess piece around a standard telephone keypad.

A legal phone number has the following requirements:

  • Must be 10 digits long.
  • Must contain only digits (no * or #).

The telephone keypad layout is:

1 2 3
4 5 6
7 8 9
* 0 #

The program must take its input from the command line, accepting:

  • The name of a chess piece (king, queen, bishop, knight, rook, pawn).
  • A starting digit, 0 to 9.

For example, java ChessPhoneNumbers queen 5

The program should not return a list of the actual numbers generated; just the count of them.

A legal move is defined as any move that is normally legal for the piece in chess, with the following additions:

  • Staying in place is a legal move for all pieces.
  • When a pawn reaches the top row, it becomes a queen.

A pawn, starting on one of the bottom two rows (one of the digits 7, 8, 9 or 0), may move either one or two spaces forward the first time it moves .

Prerequisites

Install Java JDK 8

The source code comes with Maven wrapper, therefore a separate Maven installation is not required.

Launching the program

Execute java -jar target/aquila-interview-0.1.0-SNAPSHOT.jar queen 5 to run the program with a Queen starting on the 5 key.

This should return 963635092 as a count of the number of legal phone numbers.

Building

Execute mvnw.cmd clean package (Windows) or ./mvnw clean package (Linux and MacOS) to build, run tests, and create jars.

aquila-interview's People

Contributors

murray-tait 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.