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 November 12, 2024 07:39
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
'''
post: __return__ != 0
'''
res1=20
res2=20
if n<50:
res1=1
else:
@pschanely
pschanely / main.py
Created November 7, 2024 04:28
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
'''
pre: n != -5
post: __return__ != 0
'''
return 2 * n + 10
@pschanely
pschanely / main.py
Created November 4, 2024 20:29
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
'''
post: __return__ != 0
'''
return 2 * n + 10
@pschanely
pschanely / main.py
Created October 26, 2024 17:25
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.fullmatch('[1-9][0-9][0-9][0-9]', yearstring) else None
@pschanely
pschanely / main.py
Created October 26, 2024 17:01
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
'''
pre: n>=0
post: __return__ != 0
'''
return 2 * n + 10
@pschanely
pschanely / main.py
Created October 23, 2024 03:42
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
'''
post: __return__ > 0
'''
if n > -10:
return n + 10
else:
return -n
@pschanely
pschanely / main.py
Created October 22, 2024 08:34
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
'''
post: __return__ != 0
'''
return 2 * n + 10
@pschanely
pschanely / main.py
Created October 19, 2024 00:55
Shared via CrossHair Playground
from typing import List, TypeVar, Union
'''
Below are some examples of some type limitations of CrossHair using some types.
'''
#############################
# FLOATS
#############################
def using_float(x: float) -> float:
@pschanely
pschanely / main.py
Created October 15, 2024 12:32
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
'''
post: __return__ != 0
'''
return 2 * n + 10
@pschanely
pschanely / main.py
Created October 11, 2024 21:38
Shared via CrossHair Playground
def f1(n: int) -> int:
return (n % 2) == 0
def f2(n: int) -> int:
if (n == 1000):
return 0
else:
return (n & 1) == 0