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

Function HiveMaker

Misc/HiveMaker/solution_1.py:7–32  ·  view source on GitHub ↗
(sticks)

Source from the content-addressed store, hash-verified

5# at best case.
6
7def HiveMaker(sticks):
8 #If less than 11 then only 1
9 if sticks < 11:
10 return [1, 6, sticks-6]
11
12 hive = 0
13 initial = sticks
14 while True:
15 #A hex pair has 11 sticks
16 pairs = sticks // 11
17 #The remaining sticks
18 sticks = sticks % 11
19 #If no pairs
20 if pairs == 0:
21 #With 4 sticks we have a new hex
22 hive += sticks//4
23 sticks %= 4
24 #But we cannot do anything else
25 break
26 #When we add two pairs we get 3 sticks
27 additions = pairs - 1
28 sticks += additions * 3
29 #Add to hive
30 hive += pairs * 2
31
32 return [hive, initial-sticks, sticks]
33
34print(HiveMaker(7))
35print(HiveMaker(19))

Callers 1

solution_1.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected