Is it a Cyclops number? “Nobody” knows!Sum of Binary SubstringsIs this a Smith number?Is this number triangular?Test if two numbers are equalIs this number a repdigit?Am I divisible by double the sum of my digits?Is the number binary-heavy?Is it a whole number?Binary SubstringsDiluted Integer Sums
Is this nominative case or accusative case?
Does the US political system, in principle, allow for a no-party system?
Paper published similar to PhD thesis
How does a sound wave propagate?
Can inspiration allow the Rogue to make a Sneak Attack?
What does "rhumatis" mean?
Rationale to prefer local variables over instance variables?
What is Tony Stark injecting into himself in Iron Man 3?
What is better: yes / no radio, or simple checkbox?
A bug in Excel? Conditional formatting for marking duplicates also highlights unique value
PTiJ: How should animals pray?
Can a Mimic (container form) actually hold loot?
Can a space-faring robot still function over a billion years?
Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?
Is divide-by-zero a security vulnerability?
Deal the cards to the players
Too soon for a plot twist?
Can you run a ground wire from stove directly to ground pole in the ground
How do we objectively assess if a dialogue sounds unnatural or cringy?
Why are special aircraft used for the carriers in the United States Navy?
Under what conditions would I NOT add my Proficiency Bonus to a Spell Attack Roll (or Saving Throw DC)?
The need of reserving one's ability in job interviews
New invention compresses matter to produce energy? or other items? (Short Story)
Are healthy patients an appropriate control group?
Is it a Cyclops number? “Nobody” knows!
Sum of Binary SubstringsIs this a Smith number?Is this number triangular?Test if two numbers are equalIs this number a repdigit?Am I divisible by double the sum of my digits?Is the number binary-heavy?Is it a whole number?Binary SubstringsDiluted Integer Sums
$begingroup$
Task:
Given an integer input, figure out whether or not it is a Cyclops Number.
What is a Cyclops number, you may ask? Well, it's a number whose binary representation only has one 0
in the center!
Test Cases:
Input | Output
--------------
1 | falsy
5 | truthy
12 | falsy
27 | truthy
85 | falsy
101 | falsy
119 | truthy
Input: An integer or equivalent types. (int
, long
, decimal
, etc.)
Output:
- Truthy or falsy (e.g.
true
orfalse
,0
or1
)..
Challenge Rules:
Input that is less than 0 is assumed to be falsy.
If the length of the binary representation of the number is even, then the number cannot be a Cyclops number.
General Rules:
This is code-golf, so the shortest answers in bytes wins!.
Default loopholes are forbidden.
Standard rules apply for your answer with default I/O rules.
This is my first Programming Puzzles & Code Golf challenge, so any feedback on how I should improve would be much appreciated!
code-golf number decision-problem binary
New contributor
$endgroup$
|
show 4 more comments
$begingroup$
Task:
Given an integer input, figure out whether or not it is a Cyclops Number.
What is a Cyclops number, you may ask? Well, it's a number whose binary representation only has one 0
in the center!
Test Cases:
Input | Output
--------------
1 | falsy
5 | truthy
12 | falsy
27 | truthy
85 | falsy
101 | falsy
119 | truthy
Input: An integer or equivalent types. (int
, long
, decimal
, etc.)
Output:
- Truthy or falsy (e.g.
true
orfalse
,0
or1
)..
Challenge Rules:
Input that is less than 0 is assumed to be falsy.
If the length of the binary representation of the number is even, then the number cannot be a Cyclops number.
General Rules:
This is code-golf, so the shortest answers in bytes wins!.
Default loopholes are forbidden.
Standard rules apply for your answer with default I/O rules.
This is my first Programming Puzzles & Code Golf challenge, so any feedback on how I should improve would be much appreciated!
code-golf number decision-problem binary
New contributor
$endgroup$
1
$begingroup$
You've essentially made two separate challenges, one a decision problem and one about outputting the next number of a sequence. This will not do what you want, which is invite more answers, but instead put off users who now need to consider three options about what to program before posting. I'd recommend removing the option, and in the future you can try posting to our sandbox first where hopefully you will get helpful feedback before posting. Good luck!
$endgroup$
– FryAmTheEggman
5 hours ago
$begingroup$
@SriotchilismO'Zaic thanks for the feedback! I have edited the post.
$endgroup$
– Tau
5 hours ago
$begingroup$
@FryAmTheEggman thank you, I'll keep that in mind. The post has been edited.
$endgroup$
– Tau
5 hours ago
1
$begingroup$
Note: This is A129868
$endgroup$
– tsh
4 hours ago
2
$begingroup$
Should119
be true?
$endgroup$
– Quintec
4 hours ago
|
show 4 more comments
$begingroup$
Task:
Given an integer input, figure out whether or not it is a Cyclops Number.
What is a Cyclops number, you may ask? Well, it's a number whose binary representation only has one 0
in the center!
Test Cases:
Input | Output
--------------
1 | falsy
5 | truthy
12 | falsy
27 | truthy
85 | falsy
101 | falsy
119 | truthy
Input: An integer or equivalent types. (int
, long
, decimal
, etc.)
Output:
- Truthy or falsy (e.g.
true
orfalse
,0
or1
)..
Challenge Rules:
Input that is less than 0 is assumed to be falsy.
If the length of the binary representation of the number is even, then the number cannot be a Cyclops number.
General Rules:
This is code-golf, so the shortest answers in bytes wins!.
Default loopholes are forbidden.
Standard rules apply for your answer with default I/O rules.
This is my first Programming Puzzles & Code Golf challenge, so any feedback on how I should improve would be much appreciated!
code-golf number decision-problem binary
New contributor
$endgroup$
Task:
Given an integer input, figure out whether or not it is a Cyclops Number.
What is a Cyclops number, you may ask? Well, it's a number whose binary representation only has one 0
in the center!
Test Cases:
Input | Output
--------------
1 | falsy
5 | truthy
12 | falsy
27 | truthy
85 | falsy
101 | falsy
119 | truthy
Input: An integer or equivalent types. (int
, long
, decimal
, etc.)
Output:
- Truthy or falsy (e.g.
true
orfalse
,0
or1
)..
Challenge Rules:
Input that is less than 0 is assumed to be falsy.
If the length of the binary representation of the number is even, then the number cannot be a Cyclops number.
General Rules:
This is code-golf, so the shortest answers in bytes wins!.
Default loopholes are forbidden.
Standard rules apply for your answer with default I/O rules.
This is my first Programming Puzzles & Code Golf challenge, so any feedback on how I should improve would be much appreciated!
code-golf number decision-problem binary
code-golf number decision-problem binary
New contributor
New contributor
edited 4 hours ago
Tau
New contributor
asked 5 hours ago
TauTau
1365
1365
New contributor
New contributor
1
$begingroup$
You've essentially made two separate challenges, one a decision problem and one about outputting the next number of a sequence. This will not do what you want, which is invite more answers, but instead put off users who now need to consider three options about what to program before posting. I'd recommend removing the option, and in the future you can try posting to our sandbox first where hopefully you will get helpful feedback before posting. Good luck!
$endgroup$
– FryAmTheEggman
5 hours ago
$begingroup$
@SriotchilismO'Zaic thanks for the feedback! I have edited the post.
$endgroup$
– Tau
5 hours ago
$begingroup$
@FryAmTheEggman thank you, I'll keep that in mind. The post has been edited.
$endgroup$
– Tau
5 hours ago
1
$begingroup$
Note: This is A129868
$endgroup$
– tsh
4 hours ago
2
$begingroup$
Should119
be true?
$endgroup$
– Quintec
4 hours ago
|
show 4 more comments
1
$begingroup$
You've essentially made two separate challenges, one a decision problem and one about outputting the next number of a sequence. This will not do what you want, which is invite more answers, but instead put off users who now need to consider three options about what to program before posting. I'd recommend removing the option, and in the future you can try posting to our sandbox first where hopefully you will get helpful feedback before posting. Good luck!
$endgroup$
– FryAmTheEggman
5 hours ago
$begingroup$
@SriotchilismO'Zaic thanks for the feedback! I have edited the post.
$endgroup$
– Tau
5 hours ago
$begingroup$
@FryAmTheEggman thank you, I'll keep that in mind. The post has been edited.
$endgroup$
– Tau
5 hours ago
1
$begingroup$
Note: This is A129868
$endgroup$
– tsh
4 hours ago
2
$begingroup$
Should119
be true?
$endgroup$
– Quintec
4 hours ago
1
1
$begingroup$
You've essentially made two separate challenges, one a decision problem and one about outputting the next number of a sequence. This will not do what you want, which is invite more answers, but instead put off users who now need to consider three options about what to program before posting. I'd recommend removing the option, and in the future you can try posting to our sandbox first where hopefully you will get helpful feedback before posting. Good luck!
$endgroup$
– FryAmTheEggman
5 hours ago
$begingroup$
You've essentially made two separate challenges, one a decision problem and one about outputting the next number of a sequence. This will not do what you want, which is invite more answers, but instead put off users who now need to consider three options about what to program before posting. I'd recommend removing the option, and in the future you can try posting to our sandbox first where hopefully you will get helpful feedback before posting. Good luck!
$endgroup$
– FryAmTheEggman
5 hours ago
$begingroup$
@SriotchilismO'Zaic thanks for the feedback! I have edited the post.
$endgroup$
– Tau
5 hours ago
$begingroup$
@SriotchilismO'Zaic thanks for the feedback! I have edited the post.
$endgroup$
– Tau
5 hours ago
$begingroup$
@FryAmTheEggman thank you, I'll keep that in mind. The post has been edited.
$endgroup$
– Tau
5 hours ago
$begingroup$
@FryAmTheEggman thank you, I'll keep that in mind. The post has been edited.
$endgroup$
– Tau
5 hours ago
1
1
$begingroup$
Note: This is A129868
$endgroup$
– tsh
4 hours ago
$begingroup$
Note: This is A129868
$endgroup$
– tsh
4 hours ago
2
2
$begingroup$
Should
119
be true?$endgroup$
– Quintec
4 hours ago
$begingroup$
Should
119
be true?$endgroup$
– Quintec
4 hours ago
|
show 4 more comments
8 Answers
8
active
oldest
votes
$begingroup$
Python 2, 30 bytes
lambda n:(2*n^2*n+3)**2==8*n+9
Try it online!
$endgroup$
add a comment |
$begingroup$
Japt, 25 19 10 bytes
¢èT ¶1©¢ês
That's more like it...
Checks if there is only one 0 in the binary representation and that the binary representation is a palindrome.
Try it online!
$endgroup$
$begingroup$
found an even shorter way, based on your solution :)
$endgroup$
– Embodiment of Ignorance
4 hours ago
add a comment |
$begingroup$
Japt, 8 bytes
¤øT ©¢ês
Based off of Quintec's solution.
Try it Online!
Old regex-based solution, 15 bytes
¤f/^(1*)01$/ l
Returns 1 for true, 0 for false.
Try it Online!
$endgroup$
$begingroup$
Well played, I should really learn regular expressions sometime. :) +1
$endgroup$
– Quintec
4 hours ago
$begingroup$
@Quintec Regex is awesome :)
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
Update: found shorter way :)
$endgroup$
– Quintec
4 hours ago
add a comment |
$begingroup$
Japt -N
, 6 bytes
Returns 1
for truthy, 0
or NaN
for falsy.
¤q0 äè
Run it online
$endgroup$
add a comment |
$begingroup$
Perl 6, 23 bytes
.base(2)~~/^(1*)0$0$/
Try it online!
Regex based solution
$endgroup$
add a comment |
$begingroup$
JavaScript (Node.js), 32 bytes
f=(p,q)=>p&1?f(p/2,q+q|2):!(p^q)
Try it online!
31 bytes version
f=(p,q)=>p&1?f(p>>1,q+q|2):p==q
This one will report falsy for 0.
JavaScript (Node.js), 35 bytes
p=>p.toString(2).match(/^(1*)01$/)
Try it online!
$endgroup$
add a comment |
$begingroup$
Mathematica (Wolfram language), 32 bytes
OddQ@Log[2,#+Floor@Sqrt[#/2]+2]&
Try it online!
Pure function taking an integer as input and returning True
or False
. Based on the fact (fun to prove!) that a number n
is Cyclops if and only if n
plus the square root of n/2
plus 2
rounds down to an odd power of 2. (One can replace Floor
by either Ceiling
or Round
as long as one also replaces +2
by +1
.) Returns True
on input 0
.
$endgroup$
add a comment |
$begingroup$
Jelly, 9 bytes
BŒḂaB¬S=1
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
);
);
Tau is a new contributor. Be nice, and check out our Code of Conduct.
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%2f181128%2fis-it-a-cyclops-number-nobody-knows%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
8 Answers
8
active
oldest
votes
8 Answers
8
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Python 2, 30 bytes
lambda n:(2*n^2*n+3)**2==8*n+9
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 2, 30 bytes
lambda n:(2*n^2*n+3)**2==8*n+9
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 2, 30 bytes
lambda n:(2*n^2*n+3)**2==8*n+9
Try it online!
$endgroup$
Python 2, 30 bytes
lambda n:(2*n^2*n+3)**2==8*n+9
Try it online!
answered 2 hours ago
xnorxnor
91.7k18187443
91.7k18187443
add a comment |
add a comment |
$begingroup$
Japt, 25 19 10 bytes
¢èT ¶1©¢ês
That's more like it...
Checks if there is only one 0 in the binary representation and that the binary representation is a palindrome.
Try it online!
$endgroup$
$begingroup$
found an even shorter way, based on your solution :)
$endgroup$
– Embodiment of Ignorance
4 hours ago
add a comment |
$begingroup$
Japt, 25 19 10 bytes
¢èT ¶1©¢ês
That's more like it...
Checks if there is only one 0 in the binary representation and that the binary representation is a palindrome.
Try it online!
$endgroup$
$begingroup$
found an even shorter way, based on your solution :)
$endgroup$
– Embodiment of Ignorance
4 hours ago
add a comment |
$begingroup$
Japt, 25 19 10 bytes
¢èT ¶1©¢ês
That's more like it...
Checks if there is only one 0 in the binary representation and that the binary representation is a palindrome.
Try it online!
$endgroup$
Japt, 25 19 10 bytes
¢èT ¶1©¢ês
That's more like it...
Checks if there is only one 0 in the binary representation and that the binary representation is a palindrome.
Try it online!
edited 4 hours ago
answered 4 hours ago
QuintecQuintec
1,9781726
1,9781726
$begingroup$
found an even shorter way, based on your solution :)
$endgroup$
– Embodiment of Ignorance
4 hours ago
add a comment |
$begingroup$
found an even shorter way, based on your solution :)
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
found an even shorter way, based on your solution :)
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
found an even shorter way, based on your solution :)
$endgroup$
– Embodiment of Ignorance
4 hours ago
add a comment |
$begingroup$
Japt, 8 bytes
¤øT ©¢ês
Based off of Quintec's solution.
Try it Online!
Old regex-based solution, 15 bytes
¤f/^(1*)01$/ l
Returns 1 for true, 0 for false.
Try it Online!
$endgroup$
$begingroup$
Well played, I should really learn regular expressions sometime. :) +1
$endgroup$
– Quintec
4 hours ago
$begingroup$
@Quintec Regex is awesome :)
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
Update: found shorter way :)
$endgroup$
– Quintec
4 hours ago
add a comment |
$begingroup$
Japt, 8 bytes
¤øT ©¢ês
Based off of Quintec's solution.
Try it Online!
Old regex-based solution, 15 bytes
¤f/^(1*)01$/ l
Returns 1 for true, 0 for false.
Try it Online!
$endgroup$
$begingroup$
Well played, I should really learn regular expressions sometime. :) +1
$endgroup$
– Quintec
4 hours ago
$begingroup$
@Quintec Regex is awesome :)
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
Update: found shorter way :)
$endgroup$
– Quintec
4 hours ago
add a comment |
$begingroup$
Japt, 8 bytes
¤øT ©¢ês
Based off of Quintec's solution.
Try it Online!
Old regex-based solution, 15 bytes
¤f/^(1*)01$/ l
Returns 1 for true, 0 for false.
Try it Online!
$endgroup$
Japt, 8 bytes
¤øT ©¢ês
Based off of Quintec's solution.
Try it Online!
Old regex-based solution, 15 bytes
¤f/^(1*)01$/ l
Returns 1 for true, 0 for false.
Try it Online!
edited 4 hours ago
answered 4 hours ago
Embodiment of IgnoranceEmbodiment of Ignorance
1,516123
1,516123
$begingroup$
Well played, I should really learn regular expressions sometime. :) +1
$endgroup$
– Quintec
4 hours ago
$begingroup$
@Quintec Regex is awesome :)
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
Update: found shorter way :)
$endgroup$
– Quintec
4 hours ago
add a comment |
$begingroup$
Well played, I should really learn regular expressions sometime. :) +1
$endgroup$
– Quintec
4 hours ago
$begingroup$
@Quintec Regex is awesome :)
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
Update: found shorter way :)
$endgroup$
– Quintec
4 hours ago
$begingroup$
Well played, I should really learn regular expressions sometime. :) +1
$endgroup$
– Quintec
4 hours ago
$begingroup$
Well played, I should really learn regular expressions sometime. :) +1
$endgroup$
– Quintec
4 hours ago
$begingroup$
@Quintec Regex is awesome :)
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
@Quintec Regex is awesome :)
$endgroup$
– Embodiment of Ignorance
4 hours ago
$begingroup$
Update: found shorter way :)
$endgroup$
– Quintec
4 hours ago
$begingroup$
Update: found shorter way :)
$endgroup$
– Quintec
4 hours ago
add a comment |
$begingroup$
Japt -N
, 6 bytes
Returns 1
for truthy, 0
or NaN
for falsy.
¤q0 äè
Run it online
$endgroup$
add a comment |
$begingroup$
Japt -N
, 6 bytes
Returns 1
for truthy, 0
or NaN
for falsy.
¤q0 äè
Run it online
$endgroup$
add a comment |
$begingroup$
Japt -N
, 6 bytes
Returns 1
for truthy, 0
or NaN
for falsy.
¤q0 äè
Run it online
$endgroup$
Japt -N
, 6 bytes
Returns 1
for truthy, 0
or NaN
for falsy.
¤q0 äè
Run it online
answered 2 hours ago
OliverOliver
5,2001832
5,2001832
add a comment |
add a comment |
$begingroup$
Perl 6, 23 bytes
.base(2)~~/^(1*)0$0$/
Try it online!
Regex based solution
$endgroup$
add a comment |
$begingroup$
Perl 6, 23 bytes
.base(2)~~/^(1*)0$0$/
Try it online!
Regex based solution
$endgroup$
add a comment |
$begingroup$
Perl 6, 23 bytes
.base(2)~~/^(1*)0$0$/
Try it online!
Regex based solution
$endgroup$
Perl 6, 23 bytes
.base(2)~~/^(1*)0$0$/
Try it online!
Regex based solution
answered 4 hours ago
Jo KingJo King
24.4k357126
24.4k357126
add a comment |
add a comment |
$begingroup$
JavaScript (Node.js), 32 bytes
f=(p,q)=>p&1?f(p/2,q+q|2):!(p^q)
Try it online!
31 bytes version
f=(p,q)=>p&1?f(p>>1,q+q|2):p==q
This one will report falsy for 0.
JavaScript (Node.js), 35 bytes
p=>p.toString(2).match(/^(1*)01$/)
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (Node.js), 32 bytes
f=(p,q)=>p&1?f(p/2,q+q|2):!(p^q)
Try it online!
31 bytes version
f=(p,q)=>p&1?f(p>>1,q+q|2):p==q
This one will report falsy for 0.
JavaScript (Node.js), 35 bytes
p=>p.toString(2).match(/^(1*)01$/)
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (Node.js), 32 bytes
f=(p,q)=>p&1?f(p/2,q+q|2):!(p^q)
Try it online!
31 bytes version
f=(p,q)=>p&1?f(p>>1,q+q|2):p==q
This one will report falsy for 0.
JavaScript (Node.js), 35 bytes
p=>p.toString(2).match(/^(1*)01$/)
Try it online!
$endgroup$
JavaScript (Node.js), 32 bytes
f=(p,q)=>p&1?f(p/2,q+q|2):!(p^q)
Try it online!
31 bytes version
f=(p,q)=>p&1?f(p>>1,q+q|2):p==q
This one will report falsy for 0.
JavaScript (Node.js), 35 bytes
p=>p.toString(2).match(/^(1*)01$/)
Try it online!
edited 3 hours ago
answered 4 hours ago
tshtsh
9,32511652
9,32511652
add a comment |
add a comment |
$begingroup$
Mathematica (Wolfram language), 32 bytes
OddQ@Log[2,#+Floor@Sqrt[#/2]+2]&
Try it online!
Pure function taking an integer as input and returning True
or False
. Based on the fact (fun to prove!) that a number n
is Cyclops if and only if n
plus the square root of n/2
plus 2
rounds down to an odd power of 2. (One can replace Floor
by either Ceiling
or Round
as long as one also replaces +2
by +1
.) Returns True
on input 0
.
$endgroup$
add a comment |
$begingroup$
Mathematica (Wolfram language), 32 bytes
OddQ@Log[2,#+Floor@Sqrt[#/2]+2]&
Try it online!
Pure function taking an integer as input and returning True
or False
. Based on the fact (fun to prove!) that a number n
is Cyclops if and only if n
plus the square root of n/2
plus 2
rounds down to an odd power of 2. (One can replace Floor
by either Ceiling
or Round
as long as one also replaces +2
by +1
.) Returns True
on input 0
.
$endgroup$
add a comment |
$begingroup$
Mathematica (Wolfram language), 32 bytes
OddQ@Log[2,#+Floor@Sqrt[#/2]+2]&
Try it online!
Pure function taking an integer as input and returning True
or False
. Based on the fact (fun to prove!) that a number n
is Cyclops if and only if n
plus the square root of n/2
plus 2
rounds down to an odd power of 2. (One can replace Floor
by either Ceiling
or Round
as long as one also replaces +2
by +1
.) Returns True
on input 0
.
$endgroup$
Mathematica (Wolfram language), 32 bytes
OddQ@Log[2,#+Floor@Sqrt[#/2]+2]&
Try it online!
Pure function taking an integer as input and returning True
or False
. Based on the fact (fun to prove!) that a number n
is Cyclops if and only if n
plus the square root of n/2
plus 2
rounds down to an odd power of 2. (One can replace Floor
by either Ceiling
or Round
as long as one also replaces +2
by +1
.) Returns True
on input 0
.
answered 2 hours ago
Greg MartinGreg Martin
12.3k21059
12.3k21059
add a comment |
add a comment |
$begingroup$
Jelly, 9 bytes
BŒḂaB¬S=1
Try it online!
$endgroup$
add a comment |
$begingroup$
Jelly, 9 bytes
BŒḂaB¬S=1
Try it online!
$endgroup$
add a comment |
$begingroup$
Jelly, 9 bytes
BŒḂaB¬S=1
Try it online!
$endgroup$
Jelly, 9 bytes
BŒḂaB¬S=1
Try it online!
answered 1 hour ago
Nick KennedyNick Kennedy
52127
52127
add a comment |
add a comment |
Tau is a new contributor. Be nice, and check out our Code of Conduct.
Tau is a new contributor. Be nice, and check out our Code of Conduct.
Tau is a new contributor. Be nice, and check out our Code of Conduct.
Tau is a new contributor. Be nice, and check out our Code of Conduct.
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%2f181128%2fis-it-a-cyclops-number-nobody-knows%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
1
$begingroup$
You've essentially made two separate challenges, one a decision problem and one about outputting the next number of a sequence. This will not do what you want, which is invite more answers, but instead put off users who now need to consider three options about what to program before posting. I'd recommend removing the option, and in the future you can try posting to our sandbox first where hopefully you will get helpful feedback before posting. Good luck!
$endgroup$
– FryAmTheEggman
5 hours ago
$begingroup$
@SriotchilismO'Zaic thanks for the feedback! I have edited the post.
$endgroup$
– Tau
5 hours ago
$begingroup$
@FryAmTheEggman thank you, I'll keep that in mind. The post has been edited.
$endgroup$
– Tau
5 hours ago
1
$begingroup$
Note: This is A129868
$endgroup$
– tsh
4 hours ago
2
$begingroup$
Should
119
be true?$endgroup$
– Quintec
4 hours ago