22
2
Welcome to the grinder.
Your task is to make big rocks into small rocks by grinding them.
Take an input of a big rock of size n > 3
and grind it.
Continue to grind the rocks by dumping them into the grinder until the size of all the rocks are 2
.
rocks are always grinded into equal even halves. If the result of a grinding is odd take result - 1.
Print the output of each grinding as you proceed.
Examples
input: 5
output: 22
The result are two rocks of size 2
input: 50
output:
2424 //two rocks of size 24
12121212 //four rocks of size 12
66666666 //8 rocks of size 6
2222222222222222
the result is 16 rocks of size 2
input: 30
output:
1414
6666
22222222
the result is 8 rocks of size 2
This is code-golf so the shortest code wins! Have fun and good luck!
You can expect it to be above 3. – jacksonecac – 2016-12-02T13:33:02.827
Do we have to use your format (all numbers concatenated) or can we use things like lists? Some answers seem to do that instead. – Fatalize – 2016-12-02T14:01:02.413
As long as the output displays each iteration the format does not need to be like above. – jacksonecac – 2016-12-02T14:03:21.080
...does that go as far as being allowed to output he input too? e.g. for input
50
could output be[50, [24, 24], [12, 12, 12, 12], [6, 6, 6, 6, 6, 6, 6, 6], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]
? – Jonathan Allan – 2016-12-02T14:07:08.347@JonathanAllan a single array is fine, a 2d array doesnt really fit the requirements. – jacksonecac – 2016-12-02T14:09:52.047
1I would say a 2d array does and a 1d does not , but it's up to you so OK. – Jonathan Allan – 2016-12-02T14:15:04.533
@JonathanAllan just answer the dang question :P – jacksonecac – 2016-12-02T14:16:54.253
Can we assume input will always be <100? <256? – undergroundmonorail – 2016-12-02T14:21:50.463
is it a program, or function? is initial number should be read from stdin or can be passed as argument? – user902383 – 2016-12-02T17:54:42.360
1
@user902383 either is fine unless specified in the challenge as per meta consensus. As for input and output, again both are fine - see this post.
– Jonathan Allan – 2016-12-02T20:17:09.747