Skip to content

Instantly share code, notes, and snippets.

@tkaemming
Created April 1, 2016 00:37
Show Gist options
  • Save tkaemming/85027eebd302868d098ee4036676316d to your computer and use it in GitHub Desktop.
Save tkaemming/85027eebd302868d098ee4036676316d to your computer and use it in GitHub Desktop.
"""
makes text read like it was written by a drunk person
er, makes txet rea dlike i twas rwitten by a durnk persob
"""
import random
import sys
drinks = float(sys.argv[1])
for line in sys.stdin:
characters = []
iterator = enumerate(line)
for i, character in iterator:
if character == 'n':
character = 'b' if random.random() > (1 - (0.02 * drinks)) else 'n'
elif character == 'i' and line[i+1:i+3] == 'ng' and random.random() > (1 - (0.05 * drinks)):
character = 'ig'
next(iterator)
next(iterator)
elif character.isalpha() and random.random() > (1 - (0.005 * drinks)) and len(line) > i:
character = ''.join((next(iterator)[1], character))
elif random.random() > (1 - (0.001 * drinks)):
character = character.upper()
characters.append(character)
sys.stdout.write(''.join(characters))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment