CMU Coding Bootcamp

feat: oct 2 classwork

thecoded.prof 64ce9ee0 0da7eeed

verified
Changed files
+21
python
oct2
level0
+21
python/oct2/level0/euler.py
··· 1 + from typing import List 2 + from typing import Generator 3 + 4 + 5 + def _multiples(nums: List[int], above: int, below: int) -> List[int]: 6 + return [num for num in range(above, below) if any(num % n == 0 for n in nums)] 7 + 8 + 9 + def _multiples_gen(nums: List[int], above: int, below: int) -> Generator[int]: 10 + for i in range(above, below): 11 + if any(i % n == 0 for n in nums): 12 + yield i 13 + 14 + 15 + def multiples(nums: List[int], below: int) -> List[int]: 16 + return _multiples(nums, 0, below) 17 + 18 + 19 + print(sum(multiples([3, 5], 1000))) 20 + print(sum(_multiples_gen([3, 5], 0, 1000))) 21 + print(sum(_multiples([3, 5], 0, 1000)))