Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
The challenge involves mathematics in some central way. Also consider using more specific tags, listed in the tag wiki info.
1
vote
Output endless powers of 2
JavaScript (Node.js), 27 bytes
for(n=1;;)console.log(n*=2)
Attempt This Online!
JavaScript (Node.js), 33 bytes
function*(){for(n=1;;)yield n*=2}
Attempt This Online!
6
votes
Accepted
Output endless powers of 2
Vyxal, 2 bytes
¨²
Try it Online!
Builtin for infinite powers of 2.
Vyxal, 3 bytes
Þ∞E
Try it Online!
Þ∞ Infinite list of positive integers
E \$2^x\$
3
votes
Capture the Flag... with a twist
Japt -g, 14 bytes
x_Ì*3)nZg1)*ZÎ
Try it or verify all test cases.
Port of @AndrovT's Vyxal answer. Takes -1 for A and 1 for B. Outputs 1 for A, -1 for B, and 0 for draw.
x_Ì*3)nZg1)*ZÎ implicit inpu …
0
votes
The TAK function (easy mode)
JavaScript (Node.js), 28 bytes
(x,y,z)=>x<=y?y:x>y&y<=z?z:x
Attempt This Online!
Literal translation of the simple version.
1
vote
Shift right by half a trit
Uiua, 24 bytes
⨬⍜(-1°⊂⇌base3|⊙↘⟜¯¬)0⊸<2
Try it: Uiua pad. The comment # Experimental! enables the experimental base function, which has not yet been stabilized.
Explanation: A very elegant use of the …
1
vote
Triangle area from side lengths
JavaScript, 43 bytes (@Steffan)
Ported from Steffan's Python answer by him:
f=
(a,b,c)=>(4*a*a*b*b-(a*a+b*b-c*c)**2)**.5/4
console.log(f(1, 1, 1), 0.4330)
console.log(f(3, 4, 5), 6.0000)
console. …
3
votes
Add two really big numbers
Ruby, 78 67 59 49 bytes
->a,b{c=0;a.zip(b).map{s=_1+_2+c;c=s>9?1:0;s%10}}
Attempt This Online!
My first Ruby submission! This is probably a little golfable but I'm pretty happy with it considering I …
1
vote
Finding the power sandwich
GolfScript, 25 24 23 bytes
{0\{@@).2$?.-1$<}do@;@}
Try it online!
I’m pretty sure this method is optimal, considering GolfScript doesn’t have floats and thus no min/max. It’s possible that there’s a …
1
vote
Print 100 digits of Champernowne's Constant
GolfScript, 6 bytes
55,(;5
Try it online!
Prints the first 100 digits.
55, # the list 0..55
(; # drop the 0
5 # push 5 to the stack
# the stack is implicitly printed without separator
Al …
5
votes
Modular Equivalence
Thunno 2, 7 bytes
×__Fæ2>
Attempt This Online!
Based on Command Master’s idea, implemented a bit differently
× # Multiply. X * Y
_ # Swapped subtract. X * Y - X
_ # Swa …
2
votes
Test a number for narcissism
Uiua, 12 bytes
=/+ⁿ⧻.-@0°⋕.
Try it
Explanation:
-@0°⋕.
Convert the number to a list of digits.
ⁿ⧻.
Raise each to the power of the list's length.
=/+
Is this list's sum equal to the original?
7
votes
Add two really big numbers
TypeScript's Type System, 211 193 bytes
//@ts-ignore
type F<A,C=[]>=A extends[[...infer G,infer X],[...infer H,infer Y]]?[...X,...Y,...C]extends[1,1,1,1,1,1,1,1,1,1,...infer R]?[...F<[G,H],[1]>,R]:[.. …
1
vote
Find the maximum deviation
Japt -h, 12 bytes
ãV mÍ®Ì-ZÎÃÍ
Try it
ãV # subsequences of length V
mÍ # sort each, ascending
®Ì-ZÎà # map each to last - first
Í # sort, ascending
# -h flag prints the last element
2
votes
Is it a completely even number?
JavaScript, 14 11 bytes
-3 thanks to Deadcode
f=
n=>!(n&n-2)
// test numbers 0-16
const tests = [f(0), false, true, false, true, false, false, false, true, false, false, false, false, false, fals …
6
votes
The Jaccard Index
Vyxal, 8 7 6 bytes
₍↔∪@÷/
Try it Online!
-1 thanks to TheThonnu, -1 thanks to Lyxal
₍↔∪@÷/ # implicit input of two lists
₍ # apply each to the stack, and wrap:
↔ # intersection
∪ …