Skip to content

Instantly share code, notes, and snippets.

@ashleighbasil
Created February 8, 2021 08:06
Show Gist options
  • Save ashleighbasil/97ad1d1113e5cfbe19e71461e0d62a00 to your computer and use it in GitHub Desktop.
Save ashleighbasil/97ad1d1113e5cfbe19e71461e0d62a00 to your computer and use it in GitHub Desktop.
ProductList solution to cassidoo puzzle
import math
class ProductList:
def __init__(self):
self.numbers = []
def add(self, number):
self.numbers.append(number)
def product(self, m):
factors = self.numbers[::-1][:m]
return math.prod(factors)
pl = ProductList()
pl.add(1)
pl.add(2)
pl.add(3)
pl.add(4)
prod_3 = pl.product(3)
prod_2 = pl.product(2)
print(prod_2, prod_3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment