11
\$\begingroup\$

Introduction

The childhood song Eeny, meeny, miny, moe was often used to select who was "it" when playing tag. Everyone would stand in a circle and point at one person selected at random. They would sing:

Eeny, meeny, miny, moe,
Catch a tiger by the toe.
If he hollers, let him go,
Eeny, meeny, miny, moe.

As they sung each word, they pointed at the next person in the circle. The person being pointed to when the final "moe" was sung would be "it". The children would immediately stand up and scatter.

Goal

Implement the shortest program in bytes that takes an input, the number of children, and lists the words that were sung when they were being pointed at.

The winner will be selected in one week.

Input

From STDIN, a single, positive integer, the number of children. This may be more than the number of words in the song.

Output

Writes to STDOUT a list where each line represents a child and contains the word sung while they were being pointed at. If there are too many children, empty lines may be omitted.

Requirements

  • Always start with the first child.
  • Display the words without punctuation.
  • The final "moe" should be emphasised as "MOE!" including punctuation.

Example

Input

3

Output

Eeny moe tiger toe hollers go miny
meeny Catch by If let Eeny MOE!
miny a the he him meeny

Input

7

Output

Eeny by him
meeny the go
miny toe Eeny
moe If meeny
Catch he miny
a hollers MOE!
tiger let

Input

1

Output

Eeny meeny miny moe Catch a tiger by the toe If he hollers let him go Eeny meeny miny MOE!

Input

21

Output

Eeny
meeny
miny
moe
Catch
a
tiger
by
the
toe
If
he
hollers
let
him
go
Eeny
meeny
miny
MOE!
\$\endgroup\$
14
  • 1
    \$\begingroup\$ Will the input ever be greater than the number of words present? \$\endgroup\$
    – Doorknob
    Commented Jan 20, 2016 at 0:18
  • 7
    \$\begingroup\$ Should "catch a" and "if he" and "by his"/"by the" be treated as two words or one? In the song, they only count as one "point" \$\endgroup\$
    – AAM111
    Commented Jan 20, 2016 at 2:38
  • 4
    \$\begingroup\$ We always ended with "My...mother...said...to...pick...the...very...best...one...and...you...are...IT!" That would be a cool bonus. Of course, the cheaters always dragged out the "you" and the "are" over several people... \$\endgroup\$ Commented Jan 20, 2016 at 21:52
  • 1
    \$\begingroup\$ @ThisSuitIsBlackNot NOOO (Darth Vader voice)! You stole my line. I literally logged on to PPCG just to write that since I've been thinking about it for the past two days since I saw this. \$\endgroup\$ Commented Jan 22, 2016 at 3:26
  • 1
    \$\begingroup\$ Not so fun fact: Tiger used to be the N word. \$\endgroup\$
    – DanTheMan
    Commented Jan 24, 2016 at 15:11

12 Answers 12

6
\$\begingroup\$

Pyth, 103 89 84 chars

Saved 18 bytes with string compression, thanks to @Dennis and @FryAmTheEggman
Saved another byte thanks to @isaacg

Warning: there are many unprintables in the code; use the links below to try it.

VQjd%Q>cs[J."@y)òÎ5O¹c×Ú"."@yæ\J}ÇZH66¥ÓÀD¸¶=ðÉ §J%ÔþÖúÅ="J"MOE!")\@N

Try it online | Test suite

Could probably be golfed. Suggestions welcome!

How it works

VQjd%Q>cs[J."..."."..."J"MOE!")\@N    Implicit: Q = eval(input)
VQ                                    For each item N in range 0...int(Q):
         [                    )        Create an array out of the following:
          J."..."                       Set J to this string, decompressed. ("Eeny@meeny@miny@")
                 ."..."                 This string, decompressed. ("moe@[email protected]@him@go@")
                       J                J.
                        "MOE!"          "MOE!".
        s                              Join the array with the empty string.
       c                       \@      Split the result on "@".
      >                          N     Cut off the first N items.
    %Q                                 Take every Qth item.
  jd                                   Join with spaces.
\$\endgroup\$
8
  • \$\begingroup\$ Reusing Eeny meeny miny somehow should save a few bytes. Also, Pyth has two built-ins for (de)compression (.Z and ."). \$\endgroup\$
    – Dennis
    Commented Jan 20, 2016 at 1:30
  • \$\begingroup\$ @Dennis Thanks, ." saves 14 bytes! \$\endgroup\$ Commented Jan 20, 2016 at 1:34
  • \$\begingroup\$ Does Pyth use UTF-8 or something else? This is 89 chars but 123 bytes \$\endgroup\$
    – Downgoat
    Commented Jan 20, 2016 at 2:19
  • \$\begingroup\$ @Doᴡɴɢᴏᴀᴛ Pyth uses ISO 8859-1 by default, so each character is exactly one byte. \$\endgroup\$
    – Dennis
    Commented Jan 20, 2016 at 2:22
  • \$\begingroup\$ FNQ == VQ, by the way. \$\endgroup\$
    – isaacg
    Commented Jan 20, 2016 at 4:50
5
\$\begingroup\$

TeaScript, 82 bytes

D`${a="Ey Ú9y ·ny "}¶e C® a g by e e If  Ò@s ¤t m go ${a}MOE!`q.KαtΣj═)j╝

Decompress, chunk, transpose, join, output.

Explanation

              // Implicit: x = input
D`...blah...` // Decompress "Eeny miny moe..."
q             // Split
Kα            // chunk into x-size blocks (α == x)
t             // Transpose
Σ             // Loop through lines
j═)             // Join with spaces
j╝            // Join with newline

Try it online


Non-competing 81 byte

The α wasn't getting chained . so I had to bug fix this

D`${a="Ey Ú9y ·ny "}¶e C® a g by e e If  Ò@s ¤t m go ${a}MOE!`qKαtΣj═)j╝
\$\endgroup\$
5
\$\begingroup\$

Jelly, 84 bytes

“£Dṡ“Ṙ©“Ė“¡Ḳ⁵“=U“¡Ẹ⁵“¡Ṇm“ȯf“ŀQ“ÞṖċ¥“ṅ_“Ẉ1“¡æḷ“¡ƒmxĠ“¡ṇƭEỤr“¡Þ¦»ṫ-2;;“MOE!”W¤sƓZj€⁶j⁷

Try it online!

\$\endgroup\$
1
  • 4
    \$\begingroup\$ Compressing the string by hand was... entertaining. The score would be a lot better if Jelly had a split at occurrences function. \$\endgroup\$
    – Dennis
    Commented Jan 20, 2016 at 1:20
5
\$\begingroup\$

JavaScript (ES6), 167 bytes

l=Array(n=+prompt()).fill``;`${s=`Eeny meeny miny `}moe Catch a tiger by the toe If he hollers let him go ${s}MOE!`.split` `.map((w,i)=>l[i%n]+=w+` `);alert(l.join`
`)

Explanation

l=Array(              // l = array of lines
  n=+prompt()         // n = input number
).fill``;             // initialise l as empty strings

`${s=`Eeny meeny miny `}moe Catch a tiger by the toe If he hollers let him go ${s}MOE!`

.split` `.map((w,i)=> // for each word w
  l[i%n]+=w+` `       // add it to the lines
);
alert(l.join`
`)                    // output the lines
\$\endgroup\$
3
  • \$\begingroup\$ Does l=Array(n).fill`` not work for some reason? \$\endgroup\$ Commented Jan 20, 2016 at 1:43
  • \$\begingroup\$ @ETHproductions It works. I just forgot to shorten it somehow haha! Thanks. \$\endgroup\$
    – user81655
    Commented Jan 20, 2016 at 1:56
  • \$\begingroup\$ @user81655 I love JS prompt() windows. They are just so fun. (I know that sounds crazy but I mean in comparison to every other language's console.out or equivalent print type expression) \$\endgroup\$ Commented Jan 20, 2016 at 5:08
4
\$\begingroup\$

Haskell, 160 157 bytes

import Data.Lists
unlines.map unwords.transpose.(`chunksOf`(["moe Catch a tiger by the toe If he hollers let him go","MOE!"]>>=words.("Eeny meeny miny "++)))

Prepend "Eeny meeny miny " to the other parts ("moe Catch ..." and "MOE!"), concatenate both strings, split into words, take chunks of required size, transpose and concatenate again into a single string.

@Mauris found 3 bytes by factoring out the common substring "Eeny meeny miny " and making f pointfree.

\$\endgroup\$
5
  • \$\begingroup\$ Maybe s="Eeny meeny miny " saves some bytes. \$\endgroup\$
    – lynn
    Commented Jan 20, 2016 at 1:02
  • \$\begingroup\$ @Mauris: I tried, but it was longer. \$\endgroup\$
    – nimi
    Commented Jan 20, 2016 at 1:05
  • \$\begingroup\$ @Mauris: ... oh no, it has the same length. \$\endgroup\$
    – nimi
    Commented Jan 20, 2016 at 1:07
  • \$\begingroup\$ How about f=unlines.map unwords.transpose.(`chunksOf`(["moe Catch a tiger by the toe If he hollers let him go","MOE!"]>>=words.("Eeny meeny miny "++))) \$\endgroup\$
    – lynn
    Commented Jan 20, 2016 at 16:01
  • \$\begingroup\$ @Mauris: Nice. Once f is completely pointfree we can omit even the name. \$\endgroup\$
    – nimi
    Commented Jan 20, 2016 at 19:25
3
\$\begingroup\$

Ruby, 160 bytes

puts (a=[*%w[Eeny meeny miny moe Catch a tiger by the toe If he hollers let him go Eeny meeny miny MOE!].each_slice(gets.to_i)])[0].zip(*a[1..-1]).map{|x|x*' '}

All my attempts at "compressing" the string have just made it longer. Still trying...

puts                      # output to STDOUT...
(a=                       # assign this stuff to the variable a
 [*                       # convert to array...
  %w[blah blah]           # %w splits on spaces
  .each_slice(gets.to_i)  # split into slices of input number
 ]
)[0]                      # take the first element of a
.zip(*a[1..-1])           # zip it with the remaining elements
                          #   because transpose complains about ragged 2D arrays
.map{|x|x*' '}            # join all sub-arrays on space
                          #   puts automatically inserts newlines for us
\$\endgroup\$
3
\$\begingroup\$

Python 2, 154 147 bytes

EDIT: Thanks Joe Willis!

i=input()
s='Eeny meeny miny '
for j in range(i):print' '.join((s+'moe Catch a tiger by the toe If he hollers let him go '+s+'MOE!').split()[j::i]) 

This uses the trick that [0::n] prints the nth element of the list.

Try it here

\$\endgroup\$
1
  • \$\begingroup\$ Ouch. Well you just totally destroyed my answer. LOL. I'm going to try your tip later today about the print("\n"). What exactly does :: operator do? Is that like for in loop? \$\endgroup\$ Commented Jan 20, 2016 at 14:53
3
\$\begingroup\$

JavaScript (ES6), 189 bytes:

a=prompt(),b=Array(a--).fill``,c=0;"Eeny meeny miny moe Catch a tiger by the toe If he hollers let him go Eeny meeny miny MOE!".split` `.map(v=>(b[c]+=v+' ',c+=c>a-1?-c:1));alert(b.join`\n`)

Explanation:

a=prompt(), //Get the STDIN
b=Array(a--).fill``, //Make an array based on how many kids there are
c=0; //Start the iteration variable
"Eeny meeny miny moe Catch a tiger by the toe If he hollers let him go Eeny meeny miny MOE!"
.split` `.map(
    v=>(
        b[c] += v + ' ',
        c += c > a - 1 ? -c : 1
    )
);alert(b.join`\n`)
\$\endgroup\$
5
  • \$\begingroup\$ Your input method is correct, but the output method is not accepted. You can, however, wrap it all in a function, receiving the input as an argument. You can try the following: I=>(b=Array(I--).fill``,c=0,"Eeny meeny miny moe Catch a tiger by the toe If he hollers let him go Eeny meeny miny MOE!".split` `.forEach(v=>(b[c]+=v+' ',c+=c>I-1?-c:1)),b), which is 172 bytes long. It returns each line as an element in the array. I think this is acceptable. \$\endgroup\$ Commented Jan 20, 2016 at 16:00
  • \$\begingroup\$ By the way, if you use .map() instead of .forEach(), you can save 3 bytes, reducing to 169 bytes. With a bit more of fiddling, this might actually be tweetable! \$\endgroup\$ Commented Jan 20, 2016 at 16:24
  • \$\begingroup\$ @IsmaelMiguel The question asks for input and output to be specifically through STDIN and STDOUT so I think it limits JavaScript answers to prompt and alert unfortunately. \$\endgroup\$
    – user81655
    Commented Jan 21, 2016 at 0:26
  • \$\begingroup\$ Oh, I see. I will update the code when I get a chance. Thanks for informing me :-) \$\endgroup\$
    – Quill
    Commented Jan 21, 2016 at 0:32
  • \$\begingroup\$ @user81655 You are correct. It should have an alert(b.join`<newline>`) at the end. But the damage can still be reduced with .map(), instead of .forEach(). \$\endgroup\$ Commented Jan 21, 2016 at 9:58
3
\$\begingroup\$

Python 3, 279 278 272 173 bytes

(thanks to Mathias Ettinger who literally saved me 100+ BYTES!)

s=" Eeny meeny miny moe Catch a tiger by the toe If he hollers let him go Eeny meeny miny moe!";w=s.split();i=input();i=int(i)
for z in range(i):W=w[z::i];print(" ".join(W))  

If anyone has tips or sugestions I'd really appreciate them. Thanks!

\$\endgroup\$
11
  • \$\begingroup\$ I think you've misunderstood what the input represents. It's not the line number to show, it's the number of children among which to divide the words. Every line should be displayed. In your code, int(i) should take the place of 3, but there are other errors to fix after that. \$\endgroup\$ Commented Jan 20, 2016 at 3:44
  • \$\begingroup\$ @Hand-E-Food okay I believe it works as you specified now! \$\endgroup\$ Commented Jan 20, 2016 at 4:02
  • \$\begingroup\$ That looks better! :-) And if you want some golfing help, investigate the Modulo operator, usually written as %. It's ideal for cyclic counters. \$\endgroup\$ Commented Jan 20, 2016 at 5:04
  • \$\begingroup\$ @Hand-E-Food ok thanks! I think I know what you are getting at. I am going to fix this up tomorrow. I think I can shave at least a couple bytes off. \$\endgroup\$ Commented Jan 20, 2016 at 5:06
  • \$\begingroup\$ A few points that serves both at best practices and help shorten the code: 1) .split() will split on blanks (space, newlines, tabs) 2) range(0, x) is best written as range(x) 3) have a look at slice notation: w[0::3] will return a list of every three words in w. \$\endgroup\$ Commented Jan 20, 2016 at 13:47
2
\$\begingroup\$

Mathematica, 154 bytes

StringRiffle[Thread@Partition[StringSplit@"Eeny meeny miny moe Catch a tiger by the toe If he hollers let him go Eeny meeny miny MOE!",#,#,1,""],"
"," "]&

Uses the split-chunk-transpose-join-output method of most of the other answers.

\$\endgroup\$
2
\$\begingroup\$

MATLAB, 167 bytes/characters:

n=input('');s='Eeny meeny miny ';s=strsplit([s 'moe Catch a tiger by the toe If he hollers let him go ' s 'MOE!']);f=@fprintf;for i=1:n f('%s ',s{i:n:end});f('\n');end

Explanation:

n=input('');             % Grab the input (number of children)
s='Eeny meeny miny ';    % Common string portion
% Build the full string and split into cell array at spaces
s=strsplit([s 'moe Catch a tiger by the toe If he hollers let him go ' s 'MOE!']);
f=@fprintf;              % Just a shorthand for later (only saves 1 char here)
for i=1:n                % Loop to the number of children
    f('%s ',s{i:n:end}); % Print each nth word, shifted by child
    f('\n');             % Start each child's words on a new line
end

Won't be winning any awards for the length of this one, but it was fun. :-)

\$\endgroup\$
2
\$\begingroup\$

Japt, 90 87 86 bytes

Uo mW{V=`EydÚ9yd·nyd` +`¶C®»dgdbydÈIfddÒ@sd¤tdmdgod{V}MOE!` qd f@Y%U¥W} m¸·

Lots of unprintables. Try it online!

How it works

              // Implicit: U = input
Uo mW{     }  // Create the range 0...U and map each item W to:
V=`...`       //  Set V to this string, decompressed. "Eenydmeenydmined"
+`...{V}MOE!` //  Concatenate it with this string, decompressed, with V inserted.
qd            //  Split at "d"s.
f@Y%U¥W       //  Filter to only the items where (index % U == W).
m¸            // Map each item by joining with spaces.
·             // Join the result with newlines.

I've tried compressing the string with different delimiters. The only thing more efficient than spaces would be a lowercase letter, but most of these are already used, and thus, can't be used to split the string. Here's how much compression is achieved with the remaining ones:

space -> 69 bytes
c -> 66 (including a null byte)
d -> 65
j -> 69
k -> 69
p -> 68
q -> 69
s -> 61 (but there's an s in "hollers")
u -> 65
w -> 67
x -> 69
y -> 69

Currently I'm using d. It may be possible to save a byte with s, substituting some other letter in hollers.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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