Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Rock-and-roll founding father Chuck Berry sadly passed away today.

Consider the chorus of his famous song "Johnny B. Goode":

Go, go
Go Johnny go, go
Go Johnny go, go
Go Johnny go, go
Go Johnny go, go
Johnny B. Goode

(There are other ways it has been punctuated but the above will serve for the purposes of the challenge.)

Challenge

Given a nonempty, lowercase string of letters a-z, output the chorus of "Johnny B. Goode" with all the instances of Go or go replaced with the input string, capitalized in the same way.

A trailing newline may optionally follow. Nothing else in the chorus should change.

For example, if the input is code the output must be exactly

Code, code
Code Johnny code, code
Code Johnny code, code
Code Johnny code, code
Code Johnny code, code
Johnny B. Codeode

optionally followed by a newline.

Note that the capitalization of all words matches the original chorus, and (despite lack of rhythm) the Go in Goode is replaced as well as the individual words Go and go.

The shortest code in bytes wins.

Test Cases

"input"
output

"go"
Go, go
Go Johnny go, go
Go Johnny go, go
Go Johnny go, go
Go Johnny go, go
Johnny B. Goode

"code"
Code, code
Code Johnny code, code
Code Johnny code, code
Code Johnny code, code
Code Johnny code, code
Johnny B. Codeode

"a"
A, a
A Johnny a, a
A Johnny a, a
A Johnny a, a
A Johnny a, a
Johnny B. Aode

"fantastic"
Fantastic, fantastic
Fantastic Johnny fantastic, fantastic
Fantastic Johnny fantastic, fantastic
Fantastic Johnny fantastic, fantastic
Fantastic Johnny fantastic, fantastic
Johnny B. Fantasticode
share|improve this question

Pyth - 52 bytes

j", "_ArBQ3V4s[H" Johnny "G", "G;%"Johnny B. %sode"H

Test Suite.

share|improve this answer

Pure Bash, 69 bytes

M=aaaa;echo -e $1, $1 ${M//a/\\n$1 Johnny $1, $1}\\nJohnny B. ${1}ode

Try it online!

share|improve this answer

PHP, 88 Bytes

<?=$u=ucfirst($l=$argv[1]),", $l\n",$r="$u Johnny $l, $l\n","$r$r{$r}Johnny B. {$u}ode";
share|improve this answer

Stacked, 64 bytes

:@n tc@N('%N, %n
'!'%N Johnny %n, %n
'!4*'Johnny B. 'N'ode'!)sum

Try it online!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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