16
Inspired by this CR question (please don't kill me for browsing CR)
Spec
The probabilities of misspelling a word are:
- 1/3 of the time don't change the output
- 1/3 of the time remove a random character
- 1/3 of the time duplicate a random character
The chance for removing/duplicating a given character in the input should be the same for all chars.
If two consecutive characters are the same (case-sensitive), the probability of one of them being modified should be the same as if they are one character. I.e. the outputs for AA
(which are AA
or A
or AAA
) should all have the same probability.
The input will only contain of letters for simplicity.
Examples
First line is input, following lines are all possible misspellings. Each line should have the same probability of being output, the input is excluded in the examples but it should still have a 1/3 probability of output.
foo
fo
oo
ffoo
fooo
PPCG
PPC
PPG
PCG
PPPCG
PPCCG
PPCGG
It's a nice challenge, but if each line has the same probability of being output, doesn't that mean that it isn't a 1/3 chance that the word stays the same? – Value Ink – 2016-08-30T00:45:53.663
@ValueInk okay that is a flaw with the examples. let me fix – Downgoat – 2016-08-30T00:47:13.187
3Wait, if each line would have the same probability of being output, then wouldn't the distribution of characters not be uniform? Like, with
foo
: if you remove a character it could become (-f)oo, f(-o)o, and fo(-o). Sofo
should be twice as likely asoo
, but you say every line has equal probability. – Deusovi – 2016-08-30T03:34:15.9902@Deusovi there is a whole paragraph explaing this, I'll copy that here just in case
If two consecutive characters are the same (case-sensitive), the probability of one of them being modified should be the same as if they are one character. I.e. the outputs for AA (which are AA or A or AAA) should all have the same probability.
– edc65 – 2016-08-30T08:24:10.677@Downgoat Do you run this program on messages you post in chat before hitting enter? roasted... – James – 2016-08-30T17:45:08.080
1@DJMcMayhem no, more than one characters are usually misspelt ;_; – Downgoat – 2016-08-30T18:08:57.637