bROKEN cAPSLOCK kEY fIASCO
05AB1E, 16 bytes
Thanks to Emigna for saving a byte and fixing a bug!
vyÐl'ŒÎ¾èQi¼ëš}?
Explanation:
vy # For each character in the string...
Ð # Triplicate that character
l # Convert to lowercase
'ŒÎ # Compressed version of "christmas"
¾ # Push the counting variable (let's call this N)
è # Get the nth character of "christmas", with modular indexing
Qi } # If equal...
¼ # N += 1
ë # Else...
š # Swapcase
? # Print that character
Uses the CP-1252 encoding. Try it online!
V, 38, 36 bytes
ÄVumaOchristmasòÉf2x`a@"maj~HòHdjV~
Try it online! (contains input and expected output for comparison)
When I first saw this, I thought it would be extremely easy. In fact, if it were not for the "christmas" bug, this would just be 2 bytes: V~
. The christmas bug makes it significantly harder, for a very hacky answer.
As usual, here is a hexdump:
00000000: c456 756d 614f 6368 7269 7374 6d61 731b .VumaOchristmas.
00000010: f2c9 6632 7860 6140 226d 616a 7e48 f248 ..f2x`a@"maj~H.H
00000020: 646a 567e djV~
PHP, 113 110 102 bytes
while($o=ord($c=$argv[1][$i++]))echo chr(32|$o==ord(christmas[$k%9])?$o|0&$k++:ctype_alpha($c)*32^$o);
takes input from first command line argument. Run with -r
.
breakdown
while($o=ord($c=$argv[1][$i++]))// loop through string characters
echo chr(
32|$o==ord(christmas[$k%9]) // if $c equals next character in "christmas"
?$o|0&$k++ // no change, increase "christmas" index
:ctype_alpha($c) // else if $c is a letter
*32^$o // toggle bit 5 of the ascii code
);