17
votes
Upside-Down Pyramid Addition...REVERSED!
JavaScript (ES6), 62 58 49 46 bytes
Saved 3 bytes thanks to @Oliver
Returns the list as a comma-separated string.
...
17
votes
Accepted
The fastest Sudoku solver
C++ - 0.201s official score
Using Tdoku (code; design; benchmarks) gives these results:
~/tdoku$ lscpu | grep Model.name
Model name: Intel(R) Core(TM) i7-4930K CPU @ 3.40GHz
~/tdoku$ # ...
13
votes
Shortest Code to Find the Smallest Missing Positive Integer
Nekomata + -1, 4 bytes
ŇPᵖf
Attempt This Online!
The flag -1 set the interpreter to ...
12
votes
Accepted
How quickly can you convert an NFA to a DFA?
Rust, score 15 in ≈ 6000 s
Most of my optimization effort has actually gone into memory usage rather than speed, for reasons you can see in this table of results on my system (AMD Ryzen 1800X):
...
11
votes
Climbing the Bookshelf
Wolfram Language (Mathematica), 33 bytes
dIf[Abs[#2-#]>d,0,1+#0@##2,0]&
Try it online!
Input [durability][heights...]. ...
10
votes
Gerrymander North Carolina
C++, score = 33.526203, all test cases in 2min34s
(of course, the score can be improved by running the program for more time; please do not do that to claim a victory or something)
That score is ...
9
votes
Accepted
Golfing Newton's Method
Golfed only, -23 bytes
ES6 supports default parameters.
Default function parameters allow formal parameters to be initialized
with default values if no value or ...
9
votes
The fastest Sudoku solver
C - 0.045s unofficial score
I got this time on my i7-9750H with 6 cores 12 threads @ 4Ghz. I'm aware that my cpu is faster than the i7-7700HQ so I think (hope) it would be closer to 0.080s if it were ...
9
votes
Maximum of outer product of integer vectors (in linear time)
JavaScript (Node.js), 84 bytes
f=([a,...x],m=1,n=1)=>a?f(x,Math.min(...q=a.flatMap(c=>[c*m,c*n])),Math.max(...q)):n
Try it online!
Keep trace of min and max
8
votes
8
votes
Accepted
Ethiopian Multiplication
Charcoal, 91 bytes
≔⟦⟧τ≔⁰σNθNηWθ«⊞τ⪫ Iθ⊞υ⪫⎇﹪θ² ¦[]Iη≔⁺σ∧﹪θ²ησ≔÷θ²θ≔⁺ηηη»⊞υ…=⁺²LIσ⊞υ⪫ Iσ←E⮌τ⮌ιM⌈EυLιLυ←E⮌υ⮌ι
Try it online! Link is to verbose version of code. ...
8
votes
128 years? Hypothetical leap year reform
C (gcc), 60 bytes
f(m,d,y){y-=m<3;return(y+y/4-y/128+"-bed=pen+mad."[m]+d)%7;}
Try it online!
Simple modification of Sakamoto's method. Takes input as integer ...
8
votes
Upside-Down Pyramid Addition...REVERSED!
Haskell, 22 bytes
foldl(flip$scanr(-))[]
Try it online!
8
votes
There's an echo in my array... echo in my array... my array
MATL, 16 bytes
t"GX@WQB&Y-~?w]x
Try it online! Or verify all test cases.
Explanation
Polynomial division for the win!
...
8
votes
Bridge the Gaps
Python, 2.62 * 10^40
This algorithm just floodfills (BFS) the plane starting from the black parts of the image, where for each new pixel we record what black part it was flooded from. As soon as we ...
8
votes
The fastest Sudoku solver
Node.js, 8.231s 6.735s official score
Takes the file name as argument. The input file may already contain the solutions in the format described in the challenge, in which case the program will ...
8
votes
Shortest Code to Find the Smallest Missing Positive Integer
Nibbles, 3 2 bytes (4 nibbles)
/-,~
I somehow didn't expect that fold-ing over an infinite list, starting from infinity (the ...
8
votes
Accepted
Elect the Doge of Venice
05AB1E, 24 bytes
•10¢–‘Þ}Ò•46вvNÉiK}.ry£=
Print each intermediate result as a list on a separated line to STDOUT.
Try it online.
Explanation:
...
7
votes
Upside-Down Pyramid Addition...REVERSED!
Haskell, 42 bytes
f[]=[]
f a=f(zipWith(-)a$tail a)++[last a]
Try it online!
7
votes
There's an echo in my array... echo in my array... my array
Haskell, 167 bytes
First it is important to notice that if there is an echo present, then the input array is a convolution of another array with some array of the form ...
7
votes
Bridge the Gaps
C, score 2.397x10^38
Man this took way too long to do, most likely due to my choice of language. I got the algorithm working fairly early, but ran into a lot of problems with memory allocation (...
7
votes
Climbing the Bookshelf
Octave / MATLAB, 37 35 bytes
2 bytes saved thanks to @Giuseppe!
@(x,d)sum(cumprod(abs(diff(x))<=d))
Output is 0-based.
Try it online!
7
votes
Shortest Code to Find the Smallest Missing Positive Integer
Zsh, 21 bytes
seq inf|grep -xvm1 $1
Attempt This Online!
seq inf: list of all positive integers
...
6
votes
128 years? Hypothetical leap year reform
Wolfram Language (Mathematica), 57 55 53 bytes
DayName@{m=#~Mod~128;6+Mod[(9#-m)/8-6Clip@m,28],##2}&
Try it online!
Takes three inputs: the year, the month, ...
6
votes
Upside-Down Pyramid Addition...REVERSED!
TI-BASIC, 54 bytes
Ans→L₁:dim(L₁→dim(L₂:While 1-Ans:L₁(Ans→L₂(Ans:-ΔList(L₁→L₁:dim(Ans:End:L₁(Ans→L₂(Ans:L₂
Input is the list of the right side of the triangle ...
6
votes
Climbing the Bookshelf
JavaScript (ES7), 41 bytes
-6 thanks to @emanresu A
d=>f=([a,...x])=>(a-x[0])**2<=d*d&&-~f(x)
JavaScript (ES7), 42 bytes
...
6
votes
6
votes
Climbing the Bookshelf
Perl 5 + -pa, 40 bytes
//,$\++while!eof&&"@F">=abs+($_=<>)-$'}{
Try it online!
Explanation
Thanks to ...
6
votes
Climbing the Bookshelf
Emojicode, 272 bytes
🏁🍇💯🆕🔡👂🏼❗️❗️➡️d🎶🆕🔡👂🏼❗️❗️➡️l l➡️🖍🆕a 0➡️🖍🆕c🐨a 0❗️🔂v a🍇↪️🍺💯v❗️➖🍺💯🐽l c❗️❗️▶🙌🍺d🍇🚪🐇💻c❗️🍉c⬅️➕1🍉🚪🐇💻c❗️🍉
Try it ...
6
votes
Maximum of outer product of integer vectors (in linear time)
Jelly, 12 10 bytes
Ṃ,ṀƊ×þFɗ/Ṁ
Try it online!
-2 from using Ɗ and ɗ for grouping instead of separate lines
This submission is a monadic link. For input, use a list ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
algorithm × 35code-golf × 25
math × 6
code-challenge × 4
array × 4
matrix × 4
fastest-code × 3
fastest-algorithm × 3
number × 2
ascii-art × 2
graphical-output × 2
random × 2
graph-theory × 2
optimization × 2
sudoku × 2
string × 1
kolmogorov-complexity × 1
tips × 1
date × 1
sorting × 1
permutations × 1
source-layout × 1
path-finding × 1
javascript × 1
puzzle-solver × 1