Write a program or function that transforms a string of text into something Mr. Mackey would say.
m'kayhas a random 50% chance of being added after the punctuations
!. If that is the case, it will be followed by the exact same punctuation mark that preceeds it and preceeded by a space.
For example, in the sentence
Test, test., there are two places where
m'kaycan be added: after the comma, and after the period, with a 50% chance at each place. Possible results would be
Test, m'kay, test. or
Test, test. M'kay.or
Test, m'kay, test. M'kay..
There must always be at least one
m'kayadded. Moreover, it cannot always be at the same place and each valid place where
m'kaycould be added must occur with equal probability. That is, you can't add
m'kayalways at the end of the string if because of randomness you never added any
m'kay. If there is only one
m'kay, it must have the same probability of appearing in each valid position, even though its presence is enforced.
mmust be uppercased.
The number of
m'kaymust be uniformely picked between 1 and 3. That is,
mmm'kayare all possible choices, each with probability 0.33... If it must be uppercased (see above rule), all
mmust be uppercased.
Inputs are ASCII strings containing characters from ASCII Dec 32 (Space) to ASCII Dec 126 (Tilde
~). There are no linebreaks in the input. You may assumed that any input will contain at least one of
, . ? !.
You may assume that there are no
m'kayor any of its variants in the input.
Inputs may be taken from STDIN, function arguments, command line, or anything similar.
Output may be via STDOUT, a function return, or something similar.
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. MMM'kay. It's 100% free, mm'kay, no registration required.
Drugs are bad, so, if you do drugs, you're bad, because drugs are bad. They can hurt your body, cause drugs are bad.
Drugs are bad, m'kay, so, if you do drugs, you're bad, m'kay, because drugs are bad. They can hurt your body, m'kay, cause drugs are bad. M'kay.
Do you understand? Really? Good!
Do you understand? MM'kay? Really? Good! MMM'kay!
This is code-golf, so the shortest code in bytes wins, m'kay?