| 5 | # at best case. |
| 6 | |
| 7 | def 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 | |
| 34 | print(HiveMaker(7)) |
| 35 | print(HiveMaker(19)) |