Can you outgolf me? (Robbers section)
Jelly, 5 4 bytes, George V. Williams
RÆḊḞ
Try it here.
A hidden feature!
If I remembered correctly, ÆḊ
(A) = sqrt(det(AAT)) is n! times the n dimensional Lebesgue measure of a simplex formed by n input point and the origin in m dimensional space. When n=1 it degenerate to the Euclidean distance. Not that weird after all...
Hexagony, 91 33 bytes, Blue
1""?{\>{+/</+'+./_'..@'~&/!}'+=($
Unfolded:
1 " " ?
{ \ > { +
/ < / + ' +
. / _ ' . . @
' ~ & / ! }
' + = ( $
. . . .
Try it online!
Still looks somewhat golfable but I figured I'd post it before FryAmTheEggman beats me to it. ;)
Explanation
Here are some colour-coded execution paths:
However, these are unnecessarily convoluted due to golfing. Here is the exact same code with a saner layout:
That's better. And finally, here is a memory diagram, where the red arrow indicates the initial position and orientation of the memory pointer (MP):
The gist is that I'm iteratively computing Fibonacci numbers on the three edges labelled f(i), f(i+1) and f(i+2) while keeping track of the iterator on the edges A, B and C. While doing so the roles of these edges are swapped out cyclically after each iteration. Let's see how this happens...
The code starts on the grey path which does some initial setup. Note that f(i) already has its correct initial value of 0
.
1 Set edge f(i+1) to 1.
"" Move the MP to edge A.
? Read input n into edge A.
) Increment n.
Now the green path is the main loop. _
and >
are just mirrors.
( Decrement n.
< If the result is zero or less, continue on the red path, otherwise
perform another iteration of the main loop.
{ Move the MP to edge f(i+2).
+ Add edges f(i) and f(i+1) into this edge, computing the next Fibonacci number.
' Move the MP to the edge opposite A.
~ Multiply by -1 to ensure that it's non-positive (the edge may have a positive
value after a few iterations).
& Copy the current value of n from A.
' Move back and to the right again.
+ Copy n by adding it to zero. Since we know that the other adjacent edge
is always zero, we no longer need to use ~&.
'+'+ Repeat the process twice, moving n all the way from A to B.
= Reverse the orientation of the MP so that it points at f(i) which now
becomes f(i+2) for the next iteration.
This way, the MP moves around the inner triplet of edges, computing successive Fibonacci numbers until n
reaches zero. Then finally the red path is executed:
{} Move the MP to f(i).
! Print it.
@ Terminate the program.
Diagrams generated with Timwi's HexagonyColorer and EsotericIDE.
Cheddar, 7 6 bytes, Downgoat
(<<)&1
This seems to work, but it's always possible that I don't understand the language correctly.