Pyupgrade to Python 3.9 (#4718)

* Pyupgrade to Python 3.9

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Christian Clauss
2021-09-07 13:37:03 +02:00
committed by GitHub
parent 5d5831bdd0
commit cecf43d648
142 changed files with 523 additions and 530 deletions

View File

@ -12,10 +12,10 @@ It is possible to write ten as the sum of primes in exactly five different ways:
What is the first value which can be written as the sum of primes in over
five thousand different ways?
"""
from __future__ import annotations
from functools import lru_cache
from math import ceil
from typing import Optional, Set
NUM_PRIMES = 100
@ -30,7 +30,7 @@ for prime in range(3, ceil(NUM_PRIMES ** 0.5), 2):
@lru_cache(maxsize=100)
def partition(number_to_partition: int) -> Set[int]:
def partition(number_to_partition: int) -> set[int]:
"""
Return a set of integers corresponding to unique prime partitions of n.
The unique prime partitions can be represented as unique prime decompositions,
@ -47,7 +47,7 @@ def partition(number_to_partition: int) -> Set[int]:
elif number_to_partition == 0:
return {1}
ret: Set[int] = set()
ret: set[int] = set()
prime: int
sub: int
@ -60,7 +60,7 @@ def partition(number_to_partition: int) -> Set[int]:
return ret
def solution(number_unique_partitions: int = 5000) -> Optional[int]:
def solution(number_unique_partitions: int = 5000) -> int | None:
"""
Return the smallest integer that can be written as the sum of primes in over
m unique ways.