GithubHelp home page GithubHelp logo

epkanol / scrabble-kata Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emilybache/scrabble-kata

0.0 2.0 0.0 20 KB

starting code and instructions to help you with the Scrabble kata

License: MIT License

C# 32.31% Java 67.69%

scrabble-kata's Introduction

Scrabble

In the game of scrabble you create words from letter tiles and lay them on a board. You receive points for each word you place, that are added to your score.

Common letters have a lower value than rarer letters. The value shown on each letter tile is as follows:

Letter                             Value
A, E, I, O, U, L, N, R, S, T       1
D, G                               2
B, C, M, P                         3
F, H, V, W, Y                      4
K                                  5
J, X                               8
Q, Z                               10

In this repository there is starting code providing convenient access to this data. There is also a json version.

The first part of this Code Kata is to calculate the base score for any word using any combination of these letters. In Scrabble, the base score is the sum of the value for each letter. For example, if you took the word "Cabbage" the basic score is 14 (3+1+3+3+1+2+1)

Note: The shortest word you can play has two letters. The longest word that will fit on a scrabble board has 15 letters and you don't need to handle words longer than that.

Part 2

Calculate the scrabble score for any word placed on the board, given the co-ordinates of the first letter, and the direction (vertical or horizontal).

The board is a 15x15 grid with rows labelled 1-15 and columns labelled A-O. The co-ordinates of a particular square would for example be (D, 3) or (F, 11).

Most squares are blank and have no effect on the score for a word. There are five kinds of "premium" squares on the board:

- 2×LS - Double letter score: the score for this letter is doubled
- 3×LS - Triple letter score: the score for this letter is tripled
- star - Star: the score for this word is doubled
- 2×WS - Double word score: the score for this word is doubled
- 3×WS - Triple word score: the score for this word is tripled

If a word falls on several premium squares, apply the modifiers in the order above.

In this repository there is starting code providing convenient access to data about the positions of spremium squares on the board, in two data formats. There is also a version in json.

For example if you took the word "Cabbage" the basic score is 14 (3+1+3+3+1+2+1). If you lay it horizontally, with the first letter on square (I, 2), it ends up with these modifiers:

C - blank
A - 3xLS
B - blank
B - blank
A - blank
G - 2xWS
E - blank

The score would be 32, calculated like this: (3+(1*3)+3+3+1+2+1)*2

If you instead laid it vertically with the first letter on (A, 4), it would have these modifiers:

C - 2xLS
A - blank
B - blank
B - blank
A - 3xWS
G - blank
E - blank

The score would be 51, calculated like this: ((3*2)+1+3+3+1+2+1)*3

See also wikipedia for further explanations and a picture of the board with the actual layout.

scrabble-kata's People

Contributors

emilybache avatar

Watchers

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