···66 Given a number of bricks return how many steps would be required to use them all given that:
77 S(0) = 0
88 S(n) = S(n-1) + n
99- Formula: `n=(-1+sqrt(1+8*bricks))/2`
99+ Formula: `S=(-1+sqrt(1+8*n))/2`
1010 """
1111 return ceil((-1 + sqrt(1 + 8 * bricks)) / 2)
1212
+12-1
python/sep30/level4/blendColors.py
···11+def blendComponent(c1: int, c2: int) -> int:
22+ """Get the median of 2 numbers."""
33+ return round((c1 + c2) / 2)
44+55+16def blendColors(rgb1: int, rgb2: int) -> int:
27 """Blend two colors represented as RGB values."""
88+ # Fill values and split into individual components
39 (r1, g1, b1) = [int(str(rgb1).zfill(9)[i : i + 3]) for i in range(0, 9, 3)]
410 (r2, g2, b2) = [int(str(rgb2).zfill(9)[i : i + 3]) for i in range(0, 9, 3)]
511 # Calculate the average of each color component
66- (r3, g3, b3) = [round((r1 + r2) / 2), round((g1 + g2) / 2), round((b1 + b2) / 2)]
1212+ (r3, g3, b3) = [
1313+ blendComponent(r1, r2),
1414+ blendComponent(g1, g2),
1515+ blendComponent(b1, b2),
1616+ ]
717 (final_r, final_g, final_b) = [str(x).zfill(3) for x in (r3, g3, b3)]
1818+ # Compose components and cast to integer
819 return int(final_r + final_g + final_b)
9201021