Unless you have a userscript that modifies the site's design (or even if so), you should have noticed that we have our site design!
So, to celebrate, let's make a program that retroactively applies this design (oversimplified, of course)!
So, the most important changes are:
- our new name is now Code Golf and Coding Challenges
- our site is no longer the default blue color and is instead a nice dark green
So, given a string, change:
PPCG
toCGCC
Programming Puzzles {non-whitespace} Code Golf
toCode Golf {same-thing} Coding Challenges
(for example,Programming Puzzles + Code Golf
,and Code Golf
, and& Code Golf
would all be changed toCode Golf + Coding Challenges
,and Coding Challenges
, and& Coding Challenges
.#abc
to#acb
(swap blue to green and vice versa - just ignore the fact that green shouldn't logically become blue but I don't want to complicate the color shifting)#abcdef
to#abefcd
(same as above)
Note that for the color swaps, you should accept any hexadecimal digit from 0-9
to a-f
. You can choose what case of hex digit to require, but it must be consistent and the same from input to output.
Your substitutions can be case-sensitive, and if not, please specify how the output works.
The substitutions should only happen when the string is surrounded by word boundaries (including the start of the #
). In other words, each of the specified substitutions should only occur if the match is at the edge of the string or is bordered by non-alphanumeric characters (on both sides).
Standard loopholes apply. This is a code-golf challenge, so the shortest code wins!
Examples
PPCG -> CGCC
Programming Puzzles or Code Golf -> Code Golf or Coding Challenges
PPCG stands for Programming Puzzles and Code Golf and its site color is #abf -> CGCC stands for Code Golf and Coding Challenges and its site color is #afb
The color #00f is much more intense than #5568ed -> The color #0f0 is much more intense than #55ed68
Programming Puzzles and No Substitution -> Programming Puzzles and No Substitution
No Substitution and Code Golf -> No Substitution and Code Golf
Programming Puzzles and no substitution Code Golf -> Programming Puzzles and no substitution Code Golf
Code Golf and Programming Puzzles -> Code Golf and Programming Puzzles
Programming Puzzles and Programming Puzzles and Code Golf -> Programming Puzzles and Code Golf and Coding Challenges
(for the last test case, it is important to note that the translated string could be translated again but the transformation must be applied exactly once)
Important Update
(Thanks @tsh)
The Programming Puzzles ... Code Golf
substitution rule can include the other rules inside of it (Programming Puzzles PPCG Code Golf
is valid). In this case, you may choose whether or not the rules are applied, but it must be deterministic. I'm not requiring that you be consistent between PPCG
and #...
because answers seem to implement the rules in my list ordering which results in inconsistencies. This is just a clarification; I believe all current answers remain valid.
Programming Puzzles and no substitution Code Golf
might also catch someone (even though everyone's using the same valid regex) \$\endgroup\$Code Golf and Programming Puzzles
andProgramming Puzzles and Programming Puzzles and Code Golf
. @Veskah Hmm, and I think that last suggested test case fails in my 05AB1E answer, since I don't have regex.. >.< Back to the drawing board.. \$\endgroup\$