I wrote some text, but it looks too professional. I want to make it look like I was really tired when I wrote it. I need you to insert some typos.
Your challenge is to take an arbitrary single line of text, and add typos. This means that for each character, there will be a 10% chance for it to be typofied.
The definition of "typofied" is that you must choose (randomly) one of the following:
- Duplicate the character.
- Delete the character.
Shift the character one keyboard space. The "keyboard" is defined as:
qwertyuiop asdfghjkl zxcvbnm
For the character shift, you must go one space up, down, left, or right. This must be chosen randomly. The shift option only applies to alphabetic characters. Case must be preserved. Be careful with edge-cases, like
m
!
The definition of "random" is that the result must not be predictable (by looking at previous results). For example, you can't typofy every tenth character. Furthermore, the randomness must have an even distribution. For example, you can't do 30% duplicate, 30% delete, and 40% shift; it has to be a 1/3 chance for each (1/2 for each if it's a nonalphabetic character).
Example input:
This is some correct text. It is too correct. Please un-correctify it.
Example output:
This iissome xorreect tex.. It is too coteect. Please jn-corretify it.
This is code-golf, so the shortest code in bytes will win.