The Path Of The Wildebeest
$begingroup$
Golf a program or function which gives the $n^{text{th}}$ location of the wildebeest who starts at square $1$ on an infinite chessboard which is numbered in an anti-clockwise square spiral, where the wildebeest always visits the lowest numbered square she can reach that she has not yet visited.
Inspiration: The Trapped Knight and OEIS A316667.
The code may produce the $n^{text{th}}$ location, the first $n$ locations, or generate the sequence taking no input.
Feel free to give her location after (or up to) $n$ leaps instead, but if so please state this clearly in your answer and make sure that an input of $n=0$ yields 1 (or [1] if appropriate).
This is code-golf, so the aim is to produce working code in as few bytes as possible in your chosen language.
Note: I believe that the path of the wildebeest is not finite (that she never becomes trapped, like the knight does at his $2016^{text{th}}$ location, square $2084$, and the camel does at his $3723^{text{rd}}$, square $7081$), but have not proven this - if this is not the case then the behaviour may be undefined for $n$ larger than the step at which she does get trapped. (I also believe the path will turn out to be a permutation of the natural numbers, but this is a pure hunch.)*
Detail
The board looks like the below, and continues indefinitely:
101 100 99 98 97 96 95 94 93 92 91
102 65 64 63 62 61 60 59 58 57 90
103 66 37 36 35 34 33 32 31 56 89
104 67 38 17 16 15 14 13 30 55 88
105 68 39 18 5 4 3 12 29 54 87
106 69 40 19 6 1 2 11 28 53 86
107 70 41 20 7 8 9 10 27 52 85
108 71 42 21 22 23 24 25 26 51 84
109 72 43 44 45 46 47 48 49 50 83
110 73 74 75 76 77 78 79 80 81 82
111 112 113 114 115 116 117 118 119 120 121
A wildebeest is a fairy chess piece - a non-standard chess piece which may move both as a knight (a $(1,2)$-leaper) and as a camel (a $(1,3)$-leaper).
As such she could move to any of these locations from her starting location of $1$:
. . . . . . . . . . .
. . . . 35 . 33 . . . .
. . . . 16 . 14 . . . .
. . 39 18 . . . 12 29 . .
. . . . . (1) . . . . .
. . 41 20 . . . 10 27 . .
. . . . 22 . 24 . . . .
. . . . 45 . 47 . . . .
. . . . . . . . . . .
The lowest of these is $10$ and she has not yet visited that square, so $10$ is the second term in the sequence.
Next she could move from $10$ to any of these locations:
. . . . . . . . . . .
. . . . . . 14 . 30 . .
. . . . . . 3 . 29 . .
. . . . 6 1 . . . 53 86
. . . . . . . (10) . . .
. . . . 22 23 . . . 51 84
. . . . . . 47 . 49 . .
. . . . . . 78 . 80 . .
. . . . . . . . . . .
However, she has already visited square $1$ so her third location is square $3$, the lowest she has not yet visited.
The first $100$ terms of the path of the wildebeest are:
1, 10, 3, 6, 9, 4, 7, 2, 5, 8, 11, 14, 18, 15, 12, 16, 19, 22, 41, 17, 33, 30, 34, 13, 27, 23, 20, 24, 44, 40, 21, 39, 36, 60, 31, 53, 26, 46, 25, 28, 32, 29, 51, 47, 75, 42, 45, 71, 74, 70, 38, 35, 59, 56, 86, 50, 78, 49, 52, 80, 83, 79, 115, 73, 107, 67, 64, 68, 37, 61, 93, 55, 58, 54, 84, 48, 76, 43, 69, 103, 63, 66, 62, 94, 57, 87, 125, 82, 118, 77, 113, 72, 106, 148, 65, 97, 137, 91, 129, 85
The first $11$ leaps are knight moves so the first $12$ terms coincide with A316667.
* There are over one hundred and fifty million terms. After one million terms, numbering the layers of the spiral from the centre out, she has visited $512$ layers and the ($(512times 2-1)^2-10^6=46529$) unvisited squares by layer are: [(1,0),(2,0),...,(494,0),(495, 2), (496, 53), (497, 204), (498, 662), (499, 1208), (500, 1899), (501, 2459), (502, 2921), (503, 3133), (504, 3288), (505, 3397), (506, 3538), (507, 3712), (508, 3868), (509, 3978), (510, 4046), (511, 4074), (512, 4087)], so it's not entirely clear that all squares will be visited or that the wildebeest will never get trapped. Proofs of whether she will ever become trapped or whether she will visit all squares would, of course, be gratefully received!
code-golf sequence integer chess
$endgroup$
add a comment |
$begingroup$
Golf a program or function which gives the $n^{text{th}}$ location of the wildebeest who starts at square $1$ on an infinite chessboard which is numbered in an anti-clockwise square spiral, where the wildebeest always visits the lowest numbered square she can reach that she has not yet visited.
Inspiration: The Trapped Knight and OEIS A316667.
The code may produce the $n^{text{th}}$ location, the first $n$ locations, or generate the sequence taking no input.
Feel free to give her location after (or up to) $n$ leaps instead, but if so please state this clearly in your answer and make sure that an input of $n=0$ yields 1 (or [1] if appropriate).
This is code-golf, so the aim is to produce working code in as few bytes as possible in your chosen language.
Note: I believe that the path of the wildebeest is not finite (that she never becomes trapped, like the knight does at his $2016^{text{th}}$ location, square $2084$, and the camel does at his $3723^{text{rd}}$, square $7081$), but have not proven this - if this is not the case then the behaviour may be undefined for $n$ larger than the step at which she does get trapped. (I also believe the path will turn out to be a permutation of the natural numbers, but this is a pure hunch.)*
Detail
The board looks like the below, and continues indefinitely:
101 100 99 98 97 96 95 94 93 92 91
102 65 64 63 62 61 60 59 58 57 90
103 66 37 36 35 34 33 32 31 56 89
104 67 38 17 16 15 14 13 30 55 88
105 68 39 18 5 4 3 12 29 54 87
106 69 40 19 6 1 2 11 28 53 86
107 70 41 20 7 8 9 10 27 52 85
108 71 42 21 22 23 24 25 26 51 84
109 72 43 44 45 46 47 48 49 50 83
110 73 74 75 76 77 78 79 80 81 82
111 112 113 114 115 116 117 118 119 120 121
A wildebeest is a fairy chess piece - a non-standard chess piece which may move both as a knight (a $(1,2)$-leaper) and as a camel (a $(1,3)$-leaper).
As such she could move to any of these locations from her starting location of $1$:
. . . . . . . . . . .
. . . . 35 . 33 . . . .
. . . . 16 . 14 . . . .
. . 39 18 . . . 12 29 . .
. . . . . (1) . . . . .
. . 41 20 . . . 10 27 . .
. . . . 22 . 24 . . . .
. . . . 45 . 47 . . . .
. . . . . . . . . . .
The lowest of these is $10$ and she has not yet visited that square, so $10$ is the second term in the sequence.
Next she could move from $10$ to any of these locations:
. . . . . . . . . . .
. . . . . . 14 . 30 . .
. . . . . . 3 . 29 . .
. . . . 6 1 . . . 53 86
. . . . . . . (10) . . .
. . . . 22 23 . . . 51 84
. . . . . . 47 . 49 . .
. . . . . . 78 . 80 . .
. . . . . . . . . . .
However, she has already visited square $1$ so her third location is square $3$, the lowest she has not yet visited.
The first $100$ terms of the path of the wildebeest are:
1, 10, 3, 6, 9, 4, 7, 2, 5, 8, 11, 14, 18, 15, 12, 16, 19, 22, 41, 17, 33, 30, 34, 13, 27, 23, 20, 24, 44, 40, 21, 39, 36, 60, 31, 53, 26, 46, 25, 28, 32, 29, 51, 47, 75, 42, 45, 71, 74, 70, 38, 35, 59, 56, 86, 50, 78, 49, 52, 80, 83, 79, 115, 73, 107, 67, 64, 68, 37, 61, 93, 55, 58, 54, 84, 48, 76, 43, 69, 103, 63, 66, 62, 94, 57, 87, 125, 82, 118, 77, 113, 72, 106, 148, 65, 97, 137, 91, 129, 85
The first $11$ leaps are knight moves so the first $12$ terms coincide with A316667.
* There are over one hundred and fifty million terms. After one million terms, numbering the layers of the spiral from the centre out, she has visited $512$ layers and the ($(512times 2-1)^2-10^6=46529$) unvisited squares by layer are: [(1,0),(2,0),...,(494,0),(495, 2), (496, 53), (497, 204), (498, 662), (499, 1208), (500, 1899), (501, 2459), (502, 2921), (503, 3133), (504, 3288), (505, 3397), (506, 3538), (507, 3712), (508, 3868), (509, 3978), (510, 4046), (511, 4074), (512, 4087)], so it's not entirely clear that all squares will be visited or that the wildebeest will never get trapped. Proofs of whether she will ever become trapped or whether she will visit all squares would, of course, be gratefully received!
code-golf sequence integer chess
$endgroup$
$begingroup$
I suspect the wildebeest gets trapped eventually -- it just takes longer since she has more movement options.
$endgroup$
– lirtosiast
4 hours ago
$begingroup$
"There are over ten million terms." LOL do you have a reference implementation?
$endgroup$
– Erik the Outgolfer
3 hours ago
$begingroup$
@EriktheOutgolfer yes, but she does get stuck somewhere - I need to rerun as was not catching theStopIteration:(
$endgroup$
– Jonathan Allan
3 hours ago
add a comment |
$begingroup$
Golf a program or function which gives the $n^{text{th}}$ location of the wildebeest who starts at square $1$ on an infinite chessboard which is numbered in an anti-clockwise square spiral, where the wildebeest always visits the lowest numbered square she can reach that she has not yet visited.
Inspiration: The Trapped Knight and OEIS A316667.
The code may produce the $n^{text{th}}$ location, the first $n$ locations, or generate the sequence taking no input.
Feel free to give her location after (or up to) $n$ leaps instead, but if so please state this clearly in your answer and make sure that an input of $n=0$ yields 1 (or [1] if appropriate).
This is code-golf, so the aim is to produce working code in as few bytes as possible in your chosen language.
Note: I believe that the path of the wildebeest is not finite (that she never becomes trapped, like the knight does at his $2016^{text{th}}$ location, square $2084$, and the camel does at his $3723^{text{rd}}$, square $7081$), but have not proven this - if this is not the case then the behaviour may be undefined for $n$ larger than the step at which she does get trapped. (I also believe the path will turn out to be a permutation of the natural numbers, but this is a pure hunch.)*
Detail
The board looks like the below, and continues indefinitely:
101 100 99 98 97 96 95 94 93 92 91
102 65 64 63 62 61 60 59 58 57 90
103 66 37 36 35 34 33 32 31 56 89
104 67 38 17 16 15 14 13 30 55 88
105 68 39 18 5 4 3 12 29 54 87
106 69 40 19 6 1 2 11 28 53 86
107 70 41 20 7 8 9 10 27 52 85
108 71 42 21 22 23 24 25 26 51 84
109 72 43 44 45 46 47 48 49 50 83
110 73 74 75 76 77 78 79 80 81 82
111 112 113 114 115 116 117 118 119 120 121
A wildebeest is a fairy chess piece - a non-standard chess piece which may move both as a knight (a $(1,2)$-leaper) and as a camel (a $(1,3)$-leaper).
As such she could move to any of these locations from her starting location of $1$:
. . . . . . . . . . .
. . . . 35 . 33 . . . .
. . . . 16 . 14 . . . .
. . 39 18 . . . 12 29 . .
. . . . . (1) . . . . .
. . 41 20 . . . 10 27 . .
. . . . 22 . 24 . . . .
. . . . 45 . 47 . . . .
. . . . . . . . . . .
The lowest of these is $10$ and she has not yet visited that square, so $10$ is the second term in the sequence.
Next she could move from $10$ to any of these locations:
. . . . . . . . . . .
. . . . . . 14 . 30 . .
. . . . . . 3 . 29 . .
. . . . 6 1 . . . 53 86
. . . . . . . (10) . . .
. . . . 22 23 . . . 51 84
. . . . . . 47 . 49 . .
. . . . . . 78 . 80 . .
. . . . . . . . . . .
However, she has already visited square $1$ so her third location is square $3$, the lowest she has not yet visited.
The first $100$ terms of the path of the wildebeest are:
1, 10, 3, 6, 9, 4, 7, 2, 5, 8, 11, 14, 18, 15, 12, 16, 19, 22, 41, 17, 33, 30, 34, 13, 27, 23, 20, 24, 44, 40, 21, 39, 36, 60, 31, 53, 26, 46, 25, 28, 32, 29, 51, 47, 75, 42, 45, 71, 74, 70, 38, 35, 59, 56, 86, 50, 78, 49, 52, 80, 83, 79, 115, 73, 107, 67, 64, 68, 37, 61, 93, 55, 58, 54, 84, 48, 76, 43, 69, 103, 63, 66, 62, 94, 57, 87, 125, 82, 118, 77, 113, 72, 106, 148, 65, 97, 137, 91, 129, 85
The first $11$ leaps are knight moves so the first $12$ terms coincide with A316667.
* There are over one hundred and fifty million terms. After one million terms, numbering the layers of the spiral from the centre out, she has visited $512$ layers and the ($(512times 2-1)^2-10^6=46529$) unvisited squares by layer are: [(1,0),(2,0),...,(494,0),(495, 2), (496, 53), (497, 204), (498, 662), (499, 1208), (500, 1899), (501, 2459), (502, 2921), (503, 3133), (504, 3288), (505, 3397), (506, 3538), (507, 3712), (508, 3868), (509, 3978), (510, 4046), (511, 4074), (512, 4087)], so it's not entirely clear that all squares will be visited or that the wildebeest will never get trapped. Proofs of whether she will ever become trapped or whether she will visit all squares would, of course, be gratefully received!
code-golf sequence integer chess
$endgroup$
Golf a program or function which gives the $n^{text{th}}$ location of the wildebeest who starts at square $1$ on an infinite chessboard which is numbered in an anti-clockwise square spiral, where the wildebeest always visits the lowest numbered square she can reach that she has not yet visited.
Inspiration: The Trapped Knight and OEIS A316667.
The code may produce the $n^{text{th}}$ location, the first $n$ locations, or generate the sequence taking no input.
Feel free to give her location after (or up to) $n$ leaps instead, but if so please state this clearly in your answer and make sure that an input of $n=0$ yields 1 (or [1] if appropriate).
This is code-golf, so the aim is to produce working code in as few bytes as possible in your chosen language.
Note: I believe that the path of the wildebeest is not finite (that she never becomes trapped, like the knight does at his $2016^{text{th}}$ location, square $2084$, and the camel does at his $3723^{text{rd}}$, square $7081$), but have not proven this - if this is not the case then the behaviour may be undefined for $n$ larger than the step at which she does get trapped. (I also believe the path will turn out to be a permutation of the natural numbers, but this is a pure hunch.)*
Detail
The board looks like the below, and continues indefinitely:
101 100 99 98 97 96 95 94 93 92 91
102 65 64 63 62 61 60 59 58 57 90
103 66 37 36 35 34 33 32 31 56 89
104 67 38 17 16 15 14 13 30 55 88
105 68 39 18 5 4 3 12 29 54 87
106 69 40 19 6 1 2 11 28 53 86
107 70 41 20 7 8 9 10 27 52 85
108 71 42 21 22 23 24 25 26 51 84
109 72 43 44 45 46 47 48 49 50 83
110 73 74 75 76 77 78 79 80 81 82
111 112 113 114 115 116 117 118 119 120 121
A wildebeest is a fairy chess piece - a non-standard chess piece which may move both as a knight (a $(1,2)$-leaper) and as a camel (a $(1,3)$-leaper).
As such she could move to any of these locations from her starting location of $1$:
. . . . . . . . . . .
. . . . 35 . 33 . . . .
. . . . 16 . 14 . . . .
. . 39 18 . . . 12 29 . .
. . . . . (1) . . . . .
. . 41 20 . . . 10 27 . .
. . . . 22 . 24 . . . .
. . . . 45 . 47 . . . .
. . . . . . . . . . .
The lowest of these is $10$ and she has not yet visited that square, so $10$ is the second term in the sequence.
Next she could move from $10$ to any of these locations:
. . . . . . . . . . .
. . . . . . 14 . 30 . .
. . . . . . 3 . 29 . .
. . . . 6 1 . . . 53 86
. . . . . . . (10) . . .
. . . . 22 23 . . . 51 84
. . . . . . 47 . 49 . .
. . . . . . 78 . 80 . .
. . . . . . . . . . .
However, she has already visited square $1$ so her third location is square $3$, the lowest she has not yet visited.
The first $100$ terms of the path of the wildebeest are:
1, 10, 3, 6, 9, 4, 7, 2, 5, 8, 11, 14, 18, 15, 12, 16, 19, 22, 41, 17, 33, 30, 34, 13, 27, 23, 20, 24, 44, 40, 21, 39, 36, 60, 31, 53, 26, 46, 25, 28, 32, 29, 51, 47, 75, 42, 45, 71, 74, 70, 38, 35, 59, 56, 86, 50, 78, 49, 52, 80, 83, 79, 115, 73, 107, 67, 64, 68, 37, 61, 93, 55, 58, 54, 84, 48, 76, 43, 69, 103, 63, 66, 62, 94, 57, 87, 125, 82, 118, 77, 113, 72, 106, 148, 65, 97, 137, 91, 129, 85
The first $11$ leaps are knight moves so the first $12$ terms coincide with A316667.
* There are over one hundred and fifty million terms. After one million terms, numbering the layers of the spiral from the centre out, she has visited $512$ layers and the ($(512times 2-1)^2-10^6=46529$) unvisited squares by layer are: [(1,0),(2,0),...,(494,0),(495, 2), (496, 53), (497, 204), (498, 662), (499, 1208), (500, 1899), (501, 2459), (502, 2921), (503, 3133), (504, 3288), (505, 3397), (506, 3538), (507, 3712), (508, 3868), (509, 3978), (510, 4046), (511, 4074), (512, 4087)], so it's not entirely clear that all squares will be visited or that the wildebeest will never get trapped. Proofs of whether she will ever become trapped or whether she will visit all squares would, of course, be gratefully received!
code-golf sequence integer chess
code-golf sequence integer chess
edited 16 mins ago
Jonathan Allan
asked 5 hours ago
Jonathan AllanJonathan Allan
51.4k535166
51.4k535166
$begingroup$
I suspect the wildebeest gets trapped eventually -- it just takes longer since she has more movement options.
$endgroup$
– lirtosiast
4 hours ago
$begingroup$
"There are over ten million terms." LOL do you have a reference implementation?
$endgroup$
– Erik the Outgolfer
3 hours ago
$begingroup$
@EriktheOutgolfer yes, but she does get stuck somewhere - I need to rerun as was not catching theStopIteration:(
$endgroup$
– Jonathan Allan
3 hours ago
add a comment |
$begingroup$
I suspect the wildebeest gets trapped eventually -- it just takes longer since she has more movement options.
$endgroup$
– lirtosiast
4 hours ago
$begingroup$
"There are over ten million terms." LOL do you have a reference implementation?
$endgroup$
– Erik the Outgolfer
3 hours ago
$begingroup$
@EriktheOutgolfer yes, but she does get stuck somewhere - I need to rerun as was not catching theStopIteration:(
$endgroup$
– Jonathan Allan
3 hours ago
$begingroup$
I suspect the wildebeest gets trapped eventually -- it just takes longer since she has more movement options.
$endgroup$
– lirtosiast
4 hours ago
$begingroup$
I suspect the wildebeest gets trapped eventually -- it just takes longer since she has more movement options.
$endgroup$
– lirtosiast
4 hours ago
$begingroup$
"There are over ten million terms." LOL do you have a reference implementation?
$endgroup$
– Erik the Outgolfer
3 hours ago
$begingroup$
"There are over ten million terms." LOL do you have a reference implementation?
$endgroup$
– Erik the Outgolfer
3 hours ago
$begingroup$
@EriktheOutgolfer yes, but she does get stuck somewhere - I need to rerun as was not catching the
StopIteration :($endgroup$
– Jonathan Allan
3 hours ago
$begingroup$
@EriktheOutgolfer yes, but she does get stuck somewhere - I need to rerun as was not catching the
StopIteration :($endgroup$
– Jonathan Allan
3 hours ago
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
JavaScript (Node.js), 191 ... 170 169 bytes
Returns the $N$th term.
n=>(g=(x,y)=>n--?g(Buffer('<3!3(*8*A1C1<:,:').map(m=c=>(i=(a=4*((x+=c-48>>3)*x>(y+=c%8-2)*y?x:y)**2)-(x>y||-1)*(a**.5+x+y))>m|g[i]||(H=x,V=y,m=i))&&H,V,g[m]=1):m+1)(1,2)
Try it online!
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
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%2f179157%2fthe-path-of-the-wildebeest%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
JavaScript (Node.js), 191 ... 170 169 bytes
Returns the $N$th term.
n=>(g=(x,y)=>n--?g(Buffer('<3!3(*8*A1C1<:,:').map(m=c=>(i=(a=4*((x+=c-48>>3)*x>(y+=c%8-2)*y?x:y)**2)-(x>y||-1)*(a**.5+x+y))>m|g[i]||(H=x,V=y,m=i))&&H,V,g[m]=1):m+1)(1,2)
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (Node.js), 191 ... 170 169 bytes
Returns the $N$th term.
n=>(g=(x,y)=>n--?g(Buffer('<3!3(*8*A1C1<:,:').map(m=c=>(i=(a=4*((x+=c-48>>3)*x>(y+=c%8-2)*y?x:y)**2)-(x>y||-1)*(a**.5+x+y))>m|g[i]||(H=x,V=y,m=i))&&H,V,g[m]=1):m+1)(1,2)
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (Node.js), 191 ... 170 169 bytes
Returns the $N$th term.
n=>(g=(x,y)=>n--?g(Buffer('<3!3(*8*A1C1<:,:').map(m=c=>(i=(a=4*((x+=c-48>>3)*x>(y+=c%8-2)*y?x:y)**2)-(x>y||-1)*(a**.5+x+y))>m|g[i]||(H=x,V=y,m=i))&&H,V,g[m]=1):m+1)(1,2)
Try it online!
$endgroup$
JavaScript (Node.js), 191 ... 170 169 bytes
Returns the $N$th term.
n=>(g=(x,y)=>n--?g(Buffer('<3!3(*8*A1C1<:,:').map(m=c=>(i=(a=4*((x+=c-48>>3)*x>(y+=c%8-2)*y?x:y)**2)-(x>y||-1)*(a**.5+x+y))>m|g[i]||(H=x,V=y,m=i))&&H,V,g[m]=1):m+1)(1,2)
Try it online!
edited 56 mins ago
answered 3 hours ago
ArnauldArnauld
74.1k690310
74.1k690310
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%2f179157%2fthe-path-of-the-wildebeest%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
$begingroup$
I suspect the wildebeest gets trapped eventually -- it just takes longer since she has more movement options.
$endgroup$
– lirtosiast
4 hours ago
$begingroup$
"There are over ten million terms." LOL do you have a reference implementation?
$endgroup$
– Erik the Outgolfer
3 hours ago
$begingroup$
@EriktheOutgolfer yes, but she does get stuck somewhere - I need to rerun as was not catching the
StopIteration:($endgroup$
– Jonathan Allan
3 hours ago