Skip to content

Instantly share code, notes, and snippets.

@jakevossen5
Created February 6, 2020 18:59
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 jakevossen5/542cdc6b392cd0513cebc15d5e27d1ec to your computer and use it in GitHub Desktop.
Save jakevossen5/542cdc6b392cd0513cebc15d5e27d1ec to your computer and use it in GitHub Desktop.
A one liner for a binary to decimal created to demonstrate bad code
while (n := ((print(c[1])) if not (c := ((True, "OUTPUT error ") if -1 in (n := [(lambda t: 2**int(t[0]) if t[1] == '1' else (-1 if t[1] not in ['0', '1'] else 0))(t) for t in enumerate(input('BINARY-STR> ')[::-1])]) else (True, "OUTPUT " + str(sum(n)))) if (input('OPTION> ') == '1') else (False, "OUTPUT goodbye!"))[0] else print(c[1]) or (True if 'y' in (lower_in := input('CONTINUE> ').lower()) else print('OUTPUT goodbye!')))): continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment