Today, playing Dragon Ball of the big adventure when throwing a sieve to think of the algorithm to throw a sieve, write their own play. The code is as follows:
" "Dragon Ball Big Adventure Throw a sieve introduction: Throw a sieve in the map if the map has more than 6 of the number of squares, the default is 10 to throw 10 not to exceed the remaining number of squares or the maximum number of times a single throw if the map remains less than or equal to 6 If the result of a single throw sieve is greater than the remaining number of squares, go to the next map input: Remaining grid output: The result of throwing a sieve" "ImportRandomdefthrow_once ():returnRandom.randint (1,6)defThrow_times (n,cells): Ret= [] whilen >0:curr=throw_once ()ifCurr <=cells:ret.append (curr) cells= cells-Curr N-= 1Else: returnretElse: returnretdefthrow_dices (cells):ifCells > 6: _ret= Throw_times (10, cells)Else: _ret=throw_once ()return_retif __name__=='__main__': Cells= 33Print(Throw_dices (cells))
Dragon Ball exciting bucket Big adventure throw sieve algorithm