Python SolutionsPython Solutions

🎳

A Billion Bowling Pins

Week 5, 2026

All Solutions

Python - Inefficient but works method | BMC | Python Solutions

# meths or maths? goals = [1_000_000, 1_000_000_000] for goal in goals: i = 0 while goal >= 0: i += 1 goal -= i print(i-1)

python | Peiran D | Python Solutions

//Paste your solution here if you want to share it publiclyrows = 0 number = 1 n = int(input()) while n > 0: n -= number number += 1 rows += 1 if n < 0: rows -= 1 print(rows)

Python solution | AlfieJ | Python Solutions

n = int(input()) a = 0 b = 1 while True : a += b b += 1 print(a) if a > n: print(b-2) break elif a == n: print(b-1) break

Easier Python solution | AlfieJ | Python Solutions

n = int(input()) a = 0 b = 1 while a <= n : a += b b += 1 print(b-2)

python | JustinJ | Python Solutions

//Paste your solution here if you want to share it publicly import math x = int(input()) y = (-1 + math.sqrt(1 + 8*(x))) / 2 y= math.floor(y) print(y)

python | JustinJ | Python Solutions

//Paste your solution here if you want to share it publicly import math x = int(input()) y = (-1 + math.sqrt(1 + 8*(x))) / 2 y= math.floor(y) print(y)

Python | PaulZ | Python Solutions

import math Pins = int(input("How many pins: ")) Rows = (-1 + math.sqrt(1 + 8*(Pins))) / 2 Rows= math.floor(Rows) print(Rows)

Easiest but not efficient solution | MushyZ | Python Solutions

def calc_pin_rows(no_of_pins): rows = 0 n = 1 if no_of_pins == 1: return 1 while no_of_pins > 0: if no_of_pins - n < 0: break rows += 1 no_of_pins -= n n += 1 return rows if __name__ == "__main__": no_of_pins = 1000000000 #for billion rows = calc_pin_rows(no_of_pins) print(f"Number of rows needed for {no_of_pins} pins: {rows}")