Skip to content

Instantly share code, notes, and snippets.

@donalmurtagh
Last active June 9, 2020 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donalmurtagh/2b07f51225b9e43563b48cb8b915a627 to your computer and use it in GitHub Desktop.
Save donalmurtagh/2b07f51225b9e43563b48cb8b915a627 to your computer and use it in GitHub Desktop.
Simple Blackjack

Introduction

Simple Blackjack is a variant of blackjack. It is a game played by a single player against a dealer. The objective of the game is to draw cards whose total is as close as possible to 21, without exceeding it (AKA "busting").

Rules

The value of a hand of Simple Blackjack is the sum of the card values where

  • The value of an Ace is 11
  • Jacks, Queens, and Kings are worth 10
  • All other cards (2-10) have their face value

A hand of Simple Blackjack is played as follows

  1. A standard 52-card deck is shuffled before each hand
  2. The player is initially dealt two cards
  3. The player must then decide whether to receive a further card ("hit") or stick with his current hand ("stand")
  4. The player can repeatedly hit until they either exceed 21 ("bust") or decide to stand

If the player busts before deciding to stand, they lose the hand, otherwise the dealer's cards are dealt according to the following rules

  1. If the total of the dealer's cards is below 17, they must hit
  2. If the total of the dealer's cards is 17 or above, they must stand

Winner

If either the player or the dealer bust during the course of the hand, they lose. Otherwise, the person whose hand value is closest to 21 is the winner. If both hands have the same value, the result is a draw.

Assignment

Implement a game of Simple Blackjack. Each game proceeds as follows

  • The deck is shuffled
  • The cards are dealt according to the rules above
  • At the end of the hand, the outcome is displayed, i.e. player wins/dealer wins/draw
  • The game ends and the player is asked whether they wish to play again

Guidelines

The game should be implemented as a browser-based application, ideally using Vue.js. The user interface should be functional, but does not need to doesn't need to be visually impressive, e.g. it's perfectly acceptable to use "10 D" to represent the ten of diamonds.

You are free to use any libraries, frameworks, generators, components, etc.

Tests

In addition to the game itself, your solution should include a suite of tests. You may use any testing framework or none at all. A production standard of test coverage is not expected, but at a minimum you should test the most common scenarios, e.g.

  • player busts
  • dealer busts
  • player wins
  • dealer wins
  • draw

Documentation

You must include clear instructions for how to run the tests and how to build/run the application e.g.

execute npm install followed by npm run serve in the project root then open http://localhost:8888 in a web browser

You should clearly document any dependencies required to build/run the project, e.g.

Node 12 or later is installed and npm is on the PATH

Submission

  • Push your solution to a private GitHub repo in your account
  • When your solution is complete, add your ClarusONE contact as a collaborator to this repo, so we can access it

Evaluation

While we would ideally like to receive a complete solution, we're more interested in the quality of the solution than completeness. In other words, a high quality solution which omits a few edge cases and has good test coverage will receive more credit than a complete, but low-quality solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment