# A Programming Puzzle of Mode Golf

Your task is to print the text Good morning, Green orb!, with every character repeated in place as many times as the most frequent byte in your source (the mode). A trailing newline is permitted and need not be repeated.

For example if your source was

print p


Since p appears twice and every other byte appears once you would need to print

GGoooodd  mmoorrnniinngg,,  GGrreeeenn  oorrbb!!


Answers will be scored by the product of their byte count and the number of times the output is repeated. For example the above code (if it worked) would score 7*2 = 14. The goal should be to minimize one's score.

Your code must contain at least 1 byte.

Use this program to verify that your code and output match

• Functions are allowed, right? Dec 28, 2017 at 20:05
• @totallyhuman Yes, so long as they don't take input. Dec 28, 2017 at 20:05
• Shouldn't this be tagged quine? Dec 29, 2017 at 16:12
• Morning can't be capitalized, can it haha? Jan 10, 2018 at 19:56
• @magicoctopusurn Nope the text should be the same. Jan 10, 2018 at 20:06

# Pushy, 36 * 2 = 72

GXVWOP^4W_[afdc\hiBN$29+L-''.  Try it online! The main principle of this answer is that each character n is stored as n + index - 29 in order to avoid the repetition in the original string. This mapping created the string in the backticks. The rest of the program simply decodes this and prints each character twice:  ...  \ Push the encoded string N \ Remove printing delimiter$            \ While there are items left on stack:
29+         \   Add 29 to top of stack
L-       \   Subtract current length from top of stack
''.    \   Print twice, then pop


Bytes used twice: 'W

Changelog

• Golfed length from 41 to 38, by changing decoding method.
• Golfed length from 38 to 37 by subtracting 29 from each encoded character to prevent multibyte characters.
• Golfed length from 37 to 36 by using implicit 'end loop'

# brainfuck, 414 * 163 = 67,482

-[>-<---]>-------->>>-[>+>+>+>>+>+>+>+>+>+>+>>>+>+>+>+>+>>+>+>++<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<-----]<-[>+<-------]>-->+++++++++>+++++++++>-->------------------->+++++++>+++++++++>++++++++++++>++++++++>+++>++++++++>+>------->------------------->------------------------------->++++++++++++>->->++++++++>------------------->+++++++++>++++++++++++>---->>++++[<++++++++>-]<+[<]>[<<<[>+>+<<-]>>[->.<]>[-]>]


Try it online!

I'm not very good at brainfuck so this is likely far from optimal, but it works.

## Explanation

The first part is

-[>+>+>+>>+>+>+>+>+>+>+>>>+>+>+>+>+>>+>+>++<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<-----]<-[>+<-------]>-->+++++++++>+++++++++>-->------------------->+++++++>+++++++++>++++++++++++>++++++++>+++>++++++++>+>------->------------------->------------------------------->++++++++++++>->->++++++++>------------------->+++++++++>++++++++++++>---->>++++[<++++++++>-]<+[<]>


This writes the charcodes for

Good morning, Green orb!


to memory in order. It is certainly the place that could use the most optimization.

Then we have

[<<<[>+>+<<-]>>[->.<]>[-]>]


Which goes and prints off each character as many times as we tell it. Since there are 163 pluses in the program we tell it to print each character 163 times.

-[>-<---]>--------


# Standard ML (MLton), 84*5=420 83 bytes * 5 = 415

map(fn$=>map(fn _=>print(str$))[0,2,3,4,5])(explode"Good mor\110ing, Green orb!");


Try it online!

### Alternative approach (same score)

String.map;it(fn c=>(print(it(fn _=>c)"vwxyz");c))"Good mor\110i\110g, Green orb!";


Try it online!

# Noether, 42 bytes * 4 = 168

"Good morning, Green orb!"~sL(si/4*Pi1+~i)


Outputs:

GGGGoooooooodddd    mmmmoooorrrrnnnniiiinnnngggg,,,,    GGGGrrrreeeeeeeennnn    oooorrrrbbbb!!!!


Try it online!

# 05AB1E, 22 bytes * 2 = 44

”‚¿•´,ˆ¨ orb!”'m5ǝ2иζJ


Try it online!

If I am able to output title-cased:

# 05AB1E, 13 bytes

”‚¿•´,ˆ¨ Orb!


Try it online!

Please note, CP-1252 ‚ is not a comma, therefore there are no dupes.

# ><>, 41 bytes x 7 = 287

|v"Good morning, Green orb!"
o\! !\:::|oo


Try it online!

As 'o' is used as the print character, this uses some mirrors to reuse them for printing.

• @HeebyJeebyMan completely forgot to add that on, changed it now thanks :) Jan 16, 2018 at 9:33
• 44*3
– Jo King
Feb 12, 2019 at 7:39

# Perl 6, 3 * 54 bytes = 162

<<"G{qox 2}d"morning,'Green'orb!>>~~say S:g{.}=$/x 3  Try it online! I started off with the normal: "Good morning, Green orb!"~~(S:g{.}=$/x 4).say


Which simply replaces each letter by 4 copies of itself and prints. The mode characters were the spaces and the os, so I changed the string part to a word quote with interpolation:

<<Good morning,'Green'orb!>>~~say S:g{.}=$/x 4  This decreased the spaces down to 3. Next was the o, which I decided to double in the oo part of Good. <<"G{qox 2}d"morning,'Green'orb!>>~~say S:g{.}=$/x 4


This involved wrapping the Good in interpolating quotes of its own, then having to use a custom quoting construct to do the o character, since the quote characters were taken.

END{$0="Good morning, Green orb!";gsub(/./,"&&&&");print}  Try it online! # K (oK), 35 bytes * 4 = 140 Solution: 0:,/4#'"Good morning, Green orb!";  Try it online! Explanation: Nothing fancy here, the most common letter is o which occurs 4 times. 0:,/4#'"Good morning, Green orb!"; / the solution "Good morning, Green orb!" / the string to be displayed 4#' / 4 take (#) each (') repeats each character 4 times ,/ / flatten these lists 0: ; / print to stdout (0:) and swallow return value (;)  # Swift, 53*3=159 bytes {"Good morning, Green \u{6f}rb!".flatMap{[$0,$0,$0]}}


Try it online!

# Java 11, score: 455 (91 bytes * 5)

x->{for(var s:"G\157od mo\162ning, G\162een orb!".split(""))System.out.print(s.repeat(5));}


The e, o, r, and t are all four used 5 times.

Try it online.

Explanation:

x->{                     // Method with empty unused parameter and no return-type
for(var s:"G\157od mo\162ning, G\162een orb!"
//  Push String "Good morning, Green orb!"
.split(""))  //  And loop over its characters as Strings
System.out.print(s   //   Print the current character
.repeat(5));}      //   Repeated 5 times


# Pip, 42*4 = 168

a:"Good morning, Green orb!"Fi,#a{L4O(ai)}


Try it online!

# Julia, 59 × 3 = 177

map(y->print(y^3),["Good morning, G\x72ee\x6E \x6Frb!"...])


Try it online!

# Excel, 60x4 = 240

=CONCAT(REPT(MID("Good morning, Green orb!",ROW(1:24),1),4))
`