MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / HiveMaker

Function HiveMaker

Misc/HiveMaker/solution_2.py:1–14  ·  view source on GitHub ↗
(sticks)

Source from the content-addressed store, hash-verified

1def HiveMaker(sticks):
2 hives, stickU = 0, 0 # I will set # of hives and sticks used to 0
3 if sticks <= 5:
4 return [0, 0, sticks]
5 while sticks >= 4: # While the sticks are more than or equal to 4(minimum to make a hive)
6 hives += 1
7 if hives == 1:
8 sticks, stickU = sticks - 6, stickU + 6 # First hexagon has six sides, so sticksUsed += 6
9 elif hives == 2:
10 sticks, stickU = sticks - 5, stickU + 5 # Second requires five sticks.
11 else:
12 sticks, stickU = sticks - 4, stickU + 4 # The rest just need 4 sticks as there are two sides available
13 # Subtracts sticks left because you used it, and adds it to sticks used
14 return [hives, stickU, sticks]
15
16# Works for all testcases except for one wrong testcase.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected