Skip to main content
Share Your Experience: Take the 2024 Developer Survey

New answers tagged

0 votes

*Trivial* near-repdigit perfect powers

Pip, 27 bytes W PtPB0P*t*Y489FE1=#t%Y%_+2 Outputs infinitely. Attempt This Online! Explanation This is an interesting challenge. I'm far from certain that this is ...
DLosc's user avatar
  • 39.7k
0 votes

Pascal's Triangle (Sort of)

Nibbles, 21 nibbles (10.5 bytes) =$+.`.,1!;:0$\@+`<$ Uses 1-based indexing. Attempt This Online! Explanation ...
DLosc's user avatar
  • 39.7k
0 votes

Is this number a prime?

AWK, 32 bytes {for(j=2;$0%j++;);print j~i?1:0} Try it online!
C K's user avatar
  • 81
0 votes

Crazy Librarian's Arithmetic Sequence of Primes

Vyxal, 25 bytes ₀+æ[λS₅ʀ?vṀ⌊JæA;₁ȯ|`∵Ǒ ƛ£ Try it Online! (first 5) ...
emanresu A's user avatar
  • 38.5k
1 vote

*Trivial* near-repdigit perfect powers

Perl 5 -Mbigint -p, 71 bytes $_=(sort{(log$a)-log$b}map{$z=10**$_,4*$z**2,9*$z**2,8*$z**3}1..$_)[$_] Try it online! Takes <...
Xcali's user avatar
  • 15.2k
1 vote

*Trivial* near-repdigit perfect powers

Python 3, 110 bytes n=int(input());k=lambda x,y:[x*(10**y)**i for i in range(1,n+1)];print(sorted(k(1,1)+k(4,2)+k(8,3)+k(9,2))[n]) Try it online! This answer is a ...
None1's user avatar
  • 931
1 vote

Golfing the complexity with subtraction

Ruby, 125 bytes f=->*r{g=->n{n<6?n:(2..n**0.5).map{|c|g[c]+r.map{|z|g[n/c+z]+g[[n%c,c-n%c][z]]}.min}.min}} 1.step{|x|f[0][x]>f[0,1][x]&&p(x)} ...
G B's user avatar
  • 22.1k
0 votes

How many partitions do I have?

Picat, 58 bytes f(N)=f(N,N). f(N,K)=cond(N*K<1,0**N**2,f(N-K,K)+f(N,K-1)). Attempt This Online! Uses fireflame241's recurrence with one base case. This example ...
Bubbler's user avatar
  • 76.8k
2 votes

How many partitions do I have?

Desmos, 53 52 bytes f(n)=g(n,n) g(n,m)=\{mn<1:0^{nn},g(n,m-1)+g(n-m,m)\} Try it on Desmos! Try it on Desmos! - Prettified Note that pasting this as-is will ...
fireflame241's user avatar
  • 16.3k
2 votes

*Trivial* near-repdigit perfect powers

TI-BASIC, 64 bytes Input T For(I,1,T ₁₀^(I→P 8P³→L₁(1+dim(L₁ augment(L₁,augment(seq(J²P²,J,2,3),{10P→L₁ End SortA(L₁ L₁(T This calculates the sequence, sorts it (...
Sylvester is on codidact.com's user avatar
1 vote

Golfing the complexity with subtraction

Charcoal, 94 bytes Nθ→≔⦃¹ⅈ⦄η≔ΦηιζW‹Lυθ«→F²«≔⎇κζηεF⁻ΣEεΣE⌕Aε⁻ⅈλ…⟦⁺μν×μν↔⁻μν⟧⁺²κEεμ§≔ελⅈ»≔Φ⌊⁻⊕EηλEηλ∧ꛧηκ§ζκυ»I…υθ Attempt This Online! Link is to verbose version ...
Neil's user avatar
  • 171k
4 votes

Golfing the complexity with subtraction

JavaScript (ES12), 180 bytes -1 thanks to Mukundan314 This was inspired by the Python code provided on A091333. Some optimizations borrowed from Mukundan314's answer. Prints the sequence indefinitely. ...
Arnauld's user avatar
  • 193k
2 votes

Golfing the complexity with subtraction

Python 3, 165 159 158 156 155 bytes -6 bytes thanks to @xnor Based on the Python code provided in A091333. ...
Mukundan314's user avatar
1 vote

Golfing the complexity with subtraction

Python 3.8 (pre-release), 214 201 (boolean magik) bytes ...
Sny's user avatar
  • 429
3 votes

Golfing the complexity with subtraction

JavaScript (V8), 112 bytes for(k=9;f=(n,i=n|=0)=>i-->3?Math.min(f(n,i),F(n/i)+F(i)+F(n%i),1/k+F(n/i+1)+F(i)+F(i-n%i)):n;)F(++k)%1&&print(k) Try it ...
l4m2's user avatar
  • 24.4k
2 votes

*Trivial* near-repdigit perfect powers

Vyxal 3, 17 bytes …ɾĖ:∥ᵛTd∥3*;²WfSi Try it Online! Uses the latest technology of arity grouping and properly implemented parallel apply. Ports my Vyxal 2 answer.
lyxal's user avatar
  • 33.5k
2 votes

*Trivial* near-repdigit perfect powers

Vyxal, 18 bytes ⇧ɾ↵:₌vTd:3e‟"²Wfsi Try it Online! A silly little answer. 1-indexed, outputs the nth item. Explained ...
lyxal's user avatar
  • 33.5k
3 votes

*Trivial* near-repdigit perfect powers

05AB1E, 25 20 bytes ∞¦°εŽ5×SDyÒgs5%ÖÏ*}˜ -5 bytes porting @CursorCoercer's Pyth answer, so make sure to upvote that answer as well! Outputs the infinite sequence. ...
Kevin Cruijssen's user avatar
5 votes

*Trivial* near-repdigit perfect powers

Pyth, 26 bytes KT#=*KTj*LKf!%lPK%T5j1489T Try it online! Outputs the infinite sequence. Explanation ...
CursorCoercer's user avatar
2 votes

*Trivial* near-repdigit perfect powers

APL+WIN, 46 bytes Prompts for number of terms: n↑1↓m[⍋m←∊((↑¨m)*3),((m←iר⊂2 3)*2),i←10*⍳n←⎕] Try it online! Thanks to Dyalog Classic
Graham's user avatar
  • 6,226
3 votes

*Trivial* near-repdigit perfect powers

Charcoal, 37 bytes NθI…ΦE⊗θ×I§1489ιXχ⁺²÷ι⁴¬﹪⊖Lι⁻³↔⁻²﹪κ⁴θ Try it online! Link is to verbose version of code. Explanation: ...
Neil's user avatar
  • 171k
5 votes

*Trivial* near-repdigit perfect powers

JavaScript (Node.js), 53 bytes n=>(c='14918149114891'[n%14]).padEnd(n/7*3+3.5-c/9,0) Try it online! -2 from Arnauld -1 from Tbw
l4m2's user avatar
  • 24.4k
1 vote

Is it a Mersenne Prime?

Pari/GP, 29 bytes A port of @lirtosiast's Mathematica answer in Pari/GP. Golfed version. Try it online! g(n)=isprime(bitand(n,n+2)*n)
138 Aspen's user avatar
  • 5,951
0 votes

Is it a Mersenne Prime?

05AB1E, 5 bytes bWIp* Try it online! Explanation b: push binary version of (implicit) input ...
Flummox's user avatar
  • 69
0 votes

Is it a Mersenne Prime?

Pyt, 8 bytes Đṗ⇹ɓąƖΠ* Try it online! ...
Kip the Malamute's user avatar
0 votes

Sum the powers that be

Pyt, 9 bytes ř←^ĐĐŁ⇹|· Try it online! ...
Kip the Malamute's user avatar
0 votes

Anti-divisors of a number

Scala 3, 59 bytes Golfed version. Attempt This Online! n=>{(2 to n-1).filter(m=>{val c=n%m*2-m;c> -2&&c<2}).toSeq} Ungolfed version. Attempt ...
138 Aspen's user avatar
  • 5,951

Top 50 recent answers are included