Skip to main content
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
Results tagged with
Search options answers only not deleted user 78410

Challenges with a spec which requires all answers to meet certain time complexity restrictions. This could be specific ("Your answer must be O(n^2) where n is the number of items in the input"), or at the level of complexity classes ("Your answer must be polynomial in the number of items in the input").

1 vote

Give a permutation with no two consecutive integers next to each other

Gol><>, 14 bytes FL:2%Z}:3=?$|B Try it online! Example full program & How it works 1AGIE;GDlR~ FL:2%Z}:3=?$|B 1AG Register row 1 as function G IE; Take number input; halt on EO …
Bubbler's user avatar
  • 78.4k
2 votes

Compute maximum excluding the current position

J, 20 19 bytes (]{~[=0{])(2$,\:,)/ Attempt This Online! Copy of my answer in chat to the CMC version of this challenge. -1 byte thanks to Jonah by spotting \:~@, → ,\:,. (]{~[=0{])(2$\:~@,)/ input: …
Bubbler's user avatar
  • 78.4k
13 votes

Sum of set bits from 1 to n

K (ngn/k), 45 32 bytes {+/b*1+(q!'x)+-2!q*<q:2/=#b:2\x} Try it online! Golfing ideas thanks to @ngn and @coltim The OEIS page contains a curious PARI program: a(n)=if(n==0,0,m=logint(n,2);r=n%2^m;m*2 …
Bubbler's user avatar
  • 78.4k
8 votes

Project Euler 1: Multiples in constant time

APL (Dyalog Extended), 31 bytes -/+/(⎕+⍳2)(⊢×2!⌈⍤|⍤÷)\∊(⊢,∧)\-⎕ Try it online! Full program which takes the list of divisors, and then the (start,end) pair. Uses a modified trick to generate all non …
Bubbler's user avatar
  • 78.4k
9 votes

Project Euler 1: Multiples in constant time

Jelly, 20 bytes +Ø.÷€AĊc2ḋIɓN;æl¥ƒ-Ḋ Try it online! Port of my own APL answer. Trailing ɓ chain trick is indeed strong :P How it works +Ø.÷€AĊc2ḋIɓN;æl¥ƒ-Ḋ Dyadic link; left=range, right=divisors …
Bubbler's user avatar
  • 78.4k