Skip to content

Instantly share code, notes, and snippets.

View pschanely's full-sized avatar

Phillip Schanely pschanely

View GitHub Profile
@pschanely
pschanely / main.py
Created July 7, 2025 00:15
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
'''
post: __return__ != 0
'''
return 2 * n + 10
@pschanely
pschanely / main.py
Created July 7, 2025 00:15
Shared via CrossHair Playground
import re
from typing import Optional
def parse_year(yearstring: str) -> Optional[int]:
'''
Something is wrong with this year parser! Can you guess what it is?
post: __return__ is None or 1000 <= __return__ <= 9999
'''
return int(yearstring) if re.match('[1-9][0-9][0-9][0-9]', yearstring) else None
@pschanely
pschanely / main.py
Created July 5, 2025 20:37
Shared via CrossHair Playground
import dataclasses
from typing import List
@dataclasses.dataclass
class AverageableQueue:
'''
A queue of numbers with a O(1) average() operation.
inv: self._total == sum(self._values)
'''
_values: List[int]
@pschanely
pschanely / main.py
Created June 26, 2025 18:46
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
bigger = 2 * n + 10
assert bigger != 0
return bigger
@pschanely
pschanely / main.py
Created June 26, 2025 18:35
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
bigger = 2 * n + 10
assert bigger != 0
return
@pschanely
pschanely / main.py
Created June 26, 2025 18:33
Shared via CrossHair Playground
import re
from typing import Optional
def parse_year(yearstring: str) -> Optional[int]:
'''
Something is wrong with this year parser! Can you guess what it is?
'''
year = int(yearstring) if re.match('[1-9][0-9][0-9][0-9]', yearstring) else None
assert year is None or 1000 <= year <= 9999
return year
@pschanely
pschanely / main.py
Created June 25, 2025 20:49
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
'''
post: __return__ != 0
'''
return 2 * n + 10
@pschanely
pschanely / main.py
Created June 18, 2025 05:44
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
'''
post: __return__ != 0
'''
return 2 * n + 10
@pschanely
pschanely / main.py
Created June 4, 2025 08:38
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
'''
post: __return__ != 0
'''
return 2 * n +1
@pschanely
pschanely / main.py
Created June 3, 2025 02:50
Shared via CrossHair Playground
import re
from typing import Optional
def parse_year(yearstring: str) -> Optional[int]:
'''
Something is wrong with this year parser! Can you guess what it is?
post: __return__ is None or 1000 <= __return__ <= 9999
'''
return int(yearstring) if re.match('[1-9][0-9][0-9][0-9]', yearstring) else None