r/badcode • • May 11 '20

[deleted by user]

[removed]

104 Upvotes

44 comments sorted by

View all comments

4

u/[deleted] May 13 '20

Pastebin link: https://pastebin.com/9XNiEPrb

This solution downloads the gist with the example 7-segment art, then (ab)uses regular expressions to extract the actual art, combines that into a single string with no newlines, extracts the correct part, and then repeats that for every single line of every single number.

FEATURES:

  • Caching prevents the deliberately bad code from sending millions of requests to GitHub, while using time.sleep to simulate making another GET request.
  • Abuse of regexes.
  • Probably the worst variable naming ever, which I actually had a habit of doing back when I was a beginner.
  • Abuse of try/except.
  • The bug feature that causes the wait time for time.sleep to sometimes slowly lower due to floating point precision issues.
  • Lack of data validation.
  • Several hundred ~bugs~ features that I haven't found yet.

REQUIREMENTS:

  • Python 3 (preferably 3.7+)
  • The 'requests' python module (preferably requests==2.23.0)
  • An internet connection (faster = much better)

Edit: Reddit formatting sucks.