Introduction
We -- especially the geeks among us, who tend to be fans -- all remember this old Far Side cartoon:
Clearly, Professor Schwartzman could have brushed up on his programming skills just a wee bit more before he put his invention to use. But can you replicate it yourself... using as few bytes as possible?
Input Specs
You must create a script that translates dog sounds into appropriately intonated "Hey"s. This is pure code golf; the lowest number of bytes wins.
Your input will consist of some combination of the following tokens:
Bark
,Baark
,Baaark
,Baaaark
, ... (that is,B*rk
with at least 1a
replacing the asterisk)Woof
,Wooof
,Woooof
, ... (W*f
with at least 2o
s replacing the asterisk)Grr
,Grrr
,Grrrr
, ..., (G
followed by at least 2r
s)- Any number of
.
(period),!
(exclamation mark) and/or?
(question mark) characters, which may occur anywhere in the input
Note, again, that the Woof
-based and Grr
-based tokens always require at least two o
s and r
s respectively; Wof
and Gr
are not valid tokens.
There is no limit on how long a token can be (e.g., how many repeated a
s there can be in a Bark
token); however, your decoder only needs to work correctly for input tokens with up to 10 total a
s, o
s, or r
s to pass this challenge.
Output Specs
Faithful to Schwartzman's design, your canine decoder program must process it into output text as follows:
Bark
,Woof
, andGrr
becomeHey
;Baark
,Wooof
, andGrrr
becomeHeyy
;Baaark
,Woooof
, andGrrrr
becomeHeyyy
; etc.- For all
Bark
-based tokens, the number ofy
s in the outputHey
-based token must be equal to the number ofa
s; - For all
Woof
-based tokens, the number ofy
s in the outputHey
-based token must be one less than the number ofo
s; - For all
Grr
-based tokens, the number ofy
s in the outputHey
-based token must be one less than the number ofr
s; - All punctuation (
.
,!
, and?
) is left unchanged.
Remember to drop one y
from the output for Woof
s and Grr
s only! The input Baaaaaaaark?
, with 8 a
s, will become Heyyyyyyyy?
, with a matching set of 8 y
s. However, Woooooooof?
becomes only Heyyyyyyy?
, with 7 y
s.
Again, if you can get your program to work for input tokens of unlimited size, that's great, but for purposes of this challenge, your program will only be checked to ensure that it works properly for input tokens that have no more than 10 repeated letters.
All Bark
-, Woof
-, and Grr
-based tokens in your input are assumed to begin with capital letters. Therefore, there is no need to handle turning Bark grrr
into Hey heyy
or anything similar.
Example Inputs and Outputs
-
- Input:
Bark. Bark! Bark!!
- Output:
Hey. Hey! Hey!!
- Input:
-
- Input:
Baaaaaark?
(sixa
s) - Output:
Heyyyyyy?
(sixy
s)
- Input:
-
- Input:
Grrrrrrrr...
(eightr
s) - Output:
Heyyyyyyy...
(seveny
s)
- Input:
-
- Input:
?...!
- Output:
?...!
- Input:
-
- Input:
Wooof Woof? Grrrr. Baaaark Grr!
- Output:
Heyy Hey? Heyyy. Heyyyy Hey!
- Input: