The goal is to simplify sentences containing multiple negatives.
Like with multiplying negative numbers, two negative words annihilate each other until at most one is left (doesn't matter which one). While some words disappear without a trace, other leave behind a positive part

The affected words are:

couldn't    could
wouldn't    would
shouldn't   should
don't       do
doesn't     does
didn't      did
isn't       is
aren't      are
weren't     were

You will notice that I conveniently forgot to include some rules like shan't/shall, won't/will, nothing/something, impossible/possible. Hunting down all the exceptions is a nightmare and would make it yet another string compression challenge.
But if including some additional rules that are not listed, yet are in the spirit of the challenge would make your code shorter (looking at you, Mathematica built-ins), by all means, go for it.



Move along
Nothing to see here
This sentence will stay the same
You dont put Nosferatu's donut knot in the cantaloupe cannon without an apostrophe.

Don't change this sentence.
This one will also not change
So far no inputs were changed

We don't need no education!
No, don't say that!
Wouldn't it be nice if people weren't fighting?

I don't not use no double negatives.
This isn't not the usual way to not express yourself not 
We don't not have no time to not don't solve this
I don't not even know if this isn't not making no sense anymore, it wouldn't be so bad if it weren't for not all these not words which not shouldn't be not there in the first place

Output (either of the elements is valid)

["Move along"]
["Nothing to see here"]
["This sentence will stay the same"]
["You dont put Nosferatu's donut knot in the cantaloupe cannon without an apostrophe."]

["Don't change this sentence."]
["This one will also not change"]
["So far no inputs were changed"]

["We do need education!"]
[", do say that!", "do say that!", "Do say that!"]
["Would it be nice if people were fighting?"]

["I don't use double negatives.", "I do not use double negatives.", "I do use no double negatives."]
["This is the usual way to express yourself"]
["We don't have time to do solve this", "We do not have time to do solve this", "We do have no time to do solve this", "We do have time to not do solve this", "We do have time to don't solve this"]
["I do even know if this is making sense anymore, it would be so bad if it were for all these words which should be there in the first place"]
  • \$\begingroup\$ related: codegolf.stackexchange.com/questions/165753/… codegolf.stackexchange.com/questions/148739/… \$\endgroup\$
    – DenDenDo
    Sep 21, 2018 at 19:23
  • 1
    \$\begingroup\$ I'm confused as to when to remove the whole word (as in your We don't need no education example) or when to replace the word with its complement (as in your Wouldn't it be nice example). \$\endgroup\$ Sep 21, 2018 at 19:48
  • 1
    \$\begingroup\$ Are we really supposed (or at least allowed) to replace won't with wo as one of the examples suggest? If the rule is just remove n't, then this is inconsistent with can't: according to the table, it must be replaced with can rather than ca. \$\endgroup\$
    – Arnauld
    Sep 22, 2018 at 8:37
  • 2
    \$\begingroup\$ I'm temporarily voting to close as unclear. Please ping me when it's clarified so that I can retract my vote or vote to reopen. \$\endgroup\$
    – Arnauld
    Sep 22, 2018 at 8:38
  • 1
    \$\begingroup\$ I removed can't and won't from the requirements and tests and allow undefined behaviour in those cases instead of overcomplicating it \$\endgroup\$
    – DenDenDo
    Sep 22, 2018 at 14:32

1 Answer 1


Retina 0.8.2, 44 bytes


Try it online! Link includes test cases.

  • \$\begingroup\$ It is apparently allowed to replace won't with wo (!), but the table suggests that can't should be replaced with can rather than ca. (I think this needs to be clarified in the challenge, anyway.) \$\endgroup\$
    – Arnauld
    Sep 22, 2018 at 8:09
  • \$\begingroup\$ @Arnauld Like this? \$\endgroup\$
    – Neil
    Sep 22, 2018 at 10:43
  • \$\begingroup\$ Yes, but let's see how this is clarified by the OP. \$\endgroup\$
    – Arnauld
    Sep 22, 2018 at 10:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.