title: The Real Slim Shady

text:
# Question
Title: The Real Slim Shady
Echo the following in as few bytes as possible:

```
I'm Slim Shady. Yes, I'm the real Shady.
All you other Slim Shadys are just imitating.
So, won't the real Slim Shady please stand up?
Please stand up. Please stand up.

```

The following five words must appear **EXACTLY ONCE** in your code:

`I'm`
`Slim`
`Shady`
`real`
`stand`

# Answer
# Python: 176

```
print"{0}{1}{2}. Yes, {0}{3}{2}.\nAll you other {1}{2}s are just imitating.\nSo, won't {3}{1}{2} p{4}?\nP{4}. P{4}.".format("I'm ","Slim ","Shady","the real ","lease stand up")

```

Naturally, the same idea as other compression solutions (though independently obtained).
> 28 votes

# Answer
**Brainfuck 1923 bytes**

Enjoy...

```
-[------->+<]>.+[-->+<]>++.---[->+++<]>+.
[->+++++<]>-.>-[--->+<]>--.--[--->++++<]
>.---.++++.[->+++++<]>-.>-[--->+<]>--.>+
[----->+++<]>+.-------.+++.+[--->+<]>++.
-----[++>---<]>.++[--->++<]>.--[->+++<]>-.
[->++++<]>+.[--->+<]>----.-[++>---<]>+.
------------.++++[->++<]>+.+[-->+<]>++.---
[->+++<]>+.[->+++++<]>-.---[->++++<]
>.------------.---.--[--->+<]>-.---[----->++<]
>.-------------.----.+++++++++++.[++>---<]
>--.>-[--->+<]>--.>+[----->+++<]>+.-------.
+++.+[--->+<]>++.-----[++>---<]>.>
++++++++++.+++[->+++++<]>.[--->+<]>+..
[++>---<]>--.--[->++++<]>+.----------.++++++.-
[---->+<]>+++.+++++[->+++<]
>.+++++.------------.---.+++++++++++++.
[-->+++++<]>+++.>-[--->+<]>--.--
[--->++++<]>.---.++++.[->+++++<]>-.>-
[--->+I'm<]>--.>+[----->+++<]>+.-------.+++.+
[--->+<]>++.------.+[---->+<]>+++.[->+++<]>+.--
[--->+<]>---.-------------.--[--->+<]>-.-
[--->++<]>.+++++++++++.--.+.
[---Slim->+<]>+++.-[--->++<]>-.++++.----.
+++++++++++.+[->+++<]>++.--[--->+<]
>-.-----------.+++++.-------.--[->+++<]>-.
>++++++++++.>-[--->+<]>--.[--->+<]>--.
[->+++++<]>+.------------.--[->++++<]>-.
--------.-.[++>---<]>++.[->+++<]>-.[---->+
<]>+++.---[->++++<]>.------------.---.--[---
>+<]>-.---[----->Shady++<]>.-------------.-
---.+++++++++++.[++>---<]>--.>-[--->+<]
>--.--[--->++++<]>.---.++++.[->+++++<]
>-.>-[--->+<]>--.>+[----->+++<]>+.-------.
+++.+[--->+<]>++.-[---->+<]>++.[-->+++++++<]
>.----.-------.----.--[--->+<]>--.++++[->+++<]
>.--[--->+<]>-.---[->++++<]>-.+.+[->+++<]
>++.+++++++++++++.----------.-[--->+<]
>-.---[->++++<]>+.-----.[--->++++<]>-.>
++++++++++.[->++++++++<]>.+[--->++++<]
>.---real----.----.--[--->+<]>--.++++[->+++<]
>.--[--->+<]>-.---[->++++<]>-.+.+[->+++<]
>++.+++++++++++++.----------.-[--->+<]>-.---
[->++++<]>+.-----.[->+++++<]>--.++[--->++<]
>.[-->stand+++++<]>.+[--->++++<]>
.-------.----.--[--->+<]>--.++++[->+++<]
>.--[--->+<]>-.---[->++++<]>-.+.+[->+++<]
>++.+++++++++++++.----------.-[--->+<]
>-.---[->++++<]>+.-----.[->+++++<]>--.

```

*Standard Loop Holes*
> 25 votes

# Answer
# Perl, 155

With improvements by Martin Büttner and Thaylon:

```
$_="01. Yes, 02X.
All you other1s are just imitating.
So, won't21 p3?
P3. P3.";s/\d/("I'm"," SlimX"," the real","lease stand up")[$&]/ge;s/X/ Shady/g;print

```
> 17 votes

# Answer
## Ruby, 154 bytes

```
$><<"012. Yes, 032.
All you other12s are just imitating.
So, won't312 p4?
P4. P4.".gsub(/\d/){%W{I'm \ Slim \ Shady \ the\ real lease\ stand\ up}[$&.hex]}

```

After helping out a few people with how to split up the filler strings I decided to give their replacement callback idea a go. ;)
> 12 votes

# Answer
# JavaScript (E6) 165

Just the same in another language

```
alert("012. Yes, 05326All you other12s are just imitating6So, won't5312 p4?\nP4. P4."
.replace(/\d/g,x=>"I'm1 Slim1 Shady1real1lease stand up1 the 1.\n".split(1)[x]))

```

Explanation: replace each single digit in the first string with the corresponding string in the array `["I'm"," Slim"," Shady","real","lease stand up"," the ",".\n"]`

Revised with the new rules here at PPCG (output returned from a function, no constraints about features newer than the challenge), this could be 158. See the snippet

```
F=
_=>`012. Yes, 0532.
All you other12s are just imitating.
So, won't5312 p4?
P4. P4.`.replace(/\d/g,x=>"I'm, Slim, Shady,real,lease stand up, the ".split`,`[x])

console.log(F())
```
> 10 votes

# Answer
# GolfScript, ~~162~~ ~~154~~ ~~152~~ 144 bytes

```
"I'm ":i"Slim ":|"Shady":y". Yes, "i"the real ":!y".
All you other "|y"s are just imitating.
So, won't "!|y" p""lease stand up":l"?
P"l". P"l"."

```

Test online
> 6 votes

# Answer
# CJam - 133

```
"I'm| Slim| Shady| the real|lease stand up|432. Yes, 412.
All you other32s are just imitating.
So, won't132 p0?
P0. P0."'|/~5,{`/\*}/

```

Try it at http://cjam.aditsu.net/

I think it also works in GolfScript if you replace `'|` with `"|"`
> 6 votes

# Answer
**VBA 343 bytes**

```
Sub EMINEM()
e = "Slim "
m = "Shady"
i = "I'm "
n = "lease stand up"
em = "real "

MsgBox i & e & m & ". Yes, " & i & "the " & em & m & "." & Chr(10) & "All you other " & e & m & "s are just imitating." & Chr(10) & "So, won't the " & em & e & m & " p" & n & Chr(10) & "P" & n & ". P" & n & "."

End Sub

```
> 5 votes

# Answer
# C# ~~209~~ ~~205~~ ~~201~~ ~~197~~ ~~209~~ ~~212~~ 217

```
class P{static void Main(){System.Console.Write("{0}{1}{2}. Yes, {0}{3}{2}.\nAll you other {1}{2}s are just imitating.\nSo, won't {3}{1}{2} p{4}?\nP{4}. P{4}.", "I'm ","Slim ","Shady","the real ","lease stand up");}}

```

*Now with Proper Capitalization and New Lines*
> 5 votes

# Answer
# VB ~~253~~ ~~249~~ ~~245~~ ~~241~~ ~~244~~ ~~285~~ ~~259~~ 223

I hate New Line termination

```
Module M
Sub Main
Console.Write("{0}{1}{2}. Yes, {0}{3}{2}.{5}All you other {1}{2}s are just imitating.{5}So, won't {3}{1}{2} p{4}?{5}P{4}. P{4}.","I'm ","Slim ","Shady","the real ","lease stand up",vbCr)
End Sub
End Module

```

*Now with proper Capitalization And Newlines in the output, and no Tabs* *

***Thank you VB for `vbCrLf`***

Thank you, @Taylor Scott!
> 5 votes

# Answer
# VBA 307 Bytes

And obfuscated with line separators (just for fun). Based on this answer

```
Function p()
e = "Slim ": m = "Shady": i = "I'm ": n = "lease stand up": s = "real ": a = "."
p = i & e & m & ". Yes, " & i & "the " & s & m & a & Chr(10) & "All you other " & e & m & "s are just imitating." & Chr(10) & "So, won't the " & s & e & m & " p" & n & Chr(10) & "P" & n & ". P" & n & a
End Function

```

Called from the immediate window with `?p`.

The 307 includes the `?p`.
> 5 votes

# Answer
# PHP - 151 bytes

```
<?="I'm Slim Shady".gzinflate("]Œ1
„0E{Á;üÎFr…ÅÒNHe9à°F&‰d&,Þ~Avmßûï;Ì¬=Æ.ÂVFaø•–ÃµÍ ‚#WäÓx    ñR
*Œª!Ä`d!½Ï¹Ï=>9uöót7Ø…Ij”ÔýÕ6Ó?qx‚/");@realstand;

```

hexdump:

```
0000000 3f3c 223d 2749 206d 6c53 6d69 5320 6168
0000010 7964 2e22 7a67 6e69 6c66 7461 2865 5d22
0000020 318c 840a 1030 7b45 3bc1 cefc 7246 c585
0000030 4ed2 6548 e039 46b0 8926 2664 de2c 057e
0000040 7641 df6d effb cc3b 3dac 2ec6 56c2 6146
0000050 f812 9695 b5c3 20cd 2382 e457 14d3 0978
0000060 52f1 2a0a ad8c 21aa 60c4 2164 cfbd cfb9
0000070 3e3d 7539 f3f6 3774 85d8 1949 946a d416
0000080 d5fd d336 713f 8278 222f 3b29 7240 6165
0000090 736c 6174 646e 003b
0000097

```

# Another answer without using gzinflate (228 bytes):

Reads shorts (16 bits), extracts 3 5-bit integers as indices of a lookup table.

```
<?$a=str_split(" .Yes,AlyouthrajimngSw'pP?
")+[27=>"I'm ",'Slim ',@Shady,'the real ','lease stand up'];$b=unpack(@v26,'o…~:tç       (ƒ-4€t£9ê`0BË-SBT $2U`Y{ÿXg |ác');foreach($b as$c)echo$a[$c>>10],$a[$c>>5&31],$a[$c&31];

```

hexdump:

```
0000000 3f3c 6124 733d 7274 735f 6c70 7469 2228
0000010 2e20 6559 2c73 6c41 6f79 7475 7268 6a61
0000020 6d69 676e 7753 7027 3f50 220a 2b29 325b
0000030 3d37 223e 2749 206d 2c22 5327 696c 206d
0000040 2c27 5340 6168 7964 272c 6874 2065 6572
0000050 6c61 2720 272c 656c 7361 2065 7473 6e61
0000060 2064 7075 5d27 243b 3d62 6e75 6170 6b63
0000070 4028 3276 2c36 9d27 026f 8504 7e0c 3a03
0000080 e774 0918 0901 8328 1c2d 8034 a374 ea39
0000090 6001 3011 cb42 532d 5442 a007 3224 6055
00000a0 9d59 ff7b 5802 2067 e17c 2763 3b29 6f66
00000b0 6572 6361 2868 6224 6120 2473 2963 6365
00000c0 6f68 6124 245b 3e63 313e 5d30 242c 5b61
00000d0 6324 3e3e 2635 3133 2c5d 6124 245b 2663
00000e0 3133 3b5d
00000e4

```
> 5 votes

# Answer
# C, 374

By moving memory

Not the shortest but can it get any faster?

```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *s;
void m (int d, int f, int p)
{
    memmove (s+p+f, s+p, strlen(s)-p+1); // Shift a part of the string to make room for our insertion
    memcpy (s+p, s+d, f); // Copy the desired reference in place
}
int main ()
{
    s = malloc (168);
    strcpy (s,"I'm Slim Shady. Yes, the real.\nAll you others are just imitating.\nSo, won't the please stand up?\nP. ");

    m (0, 4, 21);
    m (8, 6, 33);
    m (3, 11, 54);
    m (28, 5, 100);
    m (3, 11, 105);
    m (118, 14, 135);
    m (134, 16, 151);
    puts (s);
}

```

It's 374 chars long after minification.

```
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char*s;void m(int d,int f,int p){memmove(s+p+f,s+p,strlen(s)-p+1);memcpy(s+p,s+d,f);}int main(){s=malloc(168);strcpy(s,"I'm Slim Shady. Yes, the real.\nAll you others are just imitating.\nSo, won't the please stand up?\nP. ");m(0,4,21);m(8,6,33);m(3,11,54);m(28,5,100);m(3,11,105);m(118,14,135);m(134,16,151);puts(s);}

```
> 5 votes

# Answer
# Java, 247

My first code golf, while learning Java. Posted it because it beats the other (fully functional) Java entry and the Haskell entry.

```
class S{public static void main(String[]a){String s="I'm",t=" Slim",u=" Shady",v=" the real",w="lease stand up";System.out.print(s+t+u+". Yes, "+s+v+u+".\nAll you other"+t+u+"s are just imitating.\nSo, won't"+v+t+u+" p"+w+"?\nP"+w+". P"+w+".");}}

```
> 5 votes

# Answer
# PowerShell ~~194~~ ~~189~~ 164

```
"{0}{1}{2}. Yes, {0}{3}{2}.`nAll you other {1}{2}s are just imitating.`nSo, won't {3}{1}{2} p{4}?`nP{4}. P{4}."-f"I'm ","Slim ","Shady","the real ","lease stand up"

```

Somehow my answer ened up resembling @nneonneo's a lot, even though it wasn't my original intent...
> 4 votes

# Answer
# Lua ~~201~~ ~~193~~ ~~188~~ 178

```
h=" Shady"i="I'm"s=" Slim"..h r=" the real"u="lease stand up"io.write(i,s,". Yes, ",i,r,h,".\nAll you other",s,"s are just imitating.\nSo, won't",r,s," p",u,"?\nP",u,". P",u,".")

```

Ungolfed & expanded some

```
h=" Shady"
i="I'm"
s=" Slim"..h
r=" the real"
u="lease stand up"
io.write(i,s,". Yes, ",i,r,h,".\nAll you other",s,"s are just imitating.\nSo, won't",r,s," p",u,"?\nP",u,". P",u,".")

```
> 3 votes

# Answer
**PYTHON: ~~198~~ 193 bytes**

```
i,s,h,r,t="I'm ","Slim ","Shady","real ","lease stand up"
print i+s+h+". Yes, "+i+"the "+r+h+".\nAll you other "+s+h+"s are just imitating.\nSo, won't the "+r+s+h+" p"+t+"?\n"+"P"+t+'. P'+t+'.'

```
> 3 votes

# Answer
# PHP - 196 171

```
<?$S="Shady";$P="lease stand up";$R="the real ";$I="I'm ";$s="Slim ";echo"$I$s$S. Yes, $I$R$S
All you other $s$S"."s are just imitating.
So, won't $R$s$S p$P?
P$P. P$P."

```

;
> 3 votes

# Answer
# Perl, 161 ~~164~~ bytes

Not quite as short as squeamish ossifrage's answer, but I wanted to share the CamelCaseCompression, which no one else has used and allows the removal of many spaces and quotation marks.

It does need a slightly longer text to become truly beneficial, though.

```
$_="0 1 2. Yes, 03 2.
AllYouOther 1 2sAreJustImitating.
So, won't3 1 24?
4. 4.";s/\d/qw(I'm Slim Shady TheReal PleaseStandUp)[$&]/ge;s/\B([A-Z])/ \L\2/g;print

```

Edit: Following Thaylon's suggestion, the `s/(\S)([A-Z])/\1 \L\2/g` substitution has been shortened by four characters. That doesn't pick up on comma-capital digraphs, though, so an extra space had to be inserted before "won't".
> 3 votes

# Answer
# Common Lisp, 197

```
(let((a"I'm ")(b"Slim ")(c"Shady")(d"real ")(e"lease stand up"))(format t"~{~A~}"(list a b c". Yes, "a"the "d c".
All you other "b c"s are just imitating.
So, won't the "d b c" p"e"?
P"e". P"e"")))

```
> 3 votes

# Answer
## Golfscript - 140 (tweetable)

```
"I'm"" Slim"" Shady"". Yes, "3$" the real"3$".
All you other"6$2$"s are just imitating.
So won't"5$3$3$" p""lease stand up""?
P"1$". P"1$"."

```

I'm Slim Shady. Yes, 3 the real 3.

All you other 62s are just imitating.

So won't 533 please stand up?

P1. P1.
> 3 votes

# Answer
# ///, 131 bytes

```
/0/ Shady//1/lease stand up//2/ the real//3/ Slim0//4/I'm/43. Yes, 420.
All you other3s are just imitating.
So, won't23 p1?
P1. P1.

```

Try it online!
> 3 votes

# Answer
# Rust (full program), ~~183~~ ~~180~~ ~~178~~ ~~173~~ 172 bytes

*178 -\> 173 bytes, thanks to Sara J*

```
fn main(){print!("{}{}{}. Yes, {0}{}{2}.
All you other{1}{2}s are just imitating.
So, won't{3}{1}{2} p{}?
P{4}. P{4}.","I'm"," Slim"," Shady"," the real","lease stand up")}

```

Try it online!
> 3 votes

# Answer
# Java, ~~308~~ ~~301~~ ~~298~~ ~~292~~ 258

Java is a bit verbose, but here is my try:

```
class P{public static void main(String[]c){String s=" Shady",t=" the real",l="lease stand up",i=" Slim",m="I'm";System.out.format("%s%s%s. Yes, %s%s%s.\nAll you other%s%ss are just imitating.\nSo, won't%s%s%s p%s?\nP%s. P%s.",m,i,s,m,t,s,i,s,t,i,s,l,l,l);}}

```
> 2 votes

# Answer
# C# 226

```
class P{static void Main(){System.Console.Write("{0}{1}{2}. Yes, {0} the{3} {2}.All you other{1}{2}s are just imitating.So, won't the{3}{1}{2} please{4}up?Please{4}up. Please{4}up.","I'm"," Slim ","Shady"," real"," stand ");}}

```
> 2 votes

# Answer
**MySQL: 273 267**

```
set @i="I'm", @s="Slim", @h="Shady", @r="real", @t="stand", @p="lease stand up";select concat(@i," ",@s," ",@h,". Yes, ",@i," the ",@r," ",@h,".\r\nAll you other ",@s," ",@h,"s are just imitating.\r\nSo, won't the ",@r," ",@s," ",@h," p",@p,"?\r\nP",@p,". P",@p,".");

```
> 2 votes

# Answer
# Ruby: 211

This one is impressive since simply printing the text is more efficient, but this is way cooler.

```
puts Zlib.inflate("eJxdjDEKwzAQBHu9Yjs3Rl8ILt0FVKU88GErnCWhO2H8e6sIwUmzxQyz87AjSOyz0XJ6vFhHzB3axqhM8hFuEsGZG3IX9ZYoqDLeTQ1xj0YW0+pdyCOOnAa7/XwTFGFShhqlBa083PMXePyDC15NOP8=".unpack("m0")[0])#I'mSlimShadyrealstand

```
> 2 votes

# Answer
# F#, 250 242

```
[1..21]|>List.iter((function|1|5->"I'm "|2|9|13->"Slim "|4->". Yes, "|6|12->"the real "|8->".\nAll you other "|11->"s are just imitating.\nSo won't "|15->" p"|16|18|20-> "lease stand up"|17->"?\nP"|19->". P"|21->"."|_->"Shady")>>printf "%s")

```

More readable version with line breaks:

```
[1..21]|>List.iter((function
|1|5->"I'm "
|2|9|13->"Slim "
|4->". Yes, "
|6|12->"the real "
|8->".\nAll you other "
|11->"s are just imitating.\nSo won't "
|15->" p"
|16|18|20-> "lease stand up"
|17->"?\nP"
|19->". P"
|21->"."
|_->"Shady")>>printf "%s")

```
> 2 votes

# Answer
# JavaScript ~~259~~ ~~240~~ 238 bytes

Not that good but might as well post an answer.

```
b=String.prototype,b.a=b.replace,alert("123. Yes, 16537All you other 23s are just imitating7So, won't 6523 p4?\nP4. P4.".a(/1/g,"I'm ").a(/2/g,"Slim ").a(/3/g,"Shady").a(/4/g,"lease stand up").a(/5/g,"real ").a(/6/g,"the ").a(/7/g,".\n"))

```

More readable version :

```
b=String.prototype
b.a=b.replace
alert("123. Yes, 16537All you other 23s are just imitating7So, won't 6523 p4?\nP4. P4."
    .a(/1/g,"I'm ")
    .a(/2/g,"Slim ")
    .a(/3/g,"Shady")
    .a(/4/g,"lease stand up")
    .a(/5/g,"real ")
    .a(/6/g,"the ")
    .a(/7/g,".\n")
    )

```
> 2 votes

# Answer
# PHP, 179 Bytes

```
<?
$i="I'm";
$s=" Slim";
$h=" Shady";
$p="lease stand up";
$r=" the real";
echo"$i$s$h. Yes, $i$r$h.\nAll you other$s$h"."s are just imitating.\nSo, won't$r$s$h p$p?\nP$p. P$p.";

```

And golfed

```
<?$i="I'm";$s=" Slim";$h=" Shady";$p="lease stand up";$r=" the real";echo"$i$s$h. Yes, $i$r$h.\nAll you other$s$h"."s are just imitating.\nSo, won't$r$s$h p$p?\nP$p. P$p.";

```
> 2 votes

# Answer
# JavaScript (ES6), ~~165~~ 163 bytes

```
f=

_=>`${a="I'm"}${b=` Slim${c=` Shady`}`}. Yes, ${a+(d=" the real")+c}.
All you other${b}s are just imitating.
So, won't${d+b} p${e="lease stand up"}?
P${e}. P${e}.`

console.log(f());
```
> 2 votes

# Answer
# Matlab 206 bytes

```
i='I''m ';s='Slim ';h='Shady';r=' real ';t=' stand ';p=['Please' t 'up. '];sprintf([i s h '. Yes, ' i 'the' r h '.\nAll you other ' s h 's are just imitating.\nSo, won''t the' r s h ' please' t 'up?.\n' p p])

```
> 1 votes

# Answer
# F#, 197 bytes

```
printf"%A"<|System.String.Format("{0}{1}{2}. Yes, {0}{3}{2}.\nAll you other {1}{2}s are just imitating.\nSo, won't {3}{1}{2} p{4}?\nP{4}. P{4}.","I'm ","Slim ","Shady","the real ","lease stand up")

```

# F#, 210 bytes (alternate method)

```
let a,b,c,d,e="I'm ","Slim ","Shady","the real ","lease stand up"
printf"%s"<|a+b+c+". Yes, "+a+d+c+".\nAll you other "+b+c+"s are just imitating.\nSo, won't "+d+b+c+" p"+e+"?\nP"+e+". P"+e+"."

```
> 1 votes

# Answer
# Java - 204

**Ungolfed**:

```
String i = "I'm", s = " Slim", h = " Shady", r = " the real", t = "lease stand up";
System.out.printf(i + s + h + ". Yes, " + i + r + h + ".%n"
        + "All you other " + s + h + "s are just imitating.%n"
        + "So, won't" + r + h + " p" + t + "?%n"
        + "P" + t + ". P" + t + ".");

```

**Golfed**:

```
String i="I'm",s=" Slim",h = " Shady",r =" the real",t="lease stand up";System.out.printf(i+s+h+". Yes, "+i+r+h+".%nAll you other"+s+h+"s are just imitating.%nSo, won't"+r+h+" p"+t+"?%nP"+t+". P"+t+".");

```
> 1 votes

# Answer
# Haskell, ~~250~~ 221 bytes

Hell it beats the java version, so I'm posting. Is this really as good as it gets, or is there some secret function or monad or something that would make this task easier to complete succinctly?

**Edit**: I used `intercalcate " "` instead of `unwords`...

```
putStr$let i="I'm";s="Slim";h="Shady";r="the real";p="lease stand up";d=".";n='\n';in unwords[i,s,h++d,"Yes,",i,r,h++d,n:"All you other",s,h++"s","are just imitating"++d,n:"So, won't",r,s,h,'p':p++"?",n:'P':p++d,'P':p++d]

```
> 1 votes

# Answer
## Dart - 178 characters

Plain string interpolation and variables.

```
main({i:"I'm ",r:"the real ",s:"Slim ",z:"Shady",t:"lease stand up"}){print("$i$s$z. Yes, $i$r$z.\nAll you other $s${z}s are just imitating.\nSo, won't $r$s$z p$t?\nP$t. P$t.");}

```

Fiddling with whitespace can get it down to 176:

```
main({i:"I'm",r:" the real",s:" Slim",z:" Shady",t:"lease stand up"}){print("$i$s$z. Yes, $i$r$z.\nAll you other$s${z}s are just imitating.\nSo, won't$r$s$z p$t?\nP$t. P$t.");}

```
> 1 votes

# Answer
## Clojure - 255 chars

Simple solution from a Clojure newbie. Golfed:

```
(defn p[f & x](println(apply format f x)))(let[i "I'm" s "Shady" l "Slim" e "lease stand up" r "the real"](p "%s %s %s. Yes, %s %s %s." i l s i r s)(p "All you other %s %ss are just imitating." l s)(p "So, won't %s %s %s p%s?" r l s e)(p "P%s. P%s." e e))

```

Ungolfed:

```
(defn p [f & x] (println (apply format f x)))
(let [i "I'm" s "Shady" l "Slim" e "lease stand up" r "the real"]
    (p "%s %s %s. Yes, %s %s %s." i l s i r s)
    (p "All you other %s %ss are just imitating." l s)
    (p "So, won't %s %s %s p%s?" r l s e)
    (p "P%s. P%s." e e))

```
> 1 votes

# Answer
# Javascript, 191

Pretty basic attempt:

```
alert((a="I'm")+(b=" Slim")+(c=" Shady")+". Yes, "+a+" the "+(d="real")+c+".\nAll you other"+b+c+"s are just imitating.\nSo, won't the "+d+b+c+" p"+(e="lease stand up")+"?\nP"+e+". P"+e+".");

```
> 1 votes

# Answer
# VBA, 165

Paste directly in the intermediate pane.

```
i="I'm":s=" Slim Shady":r=" the real":p="lease stand up":?i+s". Yes, "i+r+mid(s,6)".":?"All you other"s"s are just imitating.":?"So, won't"r+s" p"p"?":?"P"p". P"p"."

```

Major golfing comes from the quirky properties of VBA's intermediate pane's ? command. You can place a string variable followed immediately by a string literal and they will concatenate with no spaces.
> 1 votes

# Answer
# Pure bash, 156 bytes

Nothing especially exciting here:

```
f()(echo "$1$2$3. Yes, $1$4$3.
All you other $2$3s are just imitating.
So, won't $4$2$3 ${5,}?
$5. $5.")
f "I'm " Slim\  Shady "the real " "Please stand up"

```
> 1 votes

# Answer
# C (gcc), ~~186~~ 181 bytes

-5 bytes thanks to ceilingcat.

```
f(){char*a=" Slim Shady",*c="I'm the real";printf("%.3s%s. Yes, %s%s.\nAll you other%ss are just imitating.\nSo, won't%s%s p%s?\nP%8$s. P%8$s.",c,a,c,a+5,a,c+3,a,"lease stand up");}

```

Try it online!
> 1 votes

# Answer
# Python 3.6, 166 bytes

```
a,b,c,d="I'm","Slim Shady","the real","lease stand up"
print(a,b+". Yes,",a,c,b[5:]+".\nAll you other",b+"s are just imitating.\nSo, won't",c,b,f"p{d}?\nP{d}. P{d}.")

```

Try it online!
> 1 votes

# Answer
# Stax, ~~116~~ ~~115~~ ~~112~~ 97 bytes

```
═Φ-cgvUV;Mc╔&♠◘Aτö,↔↕■∙o→¬▬⌡♪╓B▒ε,æO5≤,╝2Æ;╗)▀ìc)E]«╬ôÅ∩╖╚d:☻╔╩2Ñs*çφIBë╕gpÜI'mSlimShadyrealstand

```

Run and debug it

*All credit to this answer to Khuldraeseth na'Barya. I originally had a solution, but it's been completely re-written with none of the original now.*

Stax programs have two representations. Pure ASCII and "packed". Packed stax uses all 256 byte values, and thus is smaller than ASCII, which uses only 95. This solution is particularly clever because it's packed code that contains the required words. When unpacked, the `I'mSlimShadyrealstand` roughly becomes `"j|ksRfwb)ys\\GP*vOyn@[<a\\"d` which is a no-op. The rest of the program is pretty straight-forward compressed string literals.
> 1 votes

# Answer
# , ~~168~~ 160 bytes

-8 bytes thanks to Giuseppe

```
`[`=gsub;cat(1["I'm",2[" Slim ",3["Shady",4[" the real",5["lease stand up","123. Yes, 14 3.
All you other23s are just imitating.
So, won't423 p5?
P5. P5."]]]]])

```

Try it online!
> 1 votes

# Answer
# Zsh, 154 bytes

```
set "I'm" Slim Shady real stand
<<.
$1${6= $2 $3}. Yes, $1 the $4 $5.
All you other$6s are just imitating.
So, won't the $4$6 p${x=lease $5 up}?
P$x. P$x.

```

Attempt This Online!
> 1 votes

# Answer
## Groovy - 196 chars

Pretty basic solution:

```
i="I'm"
s="Shady"
l="Slim"
p="lease stand up"
q="P$p."
r="the real"
f={println it}
f "$i $l $s. Yes, $i $r $s."
f "All you other $l ${s}s are just imitating."
f "So, won't $r $l $s p$p?"
f "$q $q"

```
> 0 votes

# Answer
## Python: 175

Just a small change to the answer by **nneonneo**, but i can't comment and there don't seem to be private messages on this website so i'll post it this way.

```
a="Slim Shady"
print"{0}{1}. Yes, {0}{3}{2}.\nAll you other {1}s are just imitating.\nSo, won't {3}{1} p{4}?\nP{4}. P{4}.".format("I'm ",a,a[5:],"the real ","lease stand up")

```
> 0 votes

# Answer
## FASM 212 bytes

```
z fix equ
A z "I'm "
C z "Shady"
D z "the real "
E z "Slim ",C
F z "Please stand up"
N=$A
L z ". "
display A,E,L,"Yes, ",A,D,C,L,N,"All you other ",E,"s are just imitating.",N,"So, won't ",D,E," ",F,"?",N,F,L,F,L

```
> 0 votes

# Answer
# Extended BrainFuck \- 195

```
{S~&I'm&}{I~& Slim&&M}{M~& Shady&}{P~& the real&}{L~&Please&&E~&.&}{E~& stand up&}>&S&I~&. Yes, &&S&P&M~&.
All you other&&I~&s are just imitating.
So, won't&&P&I~& please&&E~&?
&&L~& &&L<[<]>[.>]

```

Everything pure BF is BF. `{name ...}` is a macro, `&name` applies macro and `~"string"` stores string in current position.`"` can be any char so I choose `&` to obfuscate it a little.
> 0 votes

# Answer
# PHP: 176

Thought I might as well give it a shot, nothing fancy though

```
$b="I'm ";$c="Slim";$d="Shady";$e="$c $d";$f="the real ";$g="lease stand up";echo"$b$e. Yes, $b$f$d.\nAll you other $e"."s are just imitating.\nSo, won't $f$e p$g?\nP$g. P$g.";

```
> 0 votes

# Answer
# Cobra - 188

```
class P
    def main
        s,p=" Slim Shady","lease stand up"
        l,p="I'm[s]. Yes, I'm the real[s[5:]].\nAll you other[s]s are just imitating.\nSo, won't the real[s] p[p]?\n","P[p]."
        print l+p,p

```
> 0 votes

# Answer
## JavaScript - ~~196~~ 182

```
s="I'm ",l="Slim Shady",m="the real ",r="lease stand up";alert(s+l+". Yes, "+s+m+l.slice(5)+".\nAll you other "+l+"s are just imitating.\nSo, won't "+m+l+" p"+r+"?\nP"+r+". P"+r+".")

```

If you want a explanation, just comment.
> 0 votes

# Answer
# Javascript 185

```
alert((i="I'm")+(s=" Slim"+(h=" Shady"))+". Yes, "+i+(r=" the real")+h+".\n"+"All you other "+s+"s are just imitating.\n"+"So, won't"+r+s+" p"+(p="lease stand up")+"?\n"+"P"+p+". P"+p+".")

```
> 0 votes

# Answer
# ///, ~~131~~ ~~132~~ 135 bytes

```
/!/lease stand up//#/ Shady//@/ Slim#//$/ real//%/I'm/%@. Yes, % the$#.
All you other@s are just imitating.
So, won't the$@ p!?
P!. P!.

```

Try it online!
> 0 votes

# Answer
## c, 214 byte

```
main(){char*k[]={"I'm ","Slim ","Shady","the real ","lease stand up"},*w="012. Yes, 032.\nAll you other 12s are just imitating.\nSo, won't 312 p4?\nP4. P4.",c;for(;*w;)c=*w++,c>47&&c<58?printf(k[c-48]):putchar(c);}

```

Try it online
> 0 votes

# Answer
# C, 220 bytes

```
char*s="I'm",*h="Slim",*a="Shady",*d="real",*y="lease stand up";f(){printf("%s %s %s. Yes, %s the %s %s.\nAll you other %s %ss are just imitating.\nSo, won't the %s %s %s p%s?\nP%s. P%s.",s,h,a,s,d,a,h,a,d,d,h,a,y,y,y);}

```

**Detailed** Live

```
#include <stdio.h>

char  *  s  =  "I'm"             ;
char  *  h  =  "Slim"            ;
char  *  a  =  "Shady"           ;
char  *  d  =  "real"            ;
char  *  y  =  "lease stand up"  ;

f(){printf("%s %s %s. Yes, %s the %s %s.\n\\
All you other %s %ss are just imitating.\n\\
So, won't the %s %s %s p%s?\nP%s. P%s.",

    s,
        h,
            a,
    s,
                d,
            a,
        h,
            a,
                d,
                d,
        h,
            a,
                    y,
                    y,
                    y

);}int main(){f();return 0;}

```
> 0 votes

# Answer
# VBA, 164 Bytes

Anonymous VBE immediate window function that take no input and outputs to the VBE immediate window.

```
l=" Slim Shady":i="I'm":r=" the real":t="lease stand up":?i;s". Yes, "i;r;Mid(s,6)".":?"All you other"s" are just imitating.":?"So, won't"r;s" p"t"?":?"P"t". P"t".

```
> 0 votes

# Answer
# PHP, 166 bytes:

```
<?=($i="I'm"),($l=" Slim".$s=" Shady"),". Yes, $i",($r="  the real"),"$s.
All you other${l}s are just imitating.
So, won't$r$l p",($p="lease stand up"),"?
P$p. P$p.";

```
> 0 votes

# Answer
# , ~~152~~ 151 bytes

```
echo(0 :0)rplc'12345';"0'\'cut' Slim\ Shady\lease stand up\ the real\I''m'
512. Yes, 542.
All you other12s are just imitating.
So, won't412 p3?
P3. P3.

```

Try it online!
> 0 votes

# Answer
# Java 8, 181 bytes (function)

```
v->"".format("%s%s%s. Yes, %1$s%s%3$s.%nAll you other %2$s%3$ss are just imitating.%nSo, won't %4$s%2$s%3$s p%s?%nP%5$s. P%5$s.","I'm ","Slim ","Shady","the real ","lease stand up")

```

Try it online.

# Java 8, 229 bytes (full program)

```
interface M{static void main(String[]a){System.out.printf("%s%s%s. Yes, %1$s%s%3$s.%nAll you other %2$s%3$ss are just imitating.%nSo, won't %4$s%2$s%3$s p%s?%nP%5$s. P%5$s.","I'm ","Slim ","Shady","the real ","lease stand up");}}

```

Try it online.
> 0 votes

# Answer
# ink, 177 bytes

```
VAR i="I'm"
~temp s=" Slim"+w
VAR w=" Shady"
VAR r=" the real"
VAR l="lease stand up"
{i+s}. Yes, {i+r+w}.
All you other{s}s are just imitating.
So, won't{r+s} p{l}?
P{l}. P{l}.

```

Try it online!
> 0 votes

# Answer
# C# .NET 211 + class stuff etc = 255 bytes

```
public class p{public static void Main(){System.Console.WriteLine(@"{0}{1}{2}. Yes, {0}the {3}{2}.
All you other {1}{2}s  are just imitating.
So, won't the {3}{1}{2} please {4}up?
Please {4}up. Please {4}up.","I'm ","Slim ","Shady","real ","stand ");}}

```

This is probably as {1} as it gets ;)
I just the @ string tag instead of \r\n because thats 1 byte instead of 12 (3 * \r\n)
EDIT: Didn't know you needed the full class so here
> 0 votes

# Answer
# 05AB1E, ~~124~~ 122 bytes

```
"real"“‚µ stand€¾“"Shady""Slim"…I'm)•AΘ¥в‚Y•Sè`“ÿ ÿ ÿ.…Ü, ÿ€€ ÿ ÿ.
All€î€¶ ÿ ÿs€™‚‰ imitating.
So,¢²'t€€ ÿ ÿ ÿ ÿ?
ÿ. ÿ.“.ª

```

Try it online or verify that it's correct.

**Explanation:**

```
"real"              # Push string "real"
“‚µ stand€¾“        # Push dictionary string "please stand up"
"Shady"             # Push string "Shady"
"Slim"              # Push string "Slim"
…I'm               '# Push string "I'm"
)                   # Wrap all strings on the stack into a list:
                    #  ["real","please stand up","Shady","Slim","I'm"]
 •AΘ¥в‚Y•           # Push compressed integer 11123023204234
         S          # Converted to a list of digits: [1,1,1,2,3,0,2,3,2,0,4,2,3,4]
          è         # Index each into the string-list:
                    #  ["please stand up","please stand up","please stand up","Shady","Slim",
                    #   "real","Shady","Slim","Shady","real","I'm","Shady","Slim","I'm"]
           `        # Pop and push these strings separated to the stack
“ÿ ÿ ÿ.…Ü, ÿ€€ ÿ ÿ. # Push dictionary string "ÿ ÿ ÿ. yes, ÿ the ÿ ÿ.\n
All€î€¶ ÿ ÿs€™‚‰ imitating.
                    #                         All you other ÿ ÿs are just imitating.\n
So,¢²'t€€ ÿ ÿ ÿ ÿ? '#                         So, won't the ÿ ÿ ÿ ÿ?\n
ÿ. ÿ.“              #                         ÿ. ÿ."
                    # where the `ÿ` are automatically filled with the strings of the stack
      .ª            # And sentence capitalize every sentence
                    # (without disturbing existing uppercase letters)
                    # (after which the result is output implicitly)

```

See this 05AB1E tip of mine (sections *How to use the dictionary?* and *How to compress large integers?*) to understand why `“‚µ stand€¾“` is `"please stand up"`; `•AΘ¥в‚Y•` is `11123023204234`; and `“ÿ ÿ ÿ.…Ü, ÿ€€ ÿ ÿ.\nAll€î€¶ ÿ ÿs€™‚‰ imitating.\nSo,¢²'t€€ ÿ ÿ ÿ ÿ?\nÿ. ÿ.“` is `"ÿ ÿ ÿ. yes, ÿ the ÿ ÿ.\nAll you other ÿ ÿs are just imitating.\nSo, won't the ÿ ÿ ÿ ÿ?\nÿ. ÿ."`.
> 0 votes

---
Tags: code-golf, kolmogorov-complexity, restricted-source
---


title: Please do my Martian homework

text:
# Question
Title: Please do my Martian homework
My homework is to write a ***Martian essay*** (see below) between 729 and 810 words, inclusive. Your task is to write a program that will generate the essay.

## History

Around the turn of the 20th century, spiritualist Catherine-Elise Müller allegedly communicated with Martians. During somnambulatory trances, she would write out Martian scripts. Psychologist Théodore Flourney discovered her Martian writings were very similar to her native French, and in his book "From India to the Planet Mars", he documented Catherine's Martian alphabet.

The following is *loosely* based on that alphabet with an extended mythos.

## Problem Description

The Martian language has 21 letters, shown here next to each Latin equivalent:

Unfortunately, there's no Unicode for Martian (despite Mars being part of the universe), so we're stuck using Latin characters.

Whereas in English our phonemes break out into two major types (consonants/vowels) which we loosely map to letters, Martian has three letter types:

* The vowels: a e i m n o u
* The hard consonants: b c d g k p t
* The soft consonants: f h l r s v z

In addition to this, the Martian language contains a single punctuation mark--the period.

A **Martian word** is a set of 3 to 9 letters. All Martian words have at least one vowel, one hard consonant, and one soft consonant (in any arrangement). For example, `fng`, `cdaz`, `vpi`, and `pascal` are Martian words.

A **Martian sentence** is a set of 3 to 9 Martian words delimited by spaces and followed by a period.

A **Martian paragraph** is a set of 3 to 9 Martian sentences delimited by spaces and followed by a newline.

A **Martian essay** is a collection of Martian paragraphs that contains no contiguous word repetitions.

A **contiguous word repetition** is any construct S S where S is a contiguous set of words. Note that this definition ignores sentence and paragraph boundaries.

### Examples

*Please note: There's a single trailing newline following each example (since all Martian paragraphs end in a newline)*

***Not Martian essay***

```
lorem ipsum dolor sit amet. quis nostrud exercitation ullamco laboris.

```

...for many reasons. This example is to illustrate some miscellaneous rules:

* lorem is not a Martian word because it has no hard consonants.
* amet is not a Martian word because it has no soft consonants. (`m` is a Martian vowel).
* quis is not a Martian word because it has no hard consonants
* quis is not a Martian word because q is not a Martian letter
* exercitation is not a Martian word because it has more than 9 letters
* exercitation is not a Martian word because x is not a Martian letter

***Martian essay***

```
fng cdaz vpi. pascal broke basic. popplers taste great.

```

...because it is a Martian paragraph. The Martian paragraph contains three Martian sentences.

***Not Martian essay***

```
fng cdaz vpi. pascal broke basic. free pascal rules.

```

...since `free pascal rules.` is not a Martian sentence, because neither `free` nor `rules` are Martian words, because they do not have any hard consonants.

***Martian essay***

```
fng cdaz vpi. pascal broke basic. popplers taste great.
cdaz vpi fng. basic breaks pascal. popplers punch hard. fng cdaz vpi.

```

...which contains two Martian paragraphs. The sentence `fng cdaz vpi.` appears twice, but that's perfectly fine.

***Not Martian essay***

```
popplers taste fng. cdaz vpi pascal. broke fng cdaz vpi.
pascal broke omicron planets. basic scares goats. vpi piv vpi.

```

...because the construct `fng. cdaz vpi pascal. broke fng cdaz vpi. [nl] pascal broke` is a contiguous word repetition.

# Challenge

Your challenge is to write a function or program that accepts no input, which produces as its output my homework; that is, your program should generate a **Martian essay** between 729 and 810 words (inclusive). Keep in mind, your program's output must be a valid Martian essay, but you don't have to generate it randomly or different each time. *Anything you do to generate a valid Martian essay* counts.

I've written a C++ program to check essays that you're allowed to use.

This is code golf. Shortest code in bytes wins. Standard loopholes disallowed.

# Answer
> 2 votes
# Husk, ~~19~~ 18 bytes

```
↑9C9mo`:'.wC9P…"ag

```

Try it online!

729 words, using the same idea as the 05AB1E answer.

-1 byte from Dominic Van Essen.

# Answer
> 30 votes
# Jelly, ~~28 26 25 24~~ 23 bytes

-1 byte thanks to carusocomputing (replace the word `thimble` with `abcdefg`)

```
9ØaḣŒ!s²ḣµs9K€;€”.K;⁷µ€

```

**TryItOnline!**

### How?

Makes a list of all `362880` permutations of the first ~~seven~~ nine letters of the English alphabet `abcdefghi`, which all have the properties of Martian words and are all distinct, and formats them into an essay using the first `729` words.

```
9ØaḣŒ!s²ḣµs9K€;€”.K;⁷µ€ - Main link: no arguments
9                       - 9 as x
         µ              - monadic chain separation
 Øa                     - yield lowercase alphabet
   ḣ                    - head to x ("abcdefghi")
    Œ!                  - all permutations (362880 distinct Martian words)
       ²                - square x = 81
      s                 - split into chunks of length 81 (the paragraphs)
        ḣ               - head to x (get the first 9 paragraphs only)
                     µ€ - monadic chain for €ach (for each chunk:)
          s9            -     split into chunks of length 9 (the sentences)
            K€          -     join with spaces for €each (between words in each sentence)
              ;€        -     concatenate €ach with
                ”.      -         '.' (add a full stop* after each sentence)
                  K     -     join with spaces (add a space between the sentences)
                   ;    -     concatenate with
                    ⁷   -         a line feed
                        - implicit print

```

* period

# Answer
> 19 votes
# 05AB1E, ~~25~~ ~~24~~ ~~22~~ 20 bytes

*-2 bytes thanks to Emigna (Significant refactor, thanks man).*

```
A7£œJðý72ô€¨'.«9ô9£»

```

Try it online!

```
A7£                     # Push first 7 letters of the alphabet.
   œJðý                 # All 5040 permutations of "abcdefg" joined by spaces.
       72ô              # Split into pieces of 72 (Sentences).
          €             # For each piece...
           ¨'.«         # Lop of the last char and concat a period.
               9ô       # Split into pieces of 9 (paragraphs).
                 9£     # Take only the first 9 paragraphs.
                   »    # Join by newlines and implicitly print.

```

Turns out the 810 word version is shorter than the 729 word version.

**Output:**

```
abcdefg abcdegf abcdfeg abcdfge abcdgef abcdgfe abcedfg abcedgf abcefdg. abcefgd abcegdf abcegfd abcfdeg abcfdge abcfedg abcfegd abcfgde abcfged. abcgdef abcgdfe abcgedf abcgefd abcgfde abcgfed abdcefg abdcegf abdcfeg. abdcfge abdcgef abdcgfe abdecfg abdecgf abdefcg abdefgc abdegcf abdegfc. abdfceg abdfcge abdfecg abdfegc abdfgce abdfgec abdgcef abdgcfe abdgecf. abdgefc abdgfce abdgfec abecdfg abecdgf abecfdg abecfgd abecgdf abecgfd. abedcfg abedcgf abedfcg abedfgc abedgcf abedgfc abefcdg abefcgd abefdcg. abefdgc abefgcd abefgdc abegcdf abegcfd abegdcf abegdfc abegfcd abegfdc. abfcdeg abfcdge abfcedg abfcegd abfcgde abfcged abfdceg abfdcge abfdecg.
abfdegc abfdgce abfdgec abfecdg abfecgd abfedcg abfedgc abfegcd abfegdc. abfgcde abfgced abfgdce abfgdec abfgecd abfgedc abgcdef abgcdfe abgcedf. abgcefd abgcfde abgcfed abgdcef abgdcfe abgdecf abgdefc abgdfce abgdfec. abgecdf abgecfd abgedcf abgedfc abgefcd abgefdc abgfcde abgfced abgfdce. abgfdec abgfecd abgfedc acbdefg acbdegf acbdfeg acbdfge acbdgef acbdgfe. acbedfg acbedgf acbefdg acbefgd acbegdf acbegfd acbfdeg acbfdge acbfedg. acbfegd acbfgde acbfged acbgdef acbgdfe acbgedf acbgefd acbgfde acbgfed. acdbefg acdbegf acdbfeg acdbfge acdbgef acdbgfe acdebfg acdebgf acdefbg. acdefgb acdegbf acdegfb acdfbeg acdfbge acdfebg acdfegb acdfgbe acdfgeb.
acdgbef acdgbfe acdgebf acdgefb acdgfbe acdgfeb acebdfg acebdgf acebfdg. acebfgd acebgdf acebgfd acedbfg acedbgf acedfbg acedfgb acedgbf acedgfb. acefbdg acefbgd acefdbg acefdgb acefgbd acefgdb acegbdf acegbfd acegdbf. acegdfb acegfbd acegfdb acfbdeg acfbdge acfbedg acfbegd acfbgde acfbged. acfdbeg acfdbge acfdebg acfdegb acfdgbe acfdgeb acfebdg acfebgd acfedbg. acfedgb acfegbd acfegdb acfgbde acfgbed acfgdbe acfgdeb acfgebd acfgedb. acgbdef acgbdfe acgbedf acgbefd acgbfde acgbfed acgdbef acgdbfe acgdebf. acgdefb acgdfbe acgdfeb acgebdf acgebfd acgedbf acgedfb acgefbd acgefdb. acgfbde acgfbed acgfdbe acgfdeb acgfebd acgfedb adbcefg adbcegf adbcfeg.
adbcfge adbcgef adbcgfe adbecfg adbecgf adbefcg adbefgc adbegcf adbegfc. adbfceg adbfcge adbfecg adbfegc adbfgce adbfgec adbgcef adbgcfe adbgecf. adbgefc adbgfce adbgfec adcbefg adcbegf adcbfeg adcbfge adcbgef adcbgfe. adcebfg adcebgf adcefbg adcefgb adcegbf adcegfb adcfbeg adcfbge adcfebg. adcfegb adcfgbe adcfgeb adcgbef adcgbfe adcgebf adcgefb adcgfbe adcgfeb. adebcfg adebcgf adebfcg adebfgc adebgcf adebgfc adecbfg adecbgf adecfbg. adecfgb adecgbf adecgfb adefbcg adefbgc adefcbg adefcgb adefgbc adefgcb. adegbcf adegbfc adegcbf adegcfb adegfbc adegfcb adfbceg adfbcge adfbecg. adfbegc adfbgce adfbgec adfcbeg adfcbge adfcebg adfcegb adfcgbe adfcgeb.
adfebcg adfebgc adfecbg adfecgb adfegbc adfegcb adfgbce adfgbec adfgcbe. adfgceb adfgebc adfgecb adgbcef adgbcfe adgbecf adgbefc adgbfce adgbfec. adgcbef adgcbfe adgcebf adgcefb adgcfbe adgcfeb adgebcf adgebfc adgecbf. adgecfb adgefbc adgefcb adgfbce adgfbec adgfcbe adgfceb adgfebc adgfecb. aebcdfg aebcdgf aebcfdg aebcfgd aebcgdf aebcgfd aebdcfg aebdcgf aebdfcg. aebdfgc aebdgcf aebdgfc aebfcdg aebfcgd aebfdcg aebfdgc aebfgcd aebfgdc. aebgcdf aebgcfd aebgdcf aebgdfc aebgfcd aebgfdc aecbdfg aecbdgf aecbfdg. aecbfgd aecbgdf aecbgfd aecdbfg aecdbgf aecdfbg aecdfgb aecdgbf aecdgfb. aecfbdg aecfbgd aecfdbg aecfdgb aecfgbd aecfgdb aecgbdf aecgbfd aecgdbf.
aecgdfb aecgfbd aecgfdb aedbcfg aedbcgf aedbfcg aedbfgc aedbgcf aedbgfc. aedcbfg aedcbgf aedcfbg aedcfgb aedcgbf aedcgfb aedfbcg aedfbgc aedfcbg. aedfcgb aedfgbc aedfgcb aedgbcf aedgbfc aedgcbf aedgcfb aedgfbc aedgfcb. aefbcdg aefbcgd aefbdcg aefbdgc aefbgcd aefbgdc aefcbdg aefcbgd aefcdbg. aefcdgb aefcgbd aefcgdb aefdbcg aefdbgc aefdcbg aefdcgb aefdgbc aefdgcb. aefgbcd aefgbdc aefgcbd aefgcdb aefgdbc aefgdcb aegbcdf aegbcfd aegbdcf. aegbdfc aegbfcd aegbfdc aegcbdf aegcbfd aegcdbf aegcdfb aegcfbd aegcfdb. aegdbcf aegdbfc aegdcbf aegdcfb aegdfbc aegdfcb aegfbcd aegfbdc aegfcbd. aegfcdb aegfdbc aegfdcb afbcdeg afbcdge afbcedg afbcegd afbcgde afbcged.
afbdceg afbdcge afbdecg afbdegc afbdgce afbdgec afbecdg afbecgd afbedcg. afbedgc afbegcd afbegdc afbgcde afbgced afbgdce afbgdec afbgecd afbgedc. afcbdeg afcbdge afcbedg afcbegd afcbgde afcbged afcdbeg afcdbge afcdebg. afcdegb afcdgbe afcdgeb afcebdg afcebgd afcedbg afcedgb afcegbd afcegdb. afcgbde afcgbed afcgdbe afcgdeb afcgebd afcgedb afdbceg afdbcge afdbecg. afdbegc afdbgce afdbgec afdcbeg afdcbge afdcebg afdcegb afdcgbe afdcgeb. afdebcg afdebgc afdecbg afdecgb afdegbc afdegcb afdgbce afdgbec afdgcbe. afdgceb afdgebc afdgecb afebcdg afebcgd afebdcg afebdgc afebgcd afebgdc. afecbdg afecbgd afecdbg afecdgb afecgbd afecgdb afedbcg afedbgc afedcbg.
afedcgb afedgbc afedgcb afegbcd afegbdc afegcbd afegcdb afegdbc afegdcb. afgbcde afgbced afgbdce afgbdec afgbecd afgbedc afgcbde afgcbed afgcdbe. afgcdeb afgcebd afgcedb afgdbce afgdbec afgdcbe afgdceb afgdebc afgdecb. afgebcd afgebdc afgecbd afgecdb afgedbc afgedcb agbcdef agbcdfe agbcedf. agbcefd agbcfde agbcfed agbdcef agbdcfe agbdecf agbdefc agbdfce agbdfec. agbecdf agbecfd agbedcf agbedfc agbefcd agbefdc agbfcde agbfced agbfdce. agbfdec agbfecd agbfedc agcbdef agcbdfe agcbedf agcbefd agcbfde agcbfed. agcdbef agcdbfe agcdebf agcdefb agcdfbe agcdfeb agcebdf agcebfd agcedbf. agcedfb agcefbd agcefdb agcfbde agcfbed agcfdbe agcfdeb agcfebd agcfedb.
agdbcef agdbcfe agdbecf agdbefc agdbfce agdbfec agdcbef agdcbfe agdcebf. agdcefb agdcfbe agdcfeb agdebcf agdebfc agdecbf agdecfb agdefbc agdefcb. agdfbce agdfbec agdfcbe agdfceb agdfebc agdfecb agebcdf agebcfd agebdcf. agebdfc agebfcd agebfdc agecbdf agecbfd agecdbf agecdfb agecfbd agecfdb. agedbcf agedbfc agedcbf agedcfb agedfbc agedfcb agefbcd agefbdc agefcbd. agefcdb agefdbc agefdcb agfbcde agfbced agfbdce agfbdec agfbecd agfbedc. agfcbde agfcbed agfcdbe agfcdeb agfcebd agfcedb agfdbce agfdbec agfdcbe. agfdceb agfdebc agfdecb agfebcd agfebdc agfecbd agfecdb agfedbc agfedcb. bacdefg bacdegf bacdfeg bacdfge bacdgef bacdgfe bacedfg bacedgf bacefdg.

```

# Answer
> 11 votes
# Ruby, ~~86 83 82~~ 79 bytes

```
(8019..8747).map{|x|$><<x.to_s(3).tr('012','abf')+(x%9>7?".\n":x%3>1?". ":" ")}

```

The trick: print all numbers between 102000000 and 102222222 in base 3

# Answer
> 9 votes
# Python 3, ~~121 119~~ 114 bytes

-5 thanks to Jitse!

```
from itertools import*
i=729
while i:i-=1;print(*[*permutations('thimble')][i],sep='',end='.'[i%9:]+' \n'[i%81<1])

```

**Try it online!**

### How?

Counts down from `i=729` and gets a list of the letters of the ith permutation of `'thimble'` as the next distinct Martian word (`list(permutations('thimble'))[i]`).

Avoids `''.join(...)` by use of a `*expression` to unpack the list while changing the default separator for `print` from a space to the empty string (`sep=''`).

Uses the `end` argument of `print` to optionally add spaces, full stops and line feeds as required using modular arithmetic. A full stop goes after every ninth word (`'.'*(i%9<1)`) and a line feed goes after every eighty-first word, otherwise a space does, achieved by indexing into a two character string (`' \n'[i%81<1]`).

# Answer
> 9 votes
# Mathematica, 113 bytes

```
StringRiffle[(p=Partition)["ark"["bus","car"][[#]]&/@Differences@Array[ThueMorse,730],3]~p~3,n=".\n",". "," "]<>n

```

Unnamed function that produces a string as output; that string is a Martian essay where each sentence has three words and each paragraph has three sentences. (Its deterministic output is below.)

The core of the algorithm uses the cool mathematical fact that the differences of the Thue–Morse sequence form an infinite sequence of the three symbols –1, 0, and 1 that has no contiguous digit repetitions. `Differences@Array[ThueMorse,730]` generates that sequence, to length 729.

Then `"ark"["bus","car"][[#]]&/@` is applied to this sequence; this converts each 1 to "bus" (the first argument), each –1 to "car" (the last argument), and each 0 to "ark" (the function head). `(p=Partition)[...,3]~p~3` divides this sequence of words into nested lists, each consisting of three lists of three words each. Finally, `StringRiffle[...,n=".\n",". "," "]` concatenates all the words together, with different separators depending on the list levels; and `<>n` appends the final period and newline.

The output sure doesn't look repetition-free....

```
ark car bus. car ark bus. ark car ark.
bus car bus. ark car bus. car ark bus.
car bus ark. car ark bus. ark car bus.
car ark bus. ark car ark. bus car bus.
ark car ark. bus ark car. bus car ark.
bus car bus. ark car bus. car ark bus.
ark car ark. bus car bus. ark car bus.
car ark bus. car bus ark. car ark bus.
ark car bus. car ark bus. car bus ark.
car bus car. ark bus ark. car ark bus.
car bus ark. car ark bus. ark car bus.
car ark bus. ark car ark. bus car bus.
ark car bus. car ark bus. car bus ark.
car ark bus. ark car bus. car ark bus.
ark car ark. bus car bus. ark car ark.
bus ark car. bus car ark. bus car bus.
ark car bus. car ark bus. ark car ark.
bus car bus. ark car ark. bus ark car.
bus car ark. bus ark car. ark bus car.
bus ark car. bus car ark. bus car bus.
ark car ark. bus ark car. bus car ark.
bus car bus. ark car bus. car ark bus.
ark car ark. bus car bus. ark car bus.
car ark bus. car bus ark. car ark bus.
ark car bus. car ark bus. ark car ark.
bus car bus. ark car ark. bus ark car.
bus car ark. bus car bus. ark car bus.
car ark bus. ark car ark. bus car bus.
ark car bus. car ark bus. car bus ark.
car ark bus. ark car bus. car ark bus.
car bus ark. car bus car. ark bus ark.
car ark bus. car bus ark. car ark bus.
ark car bus. car ark bus. ark car ark.
bus car bus. ark car bus. car ark bus.
car bus ark. car ark bus. ark car bus.
car ark bus. car bus ark. car bus car.
ark bus ark. car ark bus. car bus ark.
car bus car. ark bus car. bus ark car.
ark bus ark. car bus car. ark bus ark.
car ark bus. car bus ark. car ark bus.
ark car bus. car ark bus. car bus ark.
car bus car. ark bus ark. car ark bus.
car bus ark. car ark bus. ark car bus.
car ark bus. ark car ark. bus car bus.
ark car bus. car ark bus. car bus ark.
car ark bus. ark car bus. car ark bus.
ark car ark. bus car bus. ark car ark.
bus ark car. bus car ark. bus car bus.
ark car bus. car ark bus. ark car ark.
bus car bus. ark car bus. car ark bus.
car bus ark. car ark bus. ark car bus.
car ark bus. car bus ark. car bus car.
ark bus ark. car ark bus. car bus ark.
car ark bus. ark car bus. car ark bus.
ark car ark. bus car bus. ark car bus.
car ark bus. car bus ark. car ark bus.
ark car bus. car ark bus. ark car ark.
bus car bus. ark car ark. bus ark car.
bus car ark. bus car bus. ark car bus.
car ark bus. ark car ark. bus car bus.
ark car ark. bus ark car. bus car ark.
bus ark car. ark bus car. bus ark car.
bus car ark. bus car bus. ark car ark.
bus ark car. bus car ark. bus car bus.
ark car bus. car ark bus. ark car ark.
bus car bus. ark car bus. car ark bus.
car bus ark. car ark bus. ark car bus.
car ark bus. ark car ark. bus car bus.
ark car ark. bus ark car. bus car ark.
bus car bus. ark car bus. car ark bus.
ark car ark. bus car bus. ark car ark.
bus ark car. bus car ark. bus ark car.
ark bus car. bus ark car. bus car ark.
bus car bus. ark car ark. bus ark car.
bus car ark. bus ark car. ark bus car.
bus ark car. ark bus ark. car bus car.
ark bus car. bus ark car. bus car ark.
bus ark car. ark bus car. bus ark car.
bus car ark. bus car bus. ark car ark.
bus ark car. bus car ark. bus car bus.
ark car bus. car ark bus. ark car ark.

```

# Mathematica, 100 bytes

```
StringRiffle[(p=Partition)[Permutations@Characters@"thimble"~Take~729,9]~p~9,n=".\n",". "," ",""]<>n

```

A direct port of Jonathan Allen's Jelly algorithm.

# Answer
> 4 votes
## JavaScript (ES6), 130 bytes

This essay contains 774 Martian words, from a dictionary of 308 distinct words, made of all Martian letters.

```
_=>[...Array(2322)].map((_,i)=>['aeimnou','bcdgkpt','fhlrsvz'][i%3][(z=z*71%1e9)%7]+(++i%3?'':i%9?' ':i%27?'. ':`.
`),z=1).join``

```

Letters are picked in a pseudo-random manner, using the following formula:

```
(71^n mod 1000000000) mod 7

```

Where `71` is the smallest prime \[1\] for which no contiguous word repetition appear with this modulo.

```
let f =

_=>[...Array(2322)].map((_,i)=>['aeimnou','bcdgkpt','fhlrsvz'][i%3][(z=z*71%1e9)%7]+(++i%3?'':i%9?' ':i%27?'. ':`.
`),z=1).join``

console.log(f());
```

---

*\[1\] I only tested primes at the time I wrote this code. The smallest non-prime candidate is `56`.*

# Answer
> 4 votes
# PHP, 86 bytes

```
for(;$i<729;$$s="")echo${$s=str_shuffle(abcdefg)}??$s.(++$i%3?"":".").($i%9?" ":"\n");

```

Generates a randomised 729 word essay that repeats no words.
Use like:

```
php -r 'for(;$i<729;$$s="")echo${$s=str_shuffle(abcdefg)}??$s.(++$i%3?"":".").($i%9?" ":"\n");'

```

Explanation:

```
for(;$i<729;                                      # until we've generated 729 words
  $$s="")                                         # assign a blank string to the variable for the previous word
    echo ${$s=str_shuffle(abcdefg)}??             # generate a random word and if the variable for it has been assigned echo that variable (a blank string)
         $s.(++$i%3?"":".").($i%9?" ":"\n");      # otherwise echo the string and punctuation based on the word number (which is incremented here)

```

# Answer
> 4 votes
# ///, 95 bytes

```
/_/abf//-/_ _a _e _i _m _n _o _u _aa.//'/- b- c- d- g- j- p- t- bb-/'
f'
h'
l'
r'
s'
v'
z'
ff'

```

*(additional new line at the end, not visible here)*

**Try it online!**

**Essay:**

```
abf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
fabf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
habf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
labf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
rabf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
sabf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
vabf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
zabf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
ffabf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.

```

# Answer
> 3 votes
# Python 3, ~~404~~ ~~270~~ ~~332~~ ~~339~~ ~~285~~ ~~266~~ 259 bytes

This is an attempt to create a random Martian essay my randomly sampling the Martian alphabet and checking afterwards which words work.

**Edit:** -10 bytes from Zachary T's suggestion to use `R=range`. -9 bytes from changing `.intersection(w)` to `&set(w)`. -7 bytes from changing `A[random.randrange(21)]` to `random.choice(A)`.

```
import random
W=[];A="abfechidlmgrnksopvutz";R=range
while len(W)<729:W+=[''.join(random.choice(A)for j in R(9))for i in R(729)];W=[*set(w for w in W if all(set(A[z::3])&set(w)for z in R(3)))]
for j in R(9):print(" ".join(W[81*j+i]+"."*(i%9>7)for i in R(81)))

```

**Ungolfing**

```
import random
word_list = []
alphabet = "abfechidlmgrnksopvutz"
while len(word_list) < 729:
    # generates words
    for i in range(729):
        word = ""
        for j in range(9):
            word += alphabet[random.randrange(21)]
        word_list.append(word)
    # removes invalid words that don't have at least one letter of each letter type
    kept_words = []
    for word in word_list:
        all_letter_types = [0, 0, 0]
        for z in range(3):
            all_letter_types[z] = set(alphabet[z::3]) & set(word)
        if all(all_letter_types):
            kept_words.append(word)
    word_list = kept_words[:]
    # removes any contiguous word repetitions by removing all repeated words
    word_list = list(set(word_list))
# attaches punctuation and prints
for j in range(9):
    result = []
    for i in range(81):
        word = word_list[81*j+i]
        if i%9 == 8:
            word += "."
    print(" ".join(result))

```

# Answer
> 2 votes
# Zsh `-P`, 51 bytes

```
x=(a e i m n o u)
echo $x{f,h,l,r,s}$x{b,d,g.}|fold

```

Attempt This Online!

The output has some trailing spaces, which I think are normally allowed, but if not, this can be fixed by adding `|cut -c-79` (+10 bytes).

## Explanation

The basic idea is to generate a number of unique Martian words, then group them into sentences and paragraphs.

I used 4-letter words of the format `vsvh` (vowel, soft consonant, vowel, hard consonant), because it makes it possible to get enough words using just one cartesian product. (This is what the `{,,,}` expansions do; the `-P` option to Zsh also enables that multiplying behaviour for array variables, allowing us to reuse `$x`).

There are enough unique 3-letter words to meet the word count, but they would require multiple separate expansions - one single format (e.g. `vsh`) can only produce \\$ 7^3 = 343 \\$ words. This would take too many extra bytes.

Then, by adding a `.` to one of the letters, we can ensure there are regular sentence breaks - here, it's every time `g` comes around in the cartesian product.

Finally, piping this all to `fold` inserts line breaks, to keep the paragraphs under 10 sentences each.

The fact that this all works, and can be so short, is slightly miraculous. It relies on some very specific mathematical properties: by having \\$ x = 7 \\$ vowels, \\$ y = 5 \\$ soft consonants, and \\$ z = 3 \\$ hard consonants, we ensure:

* \\$ 729 \le xyxz \le 810 \\$, so our essay meets the word count
* \\$ z \ge 3 \\$, so each sentence has enough words in it (remember one of the hard consonants has a `.` at the end)
* \\$ 80 \div (5z+1) \in \mathbb Z \cap \[3, 9\] \\$, so the `fold` command, which defaults to wrapping every 80 characters, will break the essay up into paragraphs with a valid integer number of sentences
* \\$ xyxz \equiv 0 \mod (80 \div (5z+1))z \\$, so the last paragraph doesn't have any remainder sentences

Any of the issues above could be worked around, of course, but that would cost extra bytes. \\$ 7, 5, 3 \\$ is actually the only choice that works perfectly!

# Answer
> 1 votes
# K (ngn/k), ~~167~~ ~~148~~ ~~145~~ 144 bytes

```
{("\n"/(" "/'(" "/''$(729>#,//){x,,(3+*1?7){l:3+*1?7;x,,`$(-#:'w)?'w:(,/'+l?'0 7 14_c),'(l?7)?\:c:"aeimnoubcdgkptfhlrsvz"}/()}/()),''".")),"\n"}

```

Try it online!

Stitches together a random character of each type, appending an additional 0-6 random characters to form words of length 3-9, which are then shuffled. Sentences are formed from 3-9 of these words, and paragraphs from 3-9 of those sentences.

Paragraphs are iteratively appended, with the essay being complete when it contains at least 729 words. Since a valid paragraph can only contain up to 81 words (9 words per sentence * 9 sentences), it's safe to write another paragraph as long as the essay contains less than 729 words.

However, proofreading the essay to ensure there is no contiguous word repetition is an exercise left to the reader.

```
{("\n"/                                /join each paragraph with a newline
  (" "/'                               /join sentences in a paragraph with a space
   (" "/''$                            /join words in a sentence with a space (converting words from symbols to strings)
    (729>#,//){                        /while the essay contains less than 729 words...
     x,,                                /append another paragraph of...
     (3+*1?7){                          /3 to 9 (randomly chosen) sentences each containing...
      l:3+*1?7;                         /3 to 9 (randomly chosen) words
      x,,`$                             /append the new sentence (casted to symbols), which is made of l words, each being a...
      (-#:'w)?'                         /randomly shuffled string of...
      w:(,/'+l?'0 7 14_c)               /a random character from each character type in the Martian alphabet
      ,'                                /concatenated with...
      (l?7)?\:c:"aeimnoubcdgkptfhlrsvz" /0 to 6 random characters from the Martian alphabet
     }/()
    }/()
   )
   ,''"."                               /finish each sentence with a period
  )
 )
 ,"\n"                                  /finish the essay with a newline
}

```

# Answer
> 0 votes
# CJam, 26 bytes

```
'h,97>e!".
"{9/Sf*Uf+}fU9<

```

Try it online!

First solution in a while where I've had to use a literal newline. Same idea as the 05AB1E answer.

*sigh* And if only concatenation was commutative...

---
Tags: code-golf, kolmogorov-complexity
---


# Question
Title: Longest Repeating Subarray (With Overlapping)
Earlier I asked about this problem on stackoverflow (link), but now I also want to see the golfiest solutions

## Problem:

Given an array of arbitrary numbers, what is the longest subarray that is repeated (appears more than once)? In case there are multiple distinct repeated subarrays that all have the longest length, the answer can be any of them. If no subarray appears more than once, the answer is `[]` (the empty array).

Overlapping is allowed, that is partial occurrences of a subarray within itself is allowed. for ex, in the array `[1, 2, 1, 2, 1, 2]` the longest repeating subarray is `[1, 2, 1, 2]`. Look here

```
[1, 2, 1, 2, 1, 2]
^         ^        occurence #1
       ^        ^  occurence #2

```

## Constraints:

For the sake of code golf simplicity, assume that all values in the array are integers. like a 32bit int data type

The time complexity and the space complexity must be \\$O(n^{2 - \varepsilon})\\$ where \\$n\\$ = length of array, for some \\$\varepsilon \> 0\\$.

## Test cases:

| Array | Result |
| --- | --- |
| \[1, 2, 5, 7, 1, 2, 4, 5\] | \[1, 2\] |
| \[9, 7, 0, 1, 6, 3, 6, 5, 2, 1, 6, 3, 8, 3, 6, 1, 6, 3\] | \[1, 6, 3\] |
| \[1, 2, 1, 2, 7, 0, -1, 7, 0, -1\] | \[7, 0, -1\] |
| \[1, 1, 1, 1\] | \[1, 1, 1\] |
| \[1, 1, 1\] | \[1, 1\] |
| \[1, 2, 3, 4, 2, 5\] | \[2\] |
| \[1, 2, 3, 4, 5\] | \[\] |
| \[1, 6, 2, 1, 6, 2, 1, 5\] | \[1, 6, 2, 1\] |

Also this JS code generates a large test case with an array of one hundred thousand elements which your program should be able to handle. The answer is \[1, 2, 3, ..., 100\] (the 100 consecutive integers from 1 to 100)

```
function make_case() {
    let array = [];
    let number = 200;
    for (let i = 0; i < 500; i++) {
        array.push(number); array.push(number);
        number++;
    }
    for (let i = 1; i < 101; i++) {
        array.push(i);
    }
    for (let i = 0; i < 1700; i++) {
        array.push(number); array.push(number);
        number++;
    }
    for (let i = 1; i < 101; i++) {
        array.push(i);
    }
    for (let i = 0; i < (100_000 - 500 * 2 - 100 - 1700 * 2 - 100) / 2; i++) {
        array.push(number); array.push(number);
        number++;
    }
    return array;
}

```

# Answer
> 4 votes
# C++ (gcc), ~~378~~ ~~360~~ ~~359~~ ~~339~~ 337 bytes, \\$O(n \sqrt{n} \log^2 n)\\$

```
#import<bits/stdc++.h>
using V=std::vector<int>;V f(V a){int l=0,r=a.size(),n,j,i=0,m,L=r,s=sqrt(r);std::map<V,int>M;V v(L),x;for(;i+s<L;)v[i++]=M[x]=M[x=V(&a[i],&a[i+s])]?:~i;for(;M.clear(),l<r;l>m?:r=m)for(i=m=l+r>>1;i<=L;i++){V x;for(j=i-m;j<i;j+=j+s<i?s:1)x.push_back((j+s<i?v:a)[j]);l=M[x]++?n=i-m,m+1:l;}return V(&a[n],&a[n-1+l]);}

```

Try it online!

-3 thanks to @Unmitigated. -1 thanks to @movatica. -11 thanks to @ceilingcat. -2 thanks to @ceilingcat.

Mostly ungolfed:

```
#include <bits/stdc++.h>
using V=std::vector<int>;
V f(V a) {
    int l=0,r=a.size(),n,j,i,m,b,L=r,s=sqrt(r);
    std::map<V,int> M;
    V v(L);
    for(int i=0;i+s<L;i++) {
        V x(a.begin()+i,a.begin()+i+s);
        v[i]=M[x]=M[x]?M[x]:~i;
    }
    while (l<r) {
        m = (l+r)/2;
        b=0;
        std::set<V> S;
        for (i=m;i<=L;i++) {
            V x;
            for(j=i-m;j<i;j+=j+s<i?s:1)x.push_back((j+s<i?v:a)[j]);
            S.insert(x).second||(n=i-m,b=1);
        }
        b?l=m+1:r=m;
    }
    return V(a.begin()+n,a.begin()+n-1+l);
}

```

uses binary search, and sqrt decomposition for fast-ish substring comparison.

Takes a few seconds for the \\$n=100000\\$ case when compiled with `-O2`.

---
Tags: code-golf, restricted-complexity
---


title: Generate 100 Java Tuple classes

text:
# Question
Title: Generate 100 Java Tuple classes
Write a script that writes to standard output, or your language's equivalent, 100 lines of (valid) Java code that begins with:

```
class Tuple1 {public Object _0;}
class Tuple2 {public Object _0,_1;}
class Tuple3 {public Object _0,_1,_2;}
class Tuple4 {public Object _0,_1,_2,_3;}
class Tuple5 {public Object _0,_1,_2,_3,_4;}
class Tuple6 {public Object _0,_1,_2,_3,_4,_5;}
class Tuple7 {public Object _0,_1,_2,_3,_4,_5,_6;}
class Tuple8 {public Object _0,_1,_2,_3,_4,_5,_6,_7;}
class Tuple9 {public Object _0,_1,_2,_3,_4,_5,_6,_7,_8;}
class Tuple10 {public Object _0,_1,_2,_3,_4,_5,_6,_7,_8,_9;}
class Tuple11 {public Object _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10;}
class Tuple12 {public Object _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11;}

```

The last line should begin with `class Tuple100`.

This is , so the shortest code in bytes wins!

# Answer
# Jolf, 42 bytes

Do I get bonus points for beating Jelly with the best score ever? Contains unprintables, so you may want to try it online here. I replaced the unprintables with their respective alt index for readability.

```
‼Μz~1d"Ξ/êί Tuple% {Ξ0î⌂ Ξ2Qμ_ %;}"HRzH",_

```

## Explanation

```
‼Μz~1d"Ξ/êί Tuple% {Ξ0î⌂ Ξ2Qμ _%;}"HRzH",_
 Μz~1d                                     map the range 1..100 with the following function
      "                                    begin a string
       Ξ/êί                                short for "class"
            Tuple% {               H       string interpolate H (current number)
                    Ξ0î⌂ Ξ2Qμ              short for "public Object"
                              _%;}" RzH    string interpolate with a range from 1..H joined
                                       ",_  by the string ",_" (auto-closed quotes)

```
> 8 votes

# Answer
# vim ~~56~~ 54 keystrokes

```
iclass Tuple1 {public Object _0;}<esc>qyYp<C-a>$y2bPr,<C-a>q98@y

```

Since V is backwards compatible, you can Try it online!

This is the perfect task for vim! I might golf it a little bit more later. Also note that `<c-a>` means Control-A, and it counts as one keystroke.

Explanation:

```
iclass Tuple1 {public Object _0;}<esc>         'Enter the starting text

qy                          'Start recording in register y
  Yp                        'Yank the current line, the print on the line below
     <C-a>                  'Increment the next digit to occur by one
          $                 'Move to the end of this line
           y2b              '(yank) 2 words (b)ack. This will grab '_0;'
              P             'Print the previously yanked word before the cursor.
               r,           '(r)eplace the char under the cursor with a comma.
                 <c-a>q     'Increment the current digit, then stop recording
                       99@y 'Playback macro 'y' 99 times.

```
> 24 votes

# Answer
# Jelly, 44 bytes

```
R’j“,_”
“¤>%,oỊȤʠ“ØụĊ5D³ṃṠɼQ»j;Ç;“;}¶”
ȷ2RÇ€

```

My first Jelly answer. Try it online!
> 10 votes

# Answer
# Java, 160, 125 Bytes

Thanks to @DenkerAffe, @Denham Coote and @Mathias Ettinger for the improvements.

Java writing java( because someone had to!)

```
void z(){String s="_0";for(int i=1;i<101;){System.out.println("class Tuple"+(i++)+" {public Object "+s+";}");s+=",_"+i;}}

```

### And the un-golfed version

```
void z(){
    String s = "_0";
    for(int i = 1 ;i < 101;){
        System.out.println("class Tuple" + (i++) + " {public Object "+ s + ";}");
        s += ",_" + i;
        }
    }

```
> 9 votes

# Answer
## Pyth, ~~53~~ ~~50~~ 48 bytes

```
VS100%." }SüÆðQ´Ó3Ô«%&a´4UçõÛ"[Nj",_"UN

```

Try it online!

Straightforward iteration over range(1,100) and building the corrosponding string from a packed string through formatting it.

## Explanation

```
VS100%." }SüÆðQ´Ó3Ô«%&a´4UçõÛ"[Nj",_"UN

VS100                                     # Iterate over range(1,100)
     %." }SüÆðQ´Ó3Ô«%&a´4UçõÛ"            # Unpack the string and format it
                              [           # List for formatting arguments
                               N          # Number of the Tuple
                                j    UN   # Join Object numbers...
                                 ",_"     # ...on the seperator ",_"

```

The unpacked string is `class Tuple%i {public Object _%s;}`
> 8 votes

# Answer
# CoffeeScript, ~~86~~ 84 bytes

```
console.log "class Tuple#{i} {public Object _#{[0...i].join ',_'};}"for i in[1..100]

```

View the solution online
> 7 votes

# Answer
## Batch, 128 bytes

```
@set m=_0
@for /l %%t in (1,1,100)do @call:b %%t
@exit/b
:b
@echo class Tuple%1 {public Object %m%;}&set m=%m%,_%1

```

Edit: Saved 10 bytes thanks to @Bob. Saved 1 byte thanks to @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ.
> 6 votes

# Answer
# Oracle SQL 9.2, ~~138~~ 137 Bytes

```
SELECT REPLACE('class Tuple'||LEVEL||' {public Object'||SYS_CONNECT_BY_PATH(LEVEL-1,',_')||';}','t,','t ')FROM DUAL CONNECT BY LEVEL<101;

```

@Peter Thanks for pointing the 0/1 mistake.

The query use the CONNECT BY CLAUSE of hierarchical query to generate 100 rows.

The LEVEL pseudocolumn contains the row number of each row.

SYS\_CONNECT\_BY\_PATH concatenate the first parameter, the row number, of each row, and use the second parameter as the separator.
> 6 votes

# Answer
## Powershell - 65 bytes

(Amended in response to comment)

All credit to TimmyD

```
1..100|%{"class Tuple$_ {public Object _$(0..($_-1)-Join",_");}"}

```
> 6 votes

# Answer
## Retina, ~~80~~ 79 bytes

Byte count assumes ISO 8859-1 encoding.

```
100$*1
1
class Tuple11$` {public Object 1$`}¶
1(?<= (1+))
_$1,
1(1)*
$#1
,}
;}

```

Try it online!
> 5 votes

# Answer
# Perl 6, 65 bytes

```
say "class Tuple$_ \{public Object _{join ',_',^$_};}" for 1..100

```
> 5 votes

# Answer
# APL (Dyalog Unicode), 66 bytes

```
↑{∊'class Tuple'(⍕1+⍵)' {public Object _0'(',_'∘,∘⍕¨⍳⍵)';}'}¨0,⍳99

```

Try it online!

Explanation:

```
↑{∊'class Tuple'(⍕1+⍵)' {public Object _0'(',_'∘,∘⍕¨⍳⍵)';}'}¨0,⍳99
                                                             0,⍳99⍝ Numbers 0-99
                                                            ¨     ⍝ map to dfn
↑                                                                 ⍝ mix the result
  ∊'...'(⍕1+⍵)'...'                    ⍝ join the class header, tuple name (index + 1)
                                       ⍝ and the first tuple element.
                   (',_'∘,∘⍕¨⍳⍵)       ⍝ numbers from 1 to ⍵ prepended with ',_'
                                ';}'   ⍝ finish the class declaration

```
> 5 votes

# Answer
# R - ~~199~~ ~~132~~ ~~123~~ 118 bytes

Version 4

```
p=paste0;for(i in 1:10)cat(p("class Tuple",i," {public Object ",toString(sapply(0:(i-1),function(x)p("_",x))),";}\n"))

```

Version 3

```
p=paste0;for(i in 1:8)cat(p("class Tuple",i," {public Object ",p(sapply(0:(i-1),function(x)p("_",x)),collapse=","),";}\n"))

```

Version 2

```
p=paste0;for(i in 1:100)cat(p("class Tuple",i," {public Object ",p(sapply(0:(i-1),function(x)p("_",x)),collapse=","),";}"),sep="\n")

```

Version 1

```
for (i in 1:100){
  foo <- paste0("class Tuple", i, " {public Object ")
  for (j in 0:(i - 1)){
    foo <- if (j < (i - 1)) paste0(foo, "_", j, ",") else paste0(foo, "_", j, ";}")
  }
  print(foo)
}

```
> 4 votes

# Answer
# Ruby, 71 bytes

```
100.times{|i|puts"class Tuple#{i+1} {public Object _#{[*0..i]*',_'};}"}

```
> 4 votes

# Answer
# Java, 103 bytes

```
s->{s="_0";for(int i=0;i++<100;s+=",_"+i)System.out.printf("class Tuple%s {public Object %s;}\n",i,s);}

```

My first time here. Hi there! I went for a Java8 lambda expression (aka an anonymous function).

## Ungolfed version

```
s -> {
    s = "_0";
    for (int i = 0; i++ < 100; s += ",_" + i)
        System.out.printf("class Tuple%s {public Object %s;}\n", i, s);
}

```

To actually use this, as usual in Java8, you have to assign it to a variable of (or cast it to) an appropriate functional interface and then call its method; but technically, the function is only the lambda expression itself, so I am counting only that.

It also requires an input parameter, which saves me a couple bytes, since I can abuse it as a local variable without having to specify its type. I'm not sure if that's considered cheating, but to me it appears to be within the rules: I only saw people state that posting a function is allowed, not *how* that function needs to be invoked. :) And it doesn't actually read the parameter, so the function is still self-contained; you can pass any String to it, or even null, and it will still produce the correct output.

## And here is how to use it:

```
import java.util.function.Consumer;

public class Main {
    public static void main(String[] args) {
        Consumer<?> r =
            s->{s="_0";for(int i=0;i++<100;s+=",_"+i)System.out.printf("class Tuple%s {public Object %s;}\n",i,s);}
        ;
        r.accept(null);
    }
}

```
> 4 votes

# Answer
# Python 2, 96

```
def f(n=99):s=n and f(n-1)+',_'+`n`or"class Tuple%d {public Object _0";print s%-~n+';}';return s

```

# Python 3, 98

```
def f(n=99):s=n and f(n-1)+',_%d'%n or"class Tuple%d {public Object _0";print(s%-~n+';}');return s

```

**Usage:**

```
f()

```

**Ungolfed:**

```
def javatuple(n=99):
    if n == 0:
        s = "class Tuple%d {public Object _0"
    else:
        s = javatuple(n-1) + ',_' + str(n)
    print(s%(n+1) + ';}')
    return s

```

**formers:**

**103**

```
r=range
for i in r(100):
 print"class Tuple%d {public Object _%s;}"%(i+1,',_'.join(`j`for j in r(i+1)))

```

**108**

```
def f(n=99):
 if n:f(n-1)
 print"class Tuple%d {public Object _%s;}"%(n+1,',_'.join(`i`for i in range(n+1)))

```
> 3 votes

# Answer
# PowerShell, 63 bytes

```
1..100|%{"class Tuple$_ {public Object _$(0..--$_-Join",_");}"}

```

Try it online!

Two byte improvement of bulletprooffool's answer, who seems to be an abandoned account now.
> 3 votes

# Answer
# CJam, 53 bytes

```
100{)"class Tuple"\" {public Object _"1$,",_"*";}
"}/

```

Try it here.
> 2 votes

# Answer
# Groovy, 74 chars

"join()" is unbeatable... New solution, thanks to @yariash

```
100.times{println"class Tuple$it {public Object _${(0..it-1).join',_'};}"}

```

Old solution, 78 chars:

```
(1..100).each{println"class Tuple$it {public Object _${(0..it-1).join',_'};}"}

```
> 2 votes

# Answer
# 05AB1E, 43 bytes

```
тFNÝ„,_ý'_ì'Œº™'‚ÆN>'„à"ÿ Tupleÿ {ÿ ÿ ÿ;}"=

```

Try it online!
> 2 votes

# Answer
# FALSE, 85 bytes

```
1[$100>~][$$0"class Tuple"\." {public Object "[$@$@=~][\$0>[","]?$"_".1+]#";}
"%%1+]#

```

Try it online!

Loops through 1-100 to get the Tuple number and then within that loops from 0 to currnum-1 to get underscores.
> 2 votes

# Answer
# Vyxal, 36 bytes

```
`⟑↓ Tuɖ¾% {ƛḊ ß₂ %;}`₁ƛɾ\_$+\,j";v%⁋

```

Try it Online!

```
     ₁ƛ         ;    # map 1...100 to...
       ɾ             # 1...n
        \_$+         # Prepend underscores to each
            \,j      # Join by commas
               "     # Pair with n
`...`                # Compressed string `class Tuple% {public object %;}`
                 v%  # Formatted with (n, names)
                   ⁋ # Join by newlines

```
> 2 votes

# Answer
# Lua, ~~128~~ 106 Bytes

I'm still trying to find a way to directly work on a printed value, and not on a string.

**Edit : Partially found it! I still need a string for the "\_0,\_1..." part, but it already is better :).**

```
s=""for i=0,99 do s=(s..",_"..i):gsub("^,",s)print(("class Tuple"..(i+1).." {public Object ")..s..";}")end

```

### Old 128 Bytes solution

```
s="class Tuple1 {public Object _0;}"print(s)for i=1,99 do s=s:sub(1,s:find";"-1):gsub("e%d+","e"..i+1)..",_"..i..";}"print(s)end

```

### Ungolfed

```
s=""
for i=0,99
do
  s=(s..",_"..i)              -- concatenate s with ",_i"
      :gsub("^,",s)           -- remove the leading "," for ",_0"
  -- then print the concatenated string
  print(("class Tuple"..(i+1).." {public Object ")..s..";}")
end

```
> 1 votes

# Answer
# Python 2, 96 Bytes

```
r=range
for i in r(1,101):print"class Tuple%d {public Object _%s;}"%(i,',_'.join(map(str,r(i))))

```

Thanks @DenkerAffe for the suggestion of using `lambda`.

Thanks @MathiasEttinger for the `join` idea.
> 1 votes

# Answer
# Julia, 77 bytes

```
for i=1:100;println("class Tuple$i {public Object _$(join(0:i-1,",_"));}")end

```
> 1 votes

# Answer
# Python 3, 111 109 105 bytes

```
[print('class Tuple%s {public Object %s;}'%(i,','.join('_%i'%j for j in range(i))))for i in range(1,101)]

```

It's not the shortest thing in the world, I'm just participating.

edit1: down 2 bytes by removing `0,` in first `range`

edit2: I was unnecessarily casting `int` to `str` instead of just using `%i`... Down to 105.
> 1 votes

# Answer
# Mathematica, 130 Bytes

```
{"class Tuple",ToString[#]," {public Object ",StringReplace[ToString[#-1&/@Range@#],{" "|"{" ->"_","}"->";}\n"}]}&/@Range[100]<>""

```
> 1 votes

# Answer
# Scala, 85 Bytes

```
for(u<-1 to 100)println(s"class Tuple$u {public Object _${0 to u-1 mkString ",_"};}")

```
> 1 votes

# Answer
## PHP, 112 bytes

```
<?php for($i=0;$i<100;$i++){$m.=$i==0?'_'.$i:',_'.$i;echo 'class Tuple'.($i+1).' {public Object '.$m.';}<br/>';}

```
> 1 votes

# Answer
# Javascript, ~~112~~ 110 bytes

2 bytes off thanks @CᴏɴᴏʀO'Bʀɪᴇɴ.

```
_=>[...Array(100)].map((x,i)=>`class Tuple${++i} {public Object ${[...Array(i)].map((y,j)=>'_'+j)};}`).join`
`

```

Ungolfed:

```
_=>                                         // anonymous function
    [...Array(100)].map((x,i)=>             // 100 times [0..99]
        `class Tuple${++i} {public Object   // Tuple index + 1
            ${[...Array(i)].map(            // (index + 1) times
                (y,j)=>'_'+j                // _+j with j in [0..index]
            )}                              // Array without join prints comma in between
        ;}`                                 // as literal string
    ).join`\n`                              // display array line by line

```
> 1 votes

# Answer
## Java, 116

(for the printing function only - according to some comments, this is in line with the rules)

```
import static java.lang.System.*;
public class T
{
    public static void main(String[] args)
    {
        T t = new T();
        t.p();
    }

    void p(){String s="_0";for(int i=0;i<100;){out.println("class Tuple"+ ++i+" {public Object "+ s + ";}");s+=",_"+i;}}
}

```
> 1 votes

# Answer
## Seriously, 55 bytes

```
2╤R`;r"$'_+"£M',j@k"c╙ò T╒α%d {pu▐V Object %s;}"⌡%`M'
j

```

Hexdump (reversible with `xxd -r`):

```
00000000: 32e2 95a4 5260 3b72 2224 275f 2b22 c2a3  2...R`;r"$'_+"..
00000010: 4d27 2c6a 406b 2263 e295 99c3 b220 54e2  M',j@k"c..... T.
00000020: 9592 ceb1 2564 207b 7075 e296 9056 204f  ....%d {pu...V O
00000030: 626a 6563 7420 2573 3b7d 22e2 8ca1 2560  bject %s;}"...%`
00000040: 4d27 0a6a                                M'.j

```

Try it online!

Yes, that newline is supposed to be there.

Explanation (newline replaced with `\n`):

```
2╤R`;r"$'_+"£M',j@k"c╙ò T╒α%d {pu▐V Object %s;}"⌡%`M'\nj
2╤R                                                       push range [1,100]
   `                                              `M      map:
    ;r                                                      push a, range(a)
      "$'_+"£M                                              map:
       $'_+                                                   stringify, prepend "_"
              ',j                                           join with commas
                 @k                                         swap and push stack as list
                   "c╙ò T╒α%d {pu▐V Object %s;}"⌡           decompress, result is
                                                              "class Tuple%d {public Object %s;}"
                                                 %          string format
                                                    '\nj  join with newlines

```
> 1 votes

# Answer
# Japt, 52 bytes

```
Lo £`cÓ? TÕà{X} \{puÞV Object {Xò ®'_+Z}&}` r&59d} ·

```

The `?` should be the literal byte 0x95. Test it online!

Japt has:

* **concise syntax** to help shorten your code.
* **string compression** to help shorten it even further.
* **lots of bugs** to make you want to throw your computer out the window.

I can't even use a semicolon in the string because the function it's wrapped in wants to return everything after the semicolon. This should only be 46 bytes:

```
Lo £`cÓ? TÕà{X} \{puÞV Object {Xò ®'_+Z};}`} ·

```

But alas, it is not. I'll see if I can fix these bugs over the next couple of hours.

### How it works

```
Lo £       }  // Generate the range [0..100), and map each item X in this range to:
`cÓ? TÕà{X}   //  "class Tuple" + X +
\{puÞV Object //  "{public Object" +
{Xò ®'_+Z}    //   Create the range [0..X] and map each item Z to "_" + Z.
              //   Upon stringification, this automatically inserts the commas.
&}`           //  + "&}"
r&59d         //  Replace the "&" with String.fromCharCode(59), or ";".
·             // Join the result with newlines.

```
> 1 votes

# Answer
# Groovy, 97 bytes

```
(1..100).each{println "class Tuple${it} {public Object ${(0..it-1).collect{"_$it"}.join(',')};}"}

```

Try it online!
> 1 votes

# Answer
# C++, ~~164~~ ~~159~~ 157 bytes (155 as function only)

```
#include <iostream>
#define o std::cout<<
int main(){int j,i=0;for(;i<100;++i){o"class Tuple"<<i+1<<" {public Object _0";for(j=0;++j<=i;)o",_"<<j;o";}\n";}}

```

This is a full program. You can save 2 bytes in function only form if you replace `int main()` with `void f()`.

Run code in Ideone

## Ungolfed, including macro expansion

```
#include <iostream>
int main()
{
    int j,i=0;
    for(;i<100;++i)
    {
        std::cout << "class Tuple"<< i+1 <<" {public Object _0";
        for(j=0;++j<=i;)
            std::cout << ",_" << j;
        std::cout << ";}\n";
    }
}

```
> 1 votes

# Answer
# , 44 chars / 55 bytes

```
⩥ṥⓜᵖ`э£ēÕ>rĕĠ#⦃$⦄ {public Object ⦃⩤$ⓜ⍘_+$⦄;}

```

`Try it here (Firefox only).`

Still amazing even without compression.

# Explanation

```
⩥ṥⓜᵖ`э£ēÕ>rĕĠ#⦃$⦄ {public Object ⦃⩤$ⓜ⍘_+$⦄;} // implicit: ṥ=input
⩥ṥⓜ                                          // generate [0,100) to map over
    ᵖ                                         // push to stack:
     `э£ēÕ>rĕĠ#⦃$⦄                             // class Tuple[insert mapitem here]
                  {public Object ⦃⩤$ⓜ⍘_+$⦄;} // {public Object [insert [0,mapitem] here preceded by semicolons per item];}
                                             // implicit stack output

```
> 1 votes

# Answer
# Pip, ~~53~~ 51 bytes

```
LhP["class Tuple"++i" {public Object "'_.,iJ',";}"]

```

Try it online!

Explanation:

```
                        h is preinitialized to 100 and i to 0 (implicit)
L h                     Loop 100 times:
 P [                    Print the following list (with trailing newline):
    "class Tuple"
    ++i                 Increment i here so that its values run from 1 to 100
    " {public Object "
    ('_ . ,i) J ',      Range(i), concatenate "_" before each element, join on ","
    ";}"
   ]                    By default, lists are concatenated when printed

```
> 1 votes

# Answer
# JavaScript (ES6), 85 bytes

```
s='_0';for(i=1;i<101;s+=',_'+i++)console.log(`class Tuple${i} {public Object ${s};}`)

```
> 1 votes

# Answer
# Tcl, 107 bytes

```
time {set s "class Tuple[incr i] \{public Object \{"
set j 0
time {set s $s\_$j\;
incr j} $i
puts $s\}} 100

```

Try it online!

~~Tcl, 117 bytes
```
proc P n {set i 0;time {append s _$i\;;incr i} $n;set s}
time {puts "class Tuple[incr i] {public Object [P $i]}"} 100

```
Try it online!
~~
> 1 votes

# Answer
# Forth (gforth), 97 bytes

```
: f 101 1 do cr ." class Tuple"i 1 .r ." {public Object _0"i 1 ?do ." ,_"i 1 .r loop ." ;}"loop ;

```

Try it online!

### Code Explanation

```
: f                           \ start a new word definition
  101 1 do                    \ start a loop from 1 to 100
    cr                        \ output a new line
    ." class Tuple"i 1 .r     \ output "class TupleN" where N is the loop index
    ." {public Object _0"     \ output "{public Object _0"
    i 1 ?do                   \ start a loop from 1 to the outer loop index
      ." ,_"i 1 .r            \ output ",_N" where N is the inner loop index
    loop                      \ end the inner loop
    ," ;}"                    \ output ";}"
  loop                        \ end the outer loop
 ;                            \ end the word definition

```
> 1 votes

# Answer
# Python 2, 93 bytes

```
i=1;exec'print"class Tuple%s {public Object _"%i+",_".join(map(str,range(i)))+";}";i+=1;'*100

```

Try it online!

I rarely get to use `exec` in code golf, so I wasn't going to pass on this one!
> 1 votes

# Answer
# K (ngn/k), 67 bytes

```
{1@,/("class Tuple";$x;" {public Object _";",_"/$!x;";}\n")}'1+!100

```

Try it online!

A bunch of string concatenations, with `",_"/$!x` probably being the most interesting part.
> 1 votes

# Answer
# Python 2, 82 bytes

```
s="class Tuple%d {public Object _0"
i=1
exec"print s%i+';}';s+=',_%d'%i;i+=1;"*100

```

Try it online!
> 1 votes

# Answer
# Perl 5, 69 bytes

```
$p='{public Object _0';say("class Tuple$_ $p;}"),$p.=",_$_"for 1..100

```

Try it online!
> 1 votes

# Answer
# Regenerate, 66 bytes

```
(class Tuple(${$2+1}!1) \{public Object ($3,_${$2-1}!_0);\}
){100}

```

Attempt This Online!

### Explanation

```
(class Tuple(...) \{public Object (...);\}\n){100}

```

Repeat this text 100 times, with the ellipses being as follows:

```
(${$2+1}!1)

```

This is capture group 2. Try to increment the value from the last time group 2 matched. If this is the first iteration, there isn't a previous match for group 2; in that case, use `1` instead.

```
($3,_${$2-1}!_0)

```

This is capture group 3. Try to match the same string group 3 matched last time, followed by `,_`, followed by one less than the value we just matched for group 2. If this is the first iteration, there isn't a previous match for group 3; in that case, use `_0` instead.
> 1 votes

# Answer
# Perl5, 77 Bytes

```
$"=", ";for(0..100){push@o,"_$_";print"class Tuple$_\{public Object @o;\}\n"}

```

Also

```
for(0..100){$o.=$o?", _$_":"_$_";print"class Tuple$_\{public Object $o;\}\n"}

```
> 0 votes

# Answer
# MATL, 59 bytes

```
100:"'class Tuple%i {public Object %s}'@'_%i,'@:qYD59O(3$YD

```

*EDITS*

* *(May 16, 2016): to adapt to recent changes in the language, `O` needs to be replaced by `J` in the above code.*
* *(September 29, 2017): the order of the inputs to `YD` has changed, which requires some modifications in the code.*

*The following link includes these changes*.

**Try it online!**
> 0 votes

# Answer
## Java 1.8, 163 Bytes

```
interface T{static void main(String[]a){String o="";for(int i=0;i<100;){o+=(i>0?",":"")+"_"+i;System.out.println("class Tuple"+(++i)+" {public Object "+o+";}");}}}

```

### Ungolfed

```
interface T{
static void main(String[]a){
    String o="";
    for(int i=0;i<100;){
        o+=(i>0?",":"")+"_"+i;
        System.out.println("class Tuple"+(++i)+" {public Object "+o+";}");
    }
}
}

```
> 0 votes

# Answer
## AWK, 84 Bytes

`BEGIN{m=" {public Object _0";for(i=1;i<101;){print"class Tuple"i m";}";m=m",_"i++}}`

I do like playing with AWK.

If the script were placed in a file, `tuple.awk`, and called with a 1 line input, the `BEGIN` tag could be removed... e.g. `echo 1|awk -f tuple.awk`

Not sure if any other golfing could be done to it.
> 0 votes

# Answer
# Clojure, 103 chars

```
(map(fn[n](prn(str"class Tuple"n" {public Object "(join","(map #(+"_"%)(range n)))";}")))(range 1 101))

```
> 0 votes

# Answer
# jq, 80 characters

(78 characters code + 2 characters command line option.)

```
range(1;13)|"class Tuple\(.) {public Object \([range(.)|"_\(.)"]|join(","));}"

```

Sample run:

```
bash-4.3$ bin/jq -nr 'range(1;101)|"class Tuple\(.) {public Object \([range(.)|"_\(.)"]|join(","));}"' | head
class Tuple1 {public Object _0;}
class Tuple2 {public Object _0,_1;}
class Tuple3 {public Object _0,_1,_2;}
class Tuple4 {public Object _0,_1,_2,_3;}
class Tuple5 {public Object _0,_1,_2,_3,_4;}
class Tuple6 {public Object _0,_1,_2,_3,_4,_5;}
class Tuple7 {public Object _0,_1,_2,_3,_4,_5,_6;}
class Tuple8 {public Object _0,_1,_2,_3,_4,_5,_6,_7;}
class Tuple9 {public Object _0,_1,_2,_3,_4,_5,_6,_7,_8;}
class Tuple10 {public Object _0,_1,_2,_3,_4,_5,_6,_7,_8,_9;}

```

On-line test (Passing `-r` through URL is not supported – check Raw Output yourself.)
> 0 votes

# Answer
# Common Lisp, 106 bytes

`(let(y)(dotimes(x 100)(push x y)(format t"class Tuple~d {public Object ~{_~d~^,~};}~&"(1+ x)(reverse y))))`

Try it online!
> 0 votes

# Answer
## Java, 166 Bytes

```
void m(){int c=0;while(c!=100){System.out.print("class Tuple"+(c+1)+" {public Object ");for(int i=0;i<c+1;i++)System.out.print(",_"+i);System.out.print(";}\n");c++;}}

```

Not bad for java, I mean calling main() alone is like 10+ bytes.. (plus long print statements)

## (Non-Competetive) Java w/ Quick-Print! 137 bytes

```
import t.Q;
void m(){int c=0;while(c!=100){Q.p("class Tuple"+(c+1)+" {public Object ");for(int i=0;i<c+1;i++)Q.p(",_"+i);Q.p(";}\n");c++;}}

```

This one uses a quick library I have been thinking about making for a while(and just made) for shortening the long java print statements. It saves 29 bytes and that was just with 3 system.out.print() calls in the original. I've marked this one as non-competetive since the lib was made after the challenge was posted. Also, I don't know if we are allowed to use cheap little tricks like this and I felt bad about it. (Although in a way its fair since java has the longest print statements of any language I know).
> 0 votes

# Answer
## Java 8, ~~184~~ 194 bytes

(just to add `void r()` as mentioned in the comments)

```
void r(){IntStream.rangeClosed(1,100).mapToObj(i->IntStream.range(0,i).mapToObj(j->"_"+j).collect(Collectors.joining(",","class Tuple"+i+" {public Object ",";}"))).forEach(System.out::println);}

```

Ungolfed

```
void r(){ IntStream.rangeClosed(1, 100)
    .mapToObj(i -> IntStream.range(0, i).mapToObj(j -> "_" + j)
        .collect(Collectors.joining(",", "class Tuple" + i + " {public Object ", ";}")))
    .forEach(System.out::println); }

```
> 0 votes

# Answer
# Brachylog, 99 bytes

```
0:99eI+1=J,[J]:"class Tuple~w {public Object "w,(I{:0reI,(?I,F";";?'I,F","):"w~_"cr:[I]rw\};"}
"w\)

```
> 0 votes

# Answer
# Scala, 119 bytes

I'm new to Scala and to codegolf, so nothing fancy.

```
for(i<-1 to 100){print("class Tuple"+i+" {public Object "); for(j<-0 to i-2) print("_"+j+","); print("_"+(i-1)+";}\n")}

```

Try online

More readable version:

```
for (i <- 1 to 100) {
  print("class Tuple" + i + " {public Object ")
  for (j <- 0 to i - 2) print("_" + j + ",")
  print("_" + (i - 1) + ";}\n")
}

```
> 0 votes

# Answer
# Haskell, 131 bytes

Call `j`.

```
import Data.List
j=mapM_(\n->putStrLn("class Tuple"++show n++" {public Object _"++intercalate",_"(map show[0..n-1])++";}"))[1..100]

```
> 0 votes

# Answer
# BlitzMax, 81 bytes

```
While i<100s$:+",_"+i i:+1Print"class Tuple"+i+" {public Object "+s[1..]+";}"Wend

```

That's the whole program. Non-Strict and without a Framework, so I can use variables without declaration and Print without having to import StandardIO. The String slicing operator comes in handy here, since it allows me to easily remove the superfluous comma at the beginning of each Object list.

## Ungolfed version

```
While i < 100
    s$ :+ ",_" + i
    i :+ 1
    Print "class Tuple" + i + " {public Object " + s[1..] + ";}"
Wend

```
> 0 votes

# Answer
# Python 3, 96 bytes

```
r=range
for i in r(1,101):print('class Tuple%d {public Object _0'%i,*r(1,i),sep=',_',end=';}\n')

```

Joining its expanded positional arguments from `*range(1,i)` using a custom separator `,_` and ending each line with `;}`, Python 3's `print()` function happily does the job almost entirely on its own.
> 0 votes

# Answer
# Javascript ES6, ~~128~~ 122 chars

```
for(s="class Tuple1 {public Object _0;}",q=0;q++<100;s=s.replace(/\d+(?!\d|,)( )?/g,(m,s)=>[q+1+s][+s]||m+",_"+q))alert(s)

```
> 0 votes

# Answer
## Kotlin, 92 Bytes

```
fun j(){var s="_0";for(i in 1..100){println("class Tuple$i {public Object $s;}");s+=",_"+i}}

```

Try it online!

### Ungolfed

```
fun j(){
    var s = "_0"
    for(i in 1..100){
        println("class Tuple$i {public Object $s;}")
        s+=",_"+i
    }
}

```
> 0 votes

# Answer
# Perl 5, ~~68~~ 66 bytes

```
$"=',_';say"class Tuple$_ {public Object _@{[0..$_++]};}"for 0..99

```

Try it online!
> 0 votes

# Answer
# , 47 bytes

```
iclass Tuple1 {public Object _0;}99ñÙ$hi,_Û

```

Try it online!
> 0 votes

# Answer
## C++, ~~139~~ 137 bytes

-2 bytes thanks to Zacharý

```
#include<iostream>
auto&p=printf;void j(){int i=1,k;for(;i<101;++i){p("class T%d{",i);for(k=0;k<i;++k)p("public Object v%d;",k);p("}");}}

```
> 0 votes

# Answer
# C# (Visual C# Interactive Compiler), ~~110~~ 109 bytes

```
int i;for(;i++<100;)Write($"class Tuple{i} {{public Object _{string.Join(",_",Enumerable.Range(0,i))};}}\n");

```

Saved a byte thanks to @dana

Try it online!
> 0 votes

# Answer
# ink, 87 bytes

```
-(i)class Tuple{i} \{public Object <>
~temp k=-1
-(j)~k++
_{k}{k<i:,->j};\}
{i<100:->i}

```

Try it online!
> 0 votes

# Answer
# C (clang), ~~118~~ ~~116~~ 114 bytes

```
i,j,(*p)()=printf;main(){for(;j=i++<100&&p("class Tuple%d {public Object _0",i);p(";}\n"))for(;j<i;)p(",_%d",j++);}

```

Try it online!

## Explanation

Note that I put a few statements into the for loop header, but the logic is the same.

**Only works with clang.** GCC errors on `(*p)()=printf`.

Ungolfed version:

```
// Define our loop counters....
int i, j;
// And our function pointer to printf (saves 4 bytes)
// Clang is generous enough to accept this monstrosity.
//
// Remember that f() in C represents an unspecified number of arguments,
// unlike C++.
// This is why you should always compile with -Wstrict-prototypes. :)
int (*p)() = printf;

int main()
{
    // Static and globals default to 0, so we don't need i=0.
    // Loop from 1 to 100.
    while (i++ < 100) {
        // Print the beginning of the string with printf.
        // For ease, of implementation, we print the initial _0 so we can
        // just print ",_j" later.
        p("class Tuple%d {public Object _0", i);
        // Print all the members starting at _1.
        // Loop j for 1 to i - 1. We skip the first iteration.
        for (j = 1; j < i;)
            // Print ",_j"
            p(",_%d", j++);
        // Print the end of the class declaration.
        p(";}\n");
    }
}

```

Thanks to ceilingcat for the -2 bytes by using the first for loop condition to set `j`!
> 0 votes

# Answer
## Google Sheets, 142

|  | A |
| --- | --- |
| 1 | `=SEQUENCE(1,100` \- Named Range `A` |
| 2 | `;}` \- Named Range `B` |
| 3 | `=ArrayFormula("class Tuple"&A&" {public Object "&SPLIT(REGEXREPLACE(TEXTJOIN(",",,IF(FLATTEN(A)>=A,"_"&A-1,)),",,+",B),B)&B` |

+1 for each named range.

### Fun facts

`Flatten` is an undocumented function. Takes any matrix and makes it into a column vector. This includes row vectors too, so I used it instead of `Transpose`.
> 0 votes

# Answer
# brainfuck, ~~881~~ 781 bytes

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

```

Try it online!
> 0 votes

# Answer
# Pyth, 53 bytes

```
FNS*TTs["class Tuple"N" {public Object "j\,m+\_dUN";}

```

Try it online!

---

```
Pyth                                                   | Python 3
-------------------------------------------------------+-------------------------------------
FNS*TTs["class Tuple"N" {public Object "j\,m+\_dUN";}  |
FNS*TTs["class Tuple"N" {public Object "j\,m+\_dUN";}" |
-------------------------------------------------------+-------------------------------------
FNS*TT                                                 | for N in range(1, 101):
                                                       |     print(
      s[                                               |       "".join([
        "class Tuple"                                  |         "class Tuple",
                     N                                 |         str(N),
                      " {public Object "               |         " {public Object ",
                                        j\,            |         ",".join(
                                           m           |           map(
                                            +\_d       |             lambda d: "_" + str(d),
                                                UN     |             range(N)
                                                       |           )
                                                       |         ),
                                                  ";}" |         ";}"]
                                                       |       )
                                                       |     )

```
> 0 votes

# Answer
# Zsh, 65 bytes

```
for i ({1..100})<<<"class Tuple$i {public Object _0$s;}"&&s+=,_$i

```

Attempt This Online!
> 0 votes

# Answer
# Go, 173 bytes

```
import(."strings";."fmt")
func f(){for i:=1;i<101;i++{s:=[]string{}
for j:=0;j<i;j++{s=append(s,Sprint("_",j))}
Printf("class Tuple%d {public Object %s;}\n",i,Join(s,","))}}

```

Attempt This Online!

Prints to STDOUT.

# Go 1.22+, 173 bytes

```
import(."strings";."fmt")
func f(){for i:=range 100{s:=[]string{}
for j:=range i+1{s=append(s,Sprint("_",j))}
Printf("class Tuple%d {public Object %s;}\n",i+1,Join(s,","))}}

```

Run this on the Go Playground!

Alternate solution using the new integer-range loops coming in Go 1.22.
> 0 votes

# Answer
**Java 112 bytes**

> ```
> void p(){String x="_0";for(int i=0;i<100;){out.format("class Tuple %d {public Object %s;}\n",++i,x);x+=",_"+i;}}
>
> ```

Un-golfed

```
import static java.lang.System.*;

public class I {
public static void main(String[] args){
    I m=new I();
    m.p();
}
    void p(){
    String x="_0";
    for(int i=0;i<100;){
        out.format("class Tuple %d {public Object %s;}\n", ++i, x);
        x+=",_"+i;
    }
}

```

}
> -1 votes

# Answer
# Haskell, 102 bytes

```
putStr$[0..99]>>= \a->"class Tuple"++show(a+1)++" {public Object _0"++([1..a]>>=(",_"++).show)++";}\n"

```

## As a program (107 bytes):

```
main=putStr$[0..99]>>= \a->"class Tuple"++show(a+1)++" {public Object _0"++([1..a]>>=(",_"++).show)++";}\n"

```

## Explanation

```
putStr$ -- print it all
  [0..99]>>= \a->                 -- For each a from 0 to 99, make the
                                  -- following string, then concat
                                  -- it all together

    "class Tuple" ++ show (a + 1) -- class name (starts at Tuple1)

    ++" {public Object _0"        -- All Tuple classes start with a _0

    ++([1..a]>>=(",_"++).show)    -- If we're on TupleA,
                                  -- concat together ",_1", ",_2", etc.
                                  -- up to "_A"

    ++";}\n"

```
> -1 votes

---
Tags: code-golf, kolmogorov-complexity, code-generation
---