| Bytes | Lang | Time | Link |
|---|---|---|---|
| 003 | Vyxal | 240820T201408Z | emanresu |
| 155 | Perl 5 + p0513 | 240820T200438Z | Dom Hast |
| 003 | APL | 141020T043751Z | jimmy230 |
| 004 | GolfScript | 141018T220245Z | Optimize |
| 007 | Golfscript | 141018T084931Z | John Dvo |
Vyxal, N=3
› ›
››
0
Unrolled:
››
›
0 ›
››
0 › ›
›
0 › ››
0 › ›››
› increments a number, so the rolled version prints 0, the once-unrolled version prints 0+1=1, the twice-unrolled version prints 0+1+1=2 and so on. This could probably be extended to arbitrary-sized grids.
Perl 5 + -p0513, 155 bytes, N=12
Not particularly competitive, but it was fun trying to get to this point. I tried with 1s originally, but struggled to make it work with 1s only separated by newlines. Also investigated using just list length (N=6) but had issues without using length and join.
# #
# #;
# # w
# # q
# # ,
## '
# # '
# # n
# # i
# # o
# #j
$\+=length
APL, N = 3
201
340
5|0
Unrolled:
32
40
5|001
43
5|00102
4
5|001023
5|0010234
It calculates the remainder of that number divided by 5. Only the result of last line is printed.
APL, N = 2
⍬∞
≡0
Unrolled:
⍬
≡0∞
≡0∞⍬
≡ returns the depth (not to be confused with the dimension or length) of an array:
0is not an array. So the depth is 0.0∞is an array with two items0and∞(infinity). It has depth 1.0∞⍬has another item⍬, which is an empty array with depth 1. So0∞⍬has depth 2.
These two programs also works in the online interpreter. I'm not sure if the later one is syntactically correct.
⍬0
≡∞
⍬¯
≡0
APL, for any N >= 4
For N = 4:
∞ ∞
∞∞
∞ ∞
⍴1↓∞
Fully unrolled:
⍴1↓∞ ∞ ∞ ∞ ∞∞∞
For N = 5:
∞ ∞
∞ ∞
∞∞
∞ ∞
⍴1↓ ∞
Fully unrolled:
⍴1↓ ∞ ∞ ∞ ∞ ∞ ∞ ∞∞∞
1↓ removes an item in the array. It also returns the empty array if the argument is scalar. ⍴ gets the array length.
GolfScript, N = 4
This one right rolls as original spec.
.. .
...#
.#.~
],8-
Here are the unrolls:
...
#..
..
],8-~#.
.#.
...
],8-~#. ..
..
.#
],8-~#. ....
..
],8-~#. ....#.
.
],8-~#. ....#..
],8-~#. ....#...
Golfscript, N <- [5,7..]
. .
. .
..
. .#
],9\-
Fully unrolled:
],9\-# . . . . . ...
Explanation:
.(multiple times) - duplicate the input]- collect the stack into a single array,- take its length9\-- subtract it from 9#- line comment
Whitespace is a NOP, but any other NOP would have worked just as well.
Fully rolled up, it uses nine copies of the input (contents ignored) as the stack; 9 - 9 = 0; it has not been unrolled.
Each unroll hides one more dot (duplicate) behind the comment, shrinking the stack once, incrementing the output.
Fully unrolled, it uses only the input (contents ignored) as the stack; 9 - 1 = 8; it has been unrolled 8 times.
The same approach works for any N > 4: Change 9 to the appropriate value of 2*N+1, then extend the pattern of dots (duplicate) using the same spiral pattern that ensures exactly one dot gets unrolled during each unroll.