Created
April 9, 2020 01:04
-
-
Save roman-on/98d8f8ddb0bc7506835b5d42d66353cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We would like to connect chocolate cubes to a row x cm long. We have - | |
# - small chocolate cubes 1 cm long and 5 cm large chocolate cubes. | |
# The function receives the number of small cubes (small), the number of large cubes (big), - | |
# - and the desired line length (x). The function returns true - | |
# - if it is possible to create an x-length row using the number of all or part of the chocolate cubes received. | |
>>> chocolate_maker(3, 1, 8) | |
True | |
>>> chocolate_maker(3, 1, 9) | |
False | |
>>> chocolate_maker(3, 2, 10) | |
True | |
# gil gave to try: | |
chocolate_maker(0, 3, 13) | |
False | |
def chocolate_maker(small, big, x): | |
small_cube = 1 * small | |
big_cube = 5 * big | |
if (small_cube + big_cube) >= x and x % 5 <= small_cube: | |
return True | |
else: | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment