New Order #6: Easter Egg Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The PPCG Site design is on its way - help us make it awesome! Sandbox for Proposed ChallengesNew order #4: WorldNew Order #2: Turn My WayNew Order #1: How does this feel?New Order #5: where Fibonacci and Beatty meet at WythoffNew Order #3: 5 8 6Challenge UlamspiralFind the angle between two pointsTriangular Ulam spiralAsterisk spiralReturn Spiral Indexes!New Order #1: How does this feel?New Order #2: Turn My WayNew Order #3: 5 8 6New order #4: WorldNew Order #5: where Fibonacci and Beatty meet at Wythoff
Is there public access to the Meteor Crater in Arizona?
Resize vertical bars (absolute-value symbols)
Asymptotics question
Printing attributes of selection in ArcPy?
How many morphisms from 1 to 1+1 can there be?
I can't produce songs
What initially awakened the Balrog?
How many time has Arya actually used Needle?
Should a wizard buy fine inks every time he want to copy spells into his spellbook?
Why not send Voyager 3 and 4 following up the paths taken by Voyager 1 and 2 to re-transmit signals of later as they fly away from Earth?
Why are vacuum tubes still used in amateur radios?
How to write capital alpha?
Do I really need to have a message in a novel to appeal to readers?
Is there more forest in the Northern Hemisphere now than 100 years ago?
BITCOIN: on a chart what does it mean for the USD price to be higher then marketcap?
Understanding p-Values using an example
What does 丫 mean? 丫是什么意思?
Monty Hall Problem-Probability Paradox
Project Euler #1 in C++
Why datecode is SO IMPORTANT to chip manufacturers?
"klopfte jemand" or "jemand klopfte"?
Can an iPhone 7 be made to function as a NFC Tag?
The Nth Gryphon Number
What is the chair depicted in Cesare Maccari's 1889 painting "Cicerone denuncia Catilina"?
New Order #6: Easter Egg
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
The PPCG Site design is on its way - help us make it awesome!
Sandbox for Proposed ChallengesNew order #4: WorldNew Order #2: Turn My WayNew Order #1: How does this feel?New Order #5: where Fibonacci and Beatty meet at WythoffNew Order #3: 5 8 6Challenge UlamspiralFind the angle between two pointsTriangular Ulam spiralAsterisk spiralReturn Spiral Indexes!New Order #1: How does this feel?New Order #2: Turn My WayNew Order #3: 5 8 6New order #4: WorldNew Order #5: where Fibonacci and Beatty meet at Wythoff
$begingroup$
Introduction (may be ignored)
Putting all positive integers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive integers. This is the sixth challenge in this series (links to the first, second, third, fourth and fifth challenge).
This challenge has a mild Easter theme (because it's Easter). I took my inspiration from this highly decorated (and in my personal opinion rather ugly) goose egg.

It reminded me of the Ulam spiral, where all positive integers are placed in a counter-clockwise spiral. This spiral has some interesting features related to prime numbers, but that's not relevant for this challenge.

We get to this challenge's permutation of positive integers if we take the numbers in the Ulam spiral and trace all integers in a clockwise turning spiral, starting at 1. This way, we get:
1, 6, 5, 4, 3, 2, 9, 8, 7, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 25, 24, 23, etc.
If you would draw both of the spirals, you'd get some sort of an infinite mesh of (egg shell) spirals (note the New Order reference there).
This sequence is present in the OEIS under number A090861. Since this is a "pure sequence" challenge, the task is to output $a(n)$ for a given $n$ as input, where $a(n)$ is A090861.
Task
Given an integer input $n$, output $a(n)$ in integer format, where $a(n)$ is A090861.
Note: 1-based indexing is assumed here; you may use 0-based indexing, so $a(0) = 1; a(1) = 6$, etc. Please mention this in your answer if you choose to use this.
Test cases
Input | Output
---------------
1 | 1
5 | 3
20 | 10
50 | 72
78 | 76
123 | 155
1234 | 1324
3000 | 2996
9999 | 9903
29890 | 29796
Rules
- Input and output are integers.
- Your program should at least support input in the range of 1 up to 32767).
- Invalid input (0, floats, strings, negative values, etc.) may lead to unpredicted output, errors or (un)defined behaviour.
- Default I/O rules apply.
Default loopholes are forbidden.- This is code-golf, so the shortest answers in bytes wins
code-golf sequence
$endgroup$
add a comment |
$begingroup$
Introduction (may be ignored)
Putting all positive integers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive integers. This is the sixth challenge in this series (links to the first, second, third, fourth and fifth challenge).
This challenge has a mild Easter theme (because it's Easter). I took my inspiration from this highly decorated (and in my personal opinion rather ugly) goose egg.

It reminded me of the Ulam spiral, where all positive integers are placed in a counter-clockwise spiral. This spiral has some interesting features related to prime numbers, but that's not relevant for this challenge.

We get to this challenge's permutation of positive integers if we take the numbers in the Ulam spiral and trace all integers in a clockwise turning spiral, starting at 1. This way, we get:
1, 6, 5, 4, 3, 2, 9, 8, 7, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 25, 24, 23, etc.
If you would draw both of the spirals, you'd get some sort of an infinite mesh of (egg shell) spirals (note the New Order reference there).
This sequence is present in the OEIS under number A090861. Since this is a "pure sequence" challenge, the task is to output $a(n)$ for a given $n$ as input, where $a(n)$ is A090861.
Task
Given an integer input $n$, output $a(n)$ in integer format, where $a(n)$ is A090861.
Note: 1-based indexing is assumed here; you may use 0-based indexing, so $a(0) = 1; a(1) = 6$, etc. Please mention this in your answer if you choose to use this.
Test cases
Input | Output
---------------
1 | 1
5 | 3
20 | 10
50 | 72
78 | 76
123 | 155
1234 | 1324
3000 | 2996
9999 | 9903
29890 | 29796
Rules
- Input and output are integers.
- Your program should at least support input in the range of 1 up to 32767).
- Invalid input (0, floats, strings, negative values, etc.) may lead to unpredicted output, errors or (un)defined behaviour.
- Default I/O rules apply.
Default loopholes are forbidden.- This is code-golf, so the shortest answers in bytes wins
code-golf sequence
$endgroup$
add a comment |
$begingroup$
Introduction (may be ignored)
Putting all positive integers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive integers. This is the sixth challenge in this series (links to the first, second, third, fourth and fifth challenge).
This challenge has a mild Easter theme (because it's Easter). I took my inspiration from this highly decorated (and in my personal opinion rather ugly) goose egg.

It reminded me of the Ulam spiral, where all positive integers are placed in a counter-clockwise spiral. This spiral has some interesting features related to prime numbers, but that's not relevant for this challenge.

We get to this challenge's permutation of positive integers if we take the numbers in the Ulam spiral and trace all integers in a clockwise turning spiral, starting at 1. This way, we get:
1, 6, 5, 4, 3, 2, 9, 8, 7, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 25, 24, 23, etc.
If you would draw both of the spirals, you'd get some sort of an infinite mesh of (egg shell) spirals (note the New Order reference there).
This sequence is present in the OEIS under number A090861. Since this is a "pure sequence" challenge, the task is to output $a(n)$ for a given $n$ as input, where $a(n)$ is A090861.
Task
Given an integer input $n$, output $a(n)$ in integer format, where $a(n)$ is A090861.
Note: 1-based indexing is assumed here; you may use 0-based indexing, so $a(0) = 1; a(1) = 6$, etc. Please mention this in your answer if you choose to use this.
Test cases
Input | Output
---------------
1 | 1
5 | 3
20 | 10
50 | 72
78 | 76
123 | 155
1234 | 1324
3000 | 2996
9999 | 9903
29890 | 29796
Rules
- Input and output are integers.
- Your program should at least support input in the range of 1 up to 32767).
- Invalid input (0, floats, strings, negative values, etc.) may lead to unpredicted output, errors or (un)defined behaviour.
- Default I/O rules apply.
Default loopholes are forbidden.- This is code-golf, so the shortest answers in bytes wins
code-golf sequence
$endgroup$
Introduction (may be ignored)
Putting all positive integers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive integers. This is the sixth challenge in this series (links to the first, second, third, fourth and fifth challenge).
This challenge has a mild Easter theme (because it's Easter). I took my inspiration from this highly decorated (and in my personal opinion rather ugly) goose egg.

It reminded me of the Ulam spiral, where all positive integers are placed in a counter-clockwise spiral. This spiral has some interesting features related to prime numbers, but that's not relevant for this challenge.

We get to this challenge's permutation of positive integers if we take the numbers in the Ulam spiral and trace all integers in a clockwise turning spiral, starting at 1. This way, we get:
1, 6, 5, 4, 3, 2, 9, 8, 7, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 25, 24, 23, etc.
If you would draw both of the spirals, you'd get some sort of an infinite mesh of (egg shell) spirals (note the New Order reference there).
This sequence is present in the OEIS under number A090861. Since this is a "pure sequence" challenge, the task is to output $a(n)$ for a given $n$ as input, where $a(n)$ is A090861.
Task
Given an integer input $n$, output $a(n)$ in integer format, where $a(n)$ is A090861.
Note: 1-based indexing is assumed here; you may use 0-based indexing, so $a(0) = 1; a(1) = 6$, etc. Please mention this in your answer if you choose to use this.
Test cases
Input | Output
---------------
1 | 1
5 | 3
20 | 10
50 | 72
78 | 76
123 | 155
1234 | 1324
3000 | 2996
9999 | 9903
29890 | 29796
Rules
- Input and output are integers.
- Your program should at least support input in the range of 1 up to 32767).
- Invalid input (0, floats, strings, negative values, etc.) may lead to unpredicted output, errors or (un)defined behaviour.
- Default I/O rules apply.
Default loopholes are forbidden.- This is code-golf, so the shortest answers in bytes wins
code-golf sequence
code-golf sequence
asked 1 hour ago
agtoeveragtoever
1,416425
1,416425
add a comment |
add a comment |
5 Answers
5
active
oldest
votes
$begingroup$
Wolfram Language (Mathematica), 60 bytes
8(s=⌊(⌊Sqrt[#-1]⌋+1)/2⌋)^2-#+2+If[#<=4s^2+2s,-2,6]s&
Try it online!
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 67 bytes
n=>8*(x=(int)Math.Sqrt(--n)+1>>1)*x+(n<4*x*x+2*x?-2:6)*x+1-n;int x;
Try it online!
$endgroup$
add a comment |
$begingroup$
MATL, 12 bytes
Eq1YL!tPwG=)
Try it online!
Very memory-inefficient. Prepending X^k makes it more efficient.
$endgroup$
add a comment |
$begingroup$
Jelly, 16 14 bytes
2,6×Ɱ’ẎÄRUẎQị@
A monadic Link accepting an integer, n, which yields an integer, a(n).
Try it online! (very inefficient)
$endgroup$
add a comment |
$begingroup$
JavaScript (ES7), 46 45 41 bytes
0-indexed.
n=>((x=n**.5+1&~1)*2-(n<x*x+x)*4+3)*x+1-n
Try it online!
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "200"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f183528%2fnew-order-6-easter-egg%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Wolfram Language (Mathematica), 60 bytes
8(s=⌊(⌊Sqrt[#-1]⌋+1)/2⌋)^2-#+2+If[#<=4s^2+2s,-2,6]s&
Try it online!
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 60 bytes
8(s=⌊(⌊Sqrt[#-1]⌋+1)/2⌋)^2-#+2+If[#<=4s^2+2s,-2,6]s&
Try it online!
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 60 bytes
8(s=⌊(⌊Sqrt[#-1]⌋+1)/2⌋)^2-#+2+If[#<=4s^2+2s,-2,6]s&
Try it online!
$endgroup$
Wolfram Language (Mathematica), 60 bytes
8(s=⌊(⌊Sqrt[#-1]⌋+1)/2⌋)^2-#+2+If[#<=4s^2+2s,-2,6]s&
Try it online!
answered 56 mins ago
J42161217J42161217
14.3k21354
14.3k21354
add a comment |
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 67 bytes
n=>8*(x=(int)Math.Sqrt(--n)+1>>1)*x+(n<4*x*x+2*x?-2:6)*x+1-n;int x;
Try it online!
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 67 bytes
n=>8*(x=(int)Math.Sqrt(--n)+1>>1)*x+(n<4*x*x+2*x?-2:6)*x+1-n;int x;
Try it online!
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 67 bytes
n=>8*(x=(int)Math.Sqrt(--n)+1>>1)*x+(n<4*x*x+2*x?-2:6)*x+1-n;int x;
Try it online!
$endgroup$
C# (Visual C# Interactive Compiler), 67 bytes
n=>8*(x=(int)Math.Sqrt(--n)+1>>1)*x+(n<4*x*x+2*x?-2:6)*x+1-n;int x;
Try it online!
edited 27 mins ago
answered 40 mins ago
Embodiment of IgnoranceEmbodiment of Ignorance
3,044127
3,044127
add a comment |
add a comment |
$begingroup$
MATL, 12 bytes
Eq1YL!tPwG=)
Try it online!
Very memory-inefficient. Prepending X^k makes it more efficient.
$endgroup$
add a comment |
$begingroup$
MATL, 12 bytes
Eq1YL!tPwG=)
Try it online!
Very memory-inefficient. Prepending X^k makes it more efficient.
$endgroup$
add a comment |
$begingroup$
MATL, 12 bytes
Eq1YL!tPwG=)
Try it online!
Very memory-inefficient. Prepending X^k makes it more efficient.
$endgroup$
MATL, 12 bytes
Eq1YL!tPwG=)
Try it online!
Very memory-inefficient. Prepending X^k makes it more efficient.
answered 18 mins ago
Luis MendoLuis Mendo
75.5k889293
75.5k889293
add a comment |
add a comment |
$begingroup$
Jelly, 16 14 bytes
2,6×Ɱ’ẎÄRUẎQị@
A monadic Link accepting an integer, n, which yields an integer, a(n).
Try it online! (very inefficient)
$endgroup$
add a comment |
$begingroup$
Jelly, 16 14 bytes
2,6×Ɱ’ẎÄRUẎQị@
A monadic Link accepting an integer, n, which yields an integer, a(n).
Try it online! (very inefficient)
$endgroup$
add a comment |
$begingroup$
Jelly, 16 14 bytes
2,6×Ɱ’ẎÄRUẎQị@
A monadic Link accepting an integer, n, which yields an integer, a(n).
Try it online! (very inefficient)
$endgroup$
Jelly, 16 14 bytes
2,6×Ɱ’ẎÄRUẎQị@
A monadic Link accepting an integer, n, which yields an integer, a(n).
Try it online! (very inefficient)
edited 11 mins ago
answered 17 mins ago
Jonathan AllanJonathan Allan
54.7k537175
54.7k537175
add a comment |
add a comment |
$begingroup$
JavaScript (ES7), 46 45 41 bytes
0-indexed.
n=>((x=n**.5+1&~1)*2-(n<x*x+x)*4+3)*x+1-n
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (ES7), 46 45 41 bytes
0-indexed.
n=>((x=n**.5+1&~1)*2-(n<x*x+x)*4+3)*x+1-n
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (ES7), 46 45 41 bytes
0-indexed.
n=>((x=n**.5+1&~1)*2-(n<x*x+x)*4+3)*x+1-n
Try it online!
$endgroup$
JavaScript (ES7), 46 45 41 bytes
0-indexed.
n=>((x=n**.5+1&~1)*2-(n<x*x+x)*4+3)*x+1-n
Try it online!
edited 4 mins ago
answered 29 mins ago
ArnauldArnauld
81.7k798337
81.7k798337
add a comment |
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f183528%2fnew-order-6-easter-egg%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown