Answer by Razetime for Spiral Permutation Sequence
APL (Dyalog Extended), 2519 14 bytes{2⊥⍨3⍴⌊√⍵-1}-⊢-6 bytes from Adám.-5 bytes from Bubbler.Try it online!A direct implementation of the last function mentioned on the OEIS...
View ArticleAnswer by Fatalize for Spiral Permutation Sequence
Brachylog, 20 bytes-1$r$[I*I+I+1=*2-?=.This uses the same technique as pretty much all other answers.Explanation-1 § Build the expression Input - 1 $r § Square root of Input - 1 $[I § Unify I with the...
View ArticleAnswer by Neil for Spiral Permutation Sequence
ES7, 3128 26 bytesn=>(m=--n**.5|0)*++m*2-~-nI had independently discovered Alex's formula but I can't prove it because I wasn't near a computer at the time.Edit: Saved 3 bytes partly thanks to...
View ArticleAnswer by Luis Mendo for Spiral Permutation Sequence
MATL, 16 13 bytesqX^Y[tQ*Q2*G-Based on Lynn's CJam answer.Try it online! (Y[ has been replaced by k according to changes in the language)q % input n. Subtract 1X^ % square rootY[ % floortQ % duplicate...
View ArticleAnswer by Alex A. for Spiral Permutation Sequence
Julia, 28 bytesn->2((m=isqrt(n-1))^2+m+1)-nThis is a lambda function that accepts an integer and returns an integer. To call it, assign it to a variable.We define m to be the largest integer such...
View ArticleAnswer by Denker for Spiral Permutation Sequence
Pyth, 21 bytesK2-h+^.E@QKK^t.E@QKKQTry it online!Nothing fancy going on. Same method as in the JAPT answer.
View ArticleAnswer by lirtosiast for Spiral Permutation Sequence
Jelly, 11 10 bytes’ƽð²+ḷ‘Ḥ_Another Jelly answer on my phone.’ƽð²+ḷ‘Ḥ_ A monadic hook:’ƽ Helper link. Input: n’ n-1ƽ Atop integer square root. Call this m.ð Start a new dyadic link. Inputs: m,...
View ArticleAnswer by Lynn for Spiral Permutation Sequence
CJam, 14 bytesqi_(mQ7Ybb2*\-Using Alex's approach: 2*(m^2+m+1)-n where m = isqrt(n-1).
View ArticleAnswer by ETHproductions for Spiral Permutation Sequence
Japt, 2019 16 bytesV=U¬c)²-V *2-U+2Test it online!Based on the observation thatOr, rather, thatI don't know if this explanation is on the OEIS page, as I haven't looked at it yet.
View ArticleSpiral Permutation Sequence
We can roll up the natural numbers in a rectangular spiral: 17--16--15--14--13 | | 18 5---4---3 12 | | | | 19 6 1---2 11 | | | 20 7---8---9--10 | 21--22--23--24--25But now that we have them on a...
View Article
More Pages to Explore .....