#!/usr/bin/env python3
"""
You and a friend are shooting some hoops at your local basketball court when
she issues a challenge: She will name a number, which we’ll call N. Your goal
is to score exactly N points in as many ways as possible using only 2-point
and 3-point shots. The order of your shots does not matter.
For example, there are two ways you could score N = 8 points: four 2-pointers
or two 3-pointers and one 2-pointer.
Your apparently sadistic friend chooses 60 for the value of N. You try to
negotiate this number down, but to no avail. However, she says you are welcome
to pick an even larger value of N. Does there exist an integer N greater than
60 such that there are fewer ways to score N points than there are ways to
score 60 points?
"""
def count_combinations(total_points: int) -> int:
counter = 0
for i in range(total_points // 3 + 1):
for j in range(total_points // 2 + 1):
combination = (3 * i) + (2 * j)
if combination == total_points:
counter += 1
elif combination > total_points:
break
return counter
def test():
"""Small test set."""
assert count_combinations(0) == 1 #no points
assert count_combinations(1) == 0 #impossible
assert count_combinations(2) == 1 #1 two-pointer
assert count_combinations(3) == 1 #1 three-pointer
assert count_combinations(4) == 1 #2 two-pointers and 0 three-pointers
assert count_combinations(5) == 1 #0 and 1
assert count_combinations(6) == 2 #3 and 0; 0 and 2
assert count_combinations(7) == 1 #1 and 2
assert count_combinations(8) == 2 #4 and 0; 1 and 2
assert count_combinations(9) == 2 #3 and 1; 0 and 3
def main():
"""Main function."""
sixty_points_combinations = count_combinations(60)
print(f"There are {sixty_points_combinations} ways to score 60 points")
n = 61
while True:
n_points_combinations = count_combinations(n)
if n_points_combinations < sixty_points_combinations:
print(f"{n} points can be scored in just {n_points_combinations} ways")
break
cursor += 1
def timed_main():
"""Main function without any printing."""
sixty_points_combinations = count_combinations(60)
n = 61
while True:
n_points_combinations = count_combinations(n)
if n_points_combinations < sixty_points_combinations:
break
cursor += 1
if __name__ == "__main__":
test()
main()