31
Introduction:
I think we all know it, and it has probably been translated in loads of different languages: the "Head, Shoulders, Knees and Toes" children song:
Head, shoulders, knees and toes, knees and toes
Head, shoulders, knees and toes, knees and toes
And eyes and ears and mouth and nose
Head, shoulders, knees and toes, knees and toes
wikipedia
Challenge:
Input: A positive integer.
Output: Output one of the following words based on the input as n-th index:
head
shoulders
knees
toes
eyes
ears
mouth
nose
Here the body parts are appended with the indexes:
Head (0), shoulders (1), knees (2) and toes (3), knees (4) and toes (5)
Head (6), shoulders (7), knees (8) and toes (9), knees (10) and toes (11)
And eyes (12) and ears (13) and mouth (14) and nose (15)
Head (16), shoulders (17), knees (18) and toes (19), knees (20) and toes (21)
Head (22), shoulders (23), knees (24) and toes (25), knees (26) and toes (27)
Head (28), shoulders (29), knees (30) and toes (31), knees (32) and toes (33)
And eyes (34) and ears (35) and mouth (36) and nose (37)
Head (38), shoulders (39), knees (40) and toes (41), knees (42) and toes (43)
etc.
Challenge rules:
- You are of course allowed to use 1-indexed input instead of 0-indexed. But please specify which one you've used in your answer.
- The output is case insensitive, so if you want to output it in caps that's fine.
- You should support input up to at least 1,000.
General rules:
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language. - Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code.
- Also, please add an explanation if necessary.
Test cases (0-indexed):
Input: Output:
0 head
1 shoulders
7 shoulders
13 ears
20 knees
35 ears
37 nose
98 knees
543 nose
1000 knees
3Added the kolmogorov complexity tag since most answers will probably use the input as a cyclic index into a constant array, whose generation will dominate the byte count. – Martin Ender – 2016-11-17T12:54:16.977
@MartinEnder Thanks. I, incorrectly, only used
– Kevin Cruijssen – 2016-11-17T13:00:42.850kolmogorov-complexity
for answers that always have the same fixed output, but now I see that's it about fixed output-strings in the code, and finding patterns to golf it (or encode it like with @Enigma's 05AB1E answer). Thanks for adding it; I wasn't too sure what tags were relevant for this challenge, which was one of my (unfortunately unanswered) questions in the Sandbox.1Relevant meta post about usage of the tag. – Martin Ender – 2016-11-17T13:01:58.920
I think I found where this one drew inspiration from... – Erik the Outgolfer – 2016-11-17T15:06:56.657
@EriktheGolfer I had no idea someone else posted a similar question in the sandbox. I had searched for it on the non-meta site and couldn't find anything. I was actually inspired by it because a colleague of mine was in a very childish mood and was singing it (including actually touching the body parts.. >.>) Sorry @Neil, I really should learn to check the sandbox as well when I post a question.. (although yours is a bit different than the one I posted). – Kevin Cruijssen – 2016-11-17T15:11:16.687
1@KevinCruijssen At least your question caught some +1's :) (optimistic remark) You can search in the sandbox using
inquestion:2140 shoulders
. – Erik the Outgolfer – 2016-11-17T15:15:24.8733Did anyone else got this song stuck in their head all day?... – Kevin Cruijssen – 2016-11-18T10:38:49.140
The usual practise for singing this song when I was younger was to sing it repeatedly and remove additional words each time. So second time would be "heads, shoulders, knees and _, knees and _" and so on. Would be interesting to add that in also :-D – Fogmeister – 2016-11-19T15:42:45.310