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.
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]:[.. …
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
∪ …
6
votes
Compare Two Fractions With ASCII Art
Vyxal j, 31 29 27 bytes
yD∆Ŀ~cßdεȮ/‟ʁ≤‛x-i*ƛ\|j\|ø.
Try it Online! or Verify some test cases
-2 bytes thanks to lyxal :)
I'm aware of Vyncode but I'm probably going to stick to regular SBCS bytes in …
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\$
5
votes
American odds to probabilities
Ruby, 29 26 bytes
->n{(n>0?100:n=-n)/n+=1e2}
Attempt This Online!
Saved 3 bytes thanks to @MTN and @G B.
Ports Luis felipe De jesus Munoz’s JavaScript submission.
Ruby, 34 28 bytes
->n{[-n,o=1e2].max …
5
votes
The vanilla factorial challenge
TypeScript Type System, 98 99 bytes
type X<A,B=A>=B extends`1${infer R}`?R extends""?A:B extends A?X<B,X<R>>:`${A&string}${X<R,A>}`:"1"
Try it at the TypeScript playground
+1 byte to make X<0> work p …
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 …
5
votes
Is it a tetrate of two?
Python, 32 bytes
f=lambda n,i=1:n==i or f(n,2**i)
Attempt This Online!
My idea was invalid in JS, because the recursion limit isn't guaranteed, but it's OK in Python because of that difference. Outpu …
5
votes
Calculate 500 digits of e
Python, 100 bytes
from decimal import*
getcontext().prec=500
e=d=Decimal(1)
for x in range(2,254):e+=1/d;d*=x
print(e)
Attempt This Online!
-2 bytes thanks to RubenVerg
254 is the lowest number which …
4
votes
Calculate 500 digits of e
Check that answer for a better understanding of the math.
Code explanation:
2 4000:a?:b)
2 4000 # Push 2, 4000 to the stack.
:a # Store 4000 in variable a.
? …
4
votes
Diagonalize a vector
TypeScript's Type System, 62 bytes
type F<V>={[I in keyof V]:{[J in keyof V]:J extends I?V[J]:0}}
Try it at the TypeScript Playground!
It's been a little while since I've golfed in TS types, so it's …
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 …
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 …
3
votes
Reconstruct Matrix from its diagonals
Uiua, 15 bytes
⍜⊕□◌.⊞+⟜⇌⇡⌈÷2⧻.
Try it: Uiua pad
This should be 13 bytes because ⍜⊕□◌. could hypothetically be replaced by ⌝⊕□, but it hasn't been implemented yet.
Explanation:
⌈÷2⧻ - Get the side len …
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 …