5 kyu

Let's Play Darts!

203 of 943FrankK

Description:

Create your own mechanical dartboard that gives back your score based on the coordinates of your dart.

Task:

  • Use the scoring rules for a standard dartboard:
  • Finish method:
  • public string GetScore(double x, double y);
    
    public String getScore(double x, double y);
    
    function getDartboardScore(x, y);
    
    def get_score(x,y):
    
    func getScore(dart: (x: Double, y: Double)) -> String
    
    getDartScore :: Double -> Double -> DartScore
    
  • The coordinates are `(x, y)` are always relative to the center of the board (0, 0). The unit is millimeters. If you throw your dart 5 centimeters to the left and 3 centimeters below, it is written as:
  • var score = dartboard.GetScore(-50, -30);
    
    String score = dartboard.getScore(-50, -30);
    
    var score = getDartboardScore(-50, -30);
    
    score = get_score(-50, -30)
    
    var score = Dartboard.getScore(dart: (x: -50, y: -30))
    
    getDartScore (-50) (-30)
    
  • Possible scores are:
    • Outside of the board: `"X"`
    • Bull's eye: `"DB"`
    • Bull: `"SB"`
    • A single number, example: `"10"`
    • A triple number: `"T10"`
    • A double number: `"D10"`
  • A throw that ends exactly on the border of two sections results in a bounce out. You can ignore this because all the given coordinates of the tests are within the sections.
  • The diameters of the circles on the dartboard are:
    • Bull's eye: `12.70 mm`
    • Bull: `31.8 mm`
    • Triple ring inner circle: `198 mm`
    • Triple ring outer circle: `214 mm`
    • Double ring inner circle: `324 mm`
    • Double ring outer circle: `340 mm`

If you liked this kata, you can continue with: Let's Play Darts: Beat The Power!

Games
Algorithms

More By Author:

Check out these other kata created by FrankK

Stats:

CreatedJan 7, 2017
PublishedJan 7, 2017
Warriors Trained3891
Total Skips657
Total Code Submissions9395
Total Times Completed943
C# Completions162
Java Completions230
JavaScript Completions203
Python Completions283
Swift Completions65
Haskell Completions30
Total Stars174
% of votes with a positive feedback rating93% of 206
Total "Very Satisfied" Votes180
Total "Somewhat Satisfied" Votes24
Total "Not Satisfied" Votes2
Total Rank Assessments10
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • FrankK Avatar
  • ZozoFouchtra Avatar
  • muesli4 Avatar
  • Blind4Basics Avatar
  • umarqattan Avatar
  • Voile Avatar
  • nizarjak Avatar
  • hobovsky Avatar
Ad