Code Monkey home page Code Monkey logo

darts's Introduction

Darts

This is a small collection of Ruby classes for computing best dart finishes (in the sense of minimum number of throws). Calculations are done based on standard rules of darts (501, double out).

Examples of Usage

You can load the present code within this project folder via

require_relative 'lib/darts'

If you want to know how many throws are necessary for scoring 349 and how many different best score orders exist, use the following code

best_orders = Darts::ComputeBestScoreOrders.new(349).call

# minimal number of throws necessary to score 349
best_orders.number_of_throws # => 7

# number of different best score orders for 349
best_orders.count # => 1240

Or compute throws of a random score order for a nine dart finish

best_orders = Darts::ComputeBestScoreOrders.new(501).call

# a random nine dart finish
best_orders.throws.sample # => "T20 T20 T20 T20 T20 T20 T19 BULL D17"

Check also tests for more examples.

The following table gives an overview over all scores which can be thrown with no more than three throws (all three dart finishes). The second column specifies the number of different minimal throws and subsequent columns show examples of throws.

3-dart-finishes

darts's People

Contributors

spren9er avatar

Watchers

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