Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given an n - sided die, we want to determine how many different ways one could repeatedly sum die rolls and get to a given

Given an n-sided die, we want to determine how many different ways one could repeatedly sum die rolls and
get to a given total.
For instance, given a 4-sided die, we could obtain a total of 3 in four different ways:
1+1+1(rolling a 1 three times)
1+2(rolling a 1 and then rolling a 2)
2+1(rolling a 2 and then rolling a 1)
3(rolling a 3)
We will write two different functions to solve this problem. Each functions takes n(the number of sides on
the die) and total (the total to which we'll sum rolls) as input. Each function must use its corresponding
dynamic programming methodology in order to solve the problem.
vays_to_sum_memo(n, total)
must use memoization
vays_to_sum_tab(n, total)
must use tabulation
ways_to_sum_memo , total =3
4
ways_to_sum_tab(n=4, total=3)
4
Imports
No imports allowed on this assignment, with the following exceptions:
Any modules you have written yourself
typing - this is not required, but some students have requested it
For testing only (do not use these for functionality in any other classes/algorithms):
unittest
random
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learn Mysql The Easy Way A Beginner Friendly Guide

Authors: Kiet Huynh

1st Edition

B0CNY7143T, 979-8869761545

More Books

Students also viewed these Databases questions