Skip to content

Instantly share code, notes, and snippets.

@pschanely
Created April 7, 2024 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pschanely/1b2b03acd505422a4e90aff214c93a63 to your computer and use it in GitHub Desktop.
Save pschanely/1b2b03acd505422a4e90aff214c93a63 to your computer and use it in GitHub Desktop.
Shared via CrossHair Playground
def func_source(x: list[int]) -> list[int]:
return [x[0], -1]
def func_sink(x: list[int]) -> bool:
return x[1] > 0
def func_safe(x: list[int]) -> list[int]:
return [x[0], 1]
def func_1(x: list[int]) -> list[int]:
if x[0] > 0:
return func_source(x)
else:
return func_safe(x)
def func_2(x: list[int]) -> bool:
'''
pre: len(x) == 2
post: __return__ == True
'''
while x[0] > 0:
x[0] = func_1(x)[0] - 1
x[1] = func_1(x)[1]
x = func_1(x)
return func_sink(x)
def func_3(x: list[int]) -> bool:
'''
pre: len(x) == 2
post: __return__ == False
'''
while x[0] <= 0:
x[0] = func_1(x)[0] + 1
x[1] = func_1(x)[1]
x = func_1(x)
return func_sink(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment