I write a program in python to find no of combinations of series
there is one dice which has 6 faces.
user input 2
then the out is shown is as no of count where two is come in combinations
ex if we throw dice for to get 2 as sum the maximum are two dice thrown are required
(1+1) and (2) so count is 2
if i throw for sum of 3, the out-put is
(1+1+1),(1+2),(2+1),(3) so count is 4 enter code here
if i throw for sum of 4 then the out put is
(1+1+1+1),(1+1+2),(1+2+1),(2+1+1),(2+2),(3+1),(1+3),(4) count is 8
I write the code is
# I am considering the Board is horizontal single line
def count_values(values,num):
for i in range(num):
print(values[i]," ",end='')
print('')
def print_list(out_put,values,num,count=0,show=False):
dice=6
if num == 0:
count_values(values,count)
out_put[0] += 1
elif num > 0:
for k in range(1,dice+1):
values[count] = k
print_list(out_put,values,num-k, count+1,show)
n=int(input('Enter A number'))
values=[0]*n
out_put=[0]
print_list(out_put,values,n)
print(out_put)
it shows out put for small inputs likes 10,20,30 but i want the out put for 100 and 500 and 610 like inputs , but is get more time (around 5-6 hours still running) and the count of combination is more than 1145201564 still it is counting any one has solution for this
Any one has any solution. for this