Eeny, Meeny, Miny, Moe


11

소개

어린 시절의 노래 Eeny, meeny, miny, moe 는 종종 태그를 재생할 때 누가 "그것"인지 선택하는 데 사용되었습니다. 모든 사람은 원 안에 서서 무작위로 선택된 한 사람을 가리 킵니다. 그들은 노래 할 것이다 :

Eeny, meeny, miny, moe,
발가락으로 호랑이를 잡아라.
그가 외면한다면, 그를
보내라, Eeny, meeny, miny, moe.

그들은 각 단어를 부를 때 원의 다음 사람을 가리 켰습니다. 마지막 "moe"가 불려질 때 지적 된 사람은 "it"입니다. 아이들은 즉시 일어나서 흩어졌습니다.

입력, 자식 수 및 지정된 시점에서 노래 된 단어를 나열하는 가장 짧은 프로그램을 바이트 단위로 구현하십시오.

우승자는 1 주일 이내에 선발됩니다.

입력

STDIN에서, 단일의 양의 정수인 하위 수. 노래의 단어 수보다 많을 수 있습니다.

산출

STDOUT에 각 줄이 자식을 나타내고 가리키는 단어라는 노래가 포함 된 목록을 씁니다. 자식이 너무 많으면 빈 줄이 생략 될 수 있습니다.

요구 사항

  • 항상 첫 번째 아이부터 시작하십시오.
  • 문장 부호없이 단어를 표시하십시오.
  • 마지막 "moe"는 "MOE!"로 강조되어야합니다. 구두점 포함

입력

3

산출

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

입력

7

산출

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

입력

1

산출

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

입력

21

산출

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

1
입력이 존재하는 단어의 수보다 많을까요?
Doorknob

7
"a"와 "if he"와 "by his"/ "the"를 두 단어 나 하나로 취급해야합니까? 노래에서, 그들은 단지 하나의 "포인트"로 간주합니다
OldBunny2800

4
우리는 항상 "나 ... 어머니 ... 말했어 ... 선택 ... 매우 ... 최고 ... 하나 ... 그리고 ... 너 ..." ...그것!" 멋진 보너스가 될 것입니다. 물론, 사기꾼들은 항상 "당신"과 "사람"을 여러 사람들로
끌어 내 렸습니다

1
트윗 담아 가기 내 선을 훔 쳤어 나는 이것을 보았을 때부터 지난 이틀 동안 그것에 대해 생각한 이래로 PPCG에 문자 그대로 로그온했습니다.
Ashwin Gupta

1
별로 재미 있지 않은 사실 : Tiger는 N 단어였습니다.
DanTheMan

답변:


5

티 스크립트 , 82 바이트

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

압축 해제, 청크, 조옮김, 결합, 출력.

설명

              // 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

온라인으로 사용해보십시오


비경쟁 81 바이트

α체인 점점되지 않았다 .나는 버그 수정이에 있었다 있도록

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

6

Pyth, 103 89 84 자

@Dennis 및 @FryAmTheEggman 덕분에 문자열 압축으로 18 바이트 절약 @isaacg
덕분에 다른 바이트 절약

경고 : 코드에는 인쇄 할 수없는 항목이 많이 있습니다. 아래 링크를 사용하여 사용해보십시오.

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

온라인으로 사용해보십시오 | 테스트 스위트

아마 골프를 쳤다. 제안을 환영합니다!

작동 원리

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@Catch@...let@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.

Eeny meeny miny어떻게 든 재사용 하면 몇 바이트를 절약해야합니다. 또한 Pyth에는 압축 해제 ( .Z.")를 위한 두 가지 기본 제공 기능이 있습니다.
Dennis

@Dennis Thanks, ."14 바이트를 절약합니다!
ETHproductions

Pyth는 UTF-8 또는 다른 것을 사용합니까? 이것은 89 개의 문자이지만 123 바이트입니다
Downgoat

@ Doᴡɴɢᴏᴀᴛ Pyth는 기본적으로 ISO 8859-1을 사용하므로 각 문자는 정확히 1 바이트입니다.
Dennis

FNQVQ그런데 == .
isaacg

5

젤리, 84 바이트

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

온라인으로 사용해보십시오!


4
손으로 줄을 압축하는 것은 ... 즐거웠습니다. 만약 Jelly가 발생 함수 에서 분리 한다면 점수는 훨씬 더 나을 것 입니다.
Dennis

5

자바 스크립트 (ES6), 167 바이트

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`
`)

설명

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

않습니다 l=Array(n).fill`` 어떤 이유로 작동하지?
ETHproductions

@ETHproductions 작동합니다. 어떻게 든 하하를 단축하는 것을 잊었습니다! 감사.
user81655

@ user81655 JS prompt () 창을 좋아합니다. 그들은 너무 재미있다. (나는 미친 소리로 들리지만 다른 모든 언어의 console.out 또는 동등한 인쇄 유형 표현과 비교할 때 의미)
Ashwin Gupta

4

하스켈 160 157 바이트

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 "++)))

"Eeny meeny miny "다른 부분 ( "moe Catch ...""MOE!") 앞에 두 문자열을 연결하고, 단어로 분할하고, 필요한 크기의 청크를 가져오고, 단일 문자열로 다시 바꾸고 연결합니다.

@Mauris는 공통 서브 스트링 "Eeny meeny miny"를 f빼내고 포인트를 없앰 으로써 3 바이트를 찾았 습니다.


아마도 s="Eeny meeny miny "바이트를 절약 할 수 있습니다.
Lynn

@ Mauris : 시도했지만 더 길었습니다.
nimi

@Mauris : ... 아, 아니, 같은 길이입니다.
nimi

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

@Mauris : 좋습니다. 일단 f완전히 우리는 심지어 이름을 생략 할 수 있습니다 pointfree된다.
nimi

4

파이썬 2, 154 147 바이트

편집 : 조 윌리스 감사합니다!

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]) 

이것은 [0 :: n]이리스트의 n 번째 요소를 인쇄하는 트릭을 사용합니다.

여기 사용해보십시오


아야. 글쎄, 당신은 내 대답을 완전히 파괴했습니다. LOL. 오늘 나중에 인쇄 ( "\ n")에 대한 팁을 시도하겠습니다. ::운영자는 정확히 무엇을 합니까? 루프에서와 같은가요?
Ashwin Gupta

3

루비, 160 바이트

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*' '}

문자열을 "압축"하려는 모든 시도는 방금 길어졌습니다. 아직 시도 중 ...

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

3

JavaScript (ES6), 189 바이트 :

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`)

설명:

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`)

입력 방법이 정확하지만 출력 방법이 허용되지 않습니다. 그러나 입력을 인수로 수신하여 함수로 모두 랩핑 할 수 있습니다. 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)172 바이트 길이 의 다음을 시도해보십시오 . 각 줄을 배열의 요소로 반환합니다. 나는 이것이 허용된다고 생각한다.
Ismael Miguel

그런데 .map()대신 대신 사용 .forEach()하면 3 바이트를 절약하여 169 바이트로 줄일 수 있습니다. 조금 더 어리둥절 해지면 실제로 트위 블 가능합니다!
Ismael Miguel

@IsmaelMiguel 입력과 출력을 통해 구체적으로에 대한 질문은 물어 STDINSTDOUT내가가 자바 스크립트 답을 제한 생각 때문에 prompt그리고 alert불행하게도.
user81655

아, 알겠습니다 기회가 생기면 코드를 업데이트하겠습니다. 알려 주셔서 감사합니다 :-)
Quill

@ user81655 맞습니다. alert(b.join`<newline>`)끝에 있어야합니다 . 그러나 .map()대신으로 피해를 줄일 수 있습니다 .forEach().
Ismael Miguel

3

파이썬 3, 279 278 272 173 바이트

(말 그대로 나를 100 + 바이트를 구한 Mathias Ettinger에게 감사드립니다 ! )

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))  

누군가가 팁이나 sugestions를 가지고 있다면 정말 감사합니다. 감사!


나는 당신이 입력이 나타내는 것을 오해했다고 생각합니다. 표시 할 줄 번호가 아니라 단어를 나눌 어린이 수입니다. 모든 줄이 표시되어야합니다. 코드에서 int(i)를 대신해야 3하지만 그 후에 수정 해야 할 다른 오류가 있습니다.
Hand-E-Food

@ Hand-E-Food 좋아, 지금 지정한대로 작동한다고 생각합니다!
Ashwin Gupta

더 좋아 보인다! :-) 그리고 당신이 골프 도움을 원한다면, 일반적으로로 작성된 Modulo 연산자를 조사하십시오 %. 주기적 카운터에 이상적입니다.
Hand-E-Food

@ Hand-E-Food 감사합니다! 나는 당신이 무엇을 얻고 있는지 알고 있다고 생각합니다. 내일이 문제를 해결하겠습니다. 나는 적어도 몇 바이트를 면도 할 수 있다고 생각합니다.
Ashwin Gupta 2016 년

코드 단축 모범 사례와 도움에 모두를 제공하는 몇 가지 포인트 : 1) .split()공백 (공백, 줄 바꿈에 분할합니다, 탭) 2) range(0, x)최고로 기록 range(x): 슬라이스 표기를 보라) 3 w[0::3]매 3의 목록을 반환합니다 단어 w.
301_Moved_Permanently

2

Mathematica, 154 바이트

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,""],"
"," "]&

대부분의 다른 답변의 split-chunk-transpose-join-output 방법을 사용합니다.


2

MATLAB, 167 바이트 / 문자 :

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

설명:

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

이 기간 동안 수상을하지는 않았지만 재미있었습니다. :-)


2

apt, 90 87 86 바이트

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

많은 인쇄 할 수없는 것들. 온라인으로 사용해보십시오!

작동 원리

              // 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.

다른 구분 기호로 문자열을 압축하려고했습니다. 공백보다 효율적인 유일한 방법은 소문자이지만 대부분은 이미 사용되므로 문자열을 분할하는 데 사용할 수 없습니다. 나머지 압축으로 얼마나 많은 압축을 달성했는지는 다음과 같습니다.

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

현재 나는을 사용하고 d있습니다. 을 사용하여 s다른 문자를 대체 하여 바이트를 저장할 수 있습니다 hollers.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.