6 kyu

Sum of dices

Description:

You have n dices each one having s sides numbered from 1 to s. How many outcomes add up to a specified number k?

For example if we roll four normal six-sided dices we have four outcomes that add up to 5.

(1, 1, 1, 2) (1, 1, 2, 1) (1, 2, 1, 1) (2, 1, 1, 1)

There are 100 random tests with:

  • 0 <= n <= 10
  • 1 <= s <= 20
  • 0 <= k <= n * s

Notes:

  • there is always exactly 1 case to reach k = 0 regardless of the number of dice you have
  • without any dice, it's not possible to reach any positive k
Algorithms
Fundamentals

More By Author:

Check out these other kata created by NikosAthens

Stats:

CreatedApr 25, 2017
PublishedApr 25, 2017
Warriors Trained802
Total Skips15
Total Code Submissions1077
Total Times Completed166
Python Completions166
Total Stars25
% of votes with a positive feedback rating91% of 55
Total "Very Satisfied" Votes46
Total "Somewhat Satisfied" Votes8
Total "Not Satisfied" Votes1
Total Rank Assessments6
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • NikosAthens Avatar
  • kazk Avatar
  • ZED.CWT Avatar
  • dfhwze Avatar
Ad