22
3
Minecraft 1.12 will be released tomorrow, so let's celebrate!
Write code that takes in a non-negative integer N which represents the number of items of something in Minecraft. Output it in a way more helpful to players, giving the number of chests, stacks, and items N is equivalent to. Use the format
XcYsZi
where
X
is the number of chests you can completely fill with N items,Y
is the number of stacks you can fill with the items remaining after filling chests,Z
if the number of items remaining after filling chests and stacks.
Note that:
- 64 items fit in a stack. (We'll ignore items that stack to 16 or don't stack.)
- 27 stacks fit in a chest. (These are single chests, not double chests.)
So it would never make sense if Y
is more than 26 or if Z
is more than 63.
A caveat with the format is that if there is zero of something, that term is not printed.
So, for example, if
Y
were zero andX
andZ
nonzero, the format would look likeXcZi
.Likewise if
Y
andZ
were zero andX
nonzero, the format would beXc
.The exception here is when N is zero. Then
0i
is the output rather than an empty string.
You can assume all N items are of the same type, hence all stackable.
You may not output a list or tuple of three numbers. You must give a string with the exact "csi" notation, in that order, with no spaces or commas.
For reference, here's a chest completely filled with stacks of items:
Testcases
in -> out
0 -> 0i
1 -> 1i
2 -> 2i
62 -> 62i
63 -> 63i
64 -> 1s
65 -> 1s1i
66 -> 1s2i
127 -> 1s63i
128 -> 2s
129 -> 2s1i
200 -> 3s8i
512 -> 8s
1337 -> 20s57i
1664 -> 26s
1727 -> 26s63i
1728 -> 1c
1729 -> 1c1i
1791 -> 1c63i
1792 -> 1c1s
1793 -> 1c1s1i
4096 -> 2c10s
5183 -> 2c26s63i
5184 -> 3c
5200 -> 3c16i
9999 -> 5c21s15i
385026 -> 222c22s2i
1000000000 -> 578703c19s
The shortest code in bytes wins.
1Related – Leaky Nun – 2017-06-07T06:18:41.560
33ok apparently this is a crime scene investigation – Okx – 2017-06-07T06:30:16.910
1Related. – Martin Ender – 2017-06-07T06:39:52.570
@Okx I read the title and thought it was going to be some form of Clue/Cluedo but for minecraft. – caird coinheringaahing – 2017-06-07T15:13:00.427
@Okx with all the spinoffs that wouldn't be surprising. Now we need a challenge with drawing a chalk outline -- of a creeper perhaps – Chris H – 2017-06-08T09:01:09.903
Mulling it over now, but I don't think this challenge can be done in Minecraft. No way to concatenate the output string. Maybe I could display the result as an actual pile of chests, blocks, and items :) – BradC – 2017-06-08T21:06:15.997