Dragon Ball exciting bucket Big adventure throw sieve algorithm

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.