New answers tagged

1 vote

One OEIS after another

387. Cognate, 1984 bytes, A000350 ...
user avatar
  • 10.9k
1 vote

Numbers with Rotational Symmetry

PHP, 49 bytes (anonymous function) fn($s)=>$s==strrev(strtr($s,"6923457","9600000")) Try it online! PHP ...
user avatar
  • 9,610
0 votes

Numbers with Rotational Symmetry

Swift, 148 bytes ...
user avatar
  • 151
0 votes

Numbers with Rotational Symmetry

Brev, 80 bytes (define(r n)(= n((as-list reverse(over(vector-ref #(0 1 3 4 5 6 9 8 8 6)x)))n))) Non-minified: ...
user avatar
  • 290
0 votes

Numbers with Rotational Symmetry

PHP, 83 bytes <?=$argn==strrev(str_replace([6,9,x],[x,6,9],preg_replace("/[^01689]/","",$argn))); Save the code in a file (let's say ...
user avatar
  • 769
1 vote

Numbers with Rotational Symmetry

K (ngn/k), 21 bytes {y~|x[>x]x?y}/$68910, Try it online! 68910, prepend 68910 to the argument ...
user avatar
  • 14.7k
1 vote

One OEIS after another

386. Zig, 350 bytes, A000182 ...
user avatar
  • 36.1k
1 vote

Numbers with Rotational Symmetry

K (ngn/k), 25 24 bytes {d~|"01986""01689"?d:$x} Try it online! -1 byte thanks to @ngn My first version was 74 bytes but then I read @xnor's ...
user avatar
  • 311
2 votes

Numbers with Rotational Symmetry

Pure bash, 99 bytes Using shopt -s extglob: ...
user avatar
4 votes

Numbers with Rotational Symmetry

Knight, 70 bytes ;=p=sP;=a'';Ws;=a+I|?54=bAs?57bA-111bI||?48b?49b?56bAb''a=sSsF1''O?a p Working with strings is a pain in Knight Try It Online! Test Suite
user avatar
  • 5,790
0 votes

Iterated partial sums

PARI/GP, 31 bytes f(a,n)=Vec(Ser(a)/(1-x)^n+.5)\1 Attempt This Online! Converts the list to a power series, divides it by \$(1-x)^n\$, and then converts it back to ...
user avatar
  • 36.1k
1 vote

Hostile Divisor Numbers

Vyxal, 10 bytes λKvUfÞu;ȯt Try it Online!
user avatar
  • 9,066
1 vote

Iterated partial sums

Vyxal, 2 bytes Try it Online!
user avatar
  • 9,066
1 vote

Am I a Fibonacci Number?

dc, 34 bytes d0r^+0 1[d3R+d4Rd_5R>s]dssx0r4R-^p Try it online! Prints 1 if the number at the top of the stack is a fibonacci number, 0 otherwise.
user avatar
  • 475
3 votes

Delannoy numbers

K (ngn/k), 18 bytes {0/x(+':+\)/1,y#1} Try it online! Port of my APL answer that does not use the binomial coefficient built-in. See the linked answer for the ...
user avatar
  • 64.8k
0 votes

The plus-minus sequence

C (gcc), 62 bytes int f(int a,int b){for(;1;b=(a+=b)-2*b)printf("%d %d\n",a,b);} Try it online! Theoretically outputs indefinitely, however, it only ...
user avatar
  • 475
0 votes

Lolololololololololololol

Alice, 10 bytes "olL"wo~.K Try it online! Explanation ...
user avatar
  • 1,808
1 vote

Lolololololololololololol

Knight, 14 bytes ;O'L\'W1O'ol\' Try It Online! My first Knight answer :D
user avatar
  • 5,790
0 votes

An abundance of integers!

cQuents, 6 bytes $<U\z$ Try it online! Outputs 1 for true and 0 for false. If no input given, outputs the 1-indexed sequences of 1/0 for whether each index is ...
user avatar
  • 13.5k
1 vote

An abundance of integers!

Julia, 25 bytes a(n,r=1:n)=(n.%r.<1)'r>2n Attempt This Online!
user avatar
1 vote

Goldbach partitions

Regex 🐇 (ECMAScriptRME / Perl / PCRE), 38 bytes ^(x+)(?!(.*(?=\1$))?((xx+)\4+$|x?$))\1 Try it on replit.com! - ECMAScript (...
user avatar
  • 9,610
0 votes

Sums of Consecutive Integers

Knight, 66 bytes ;=i+=a 0P W;=r""!>=a+1=b a=c iW!>0c;=c-c=b+1b;=r+r+"+"bI?0cQ Or 0 Try it online! Annotated code: ...
user avatar
  • 1,431
1 vote

Sums of Consecutive Integers

Prolog (SWI), 75 71 bytes L/X/H:-between(L,H,X). N*Z:-1/A/N,A/X/N,findall(Y,A/Y/X,Z),sum(Z,#=,N). Try it online! -4 bytes thanks to DLosc.
user avatar
  • 9,066
4 votes

Fibonacci function or sequence

Trianguish, 152 135 bytes ...
user avatar
0 votes

Runs of Ones (What Fun!)

Retina, 25 bytes L$`(?<!1)1*(?=1) $.` $.>` Try it online! Link includes test cases. Explanation: Retina can compute the character index of the start of the ...
user avatar
  • 146k
0 votes

Runs of Ones (What Fun!)

J, 21 bytes [:]`<:/.@I.2~:/\0,,&0 Try it online! Returns a column vector. 0,,&0 Bookend the input with zeros. ...
user avatar
  • 28.6k
0 votes

Runs of Ones (What Fun!)

C (clang), 83 bytes c;i;f(*l,n){for(c=i=0;i<=n;++i)l[n-1]*i/n||i-n&&l[i]-c?printf("%d ",i-c,c=l[i]):0;} Try it online! Inputs a pointer to an ...
user avatar
  • 18.6k
1 vote
Accepted

Runs of Ones (What Fun!)

Jelly, 8 bytes Tḟ+¥ⱮØ+Z A monadic Link that accepts a list and yields a list of start, end pairs of truthy runs (1-indexed). Try it online! How? ...
user avatar
0 votes

Runs of Ones (What Fun!)

Desmos, 68 bytes L=join(0,l,0) g(k)=[0...L.length][L[2...]=L+2k-1]+k f(l)=(g(1),g(0)) The function \$f\$ returns a list of 1-indexed coordinate pairs. Seems ...
user avatar
  • 5,790
0 votes

Runs of Ones (What Fun!)

Charcoal, 26 bytes IΦE⪪θ0∧ι⁺⟦⁰⊖Lι⟧⁺L⪫…⪪θ0κωκι Try it online! Link is to verbose version of code. Explanation: ...
user avatar
  • 146k
4 votes

Runs of Ones (What Fun!)

Python, 57 bytes lambda L,i=0:[l+j for j,l in enumerate(L+[0])if i^(i:=l)] Attempt This Online!
user avatar
  • 8,180
1 vote

Runs of Ones (What Fun!)

lin, 46 bytes "1+".?g ?M \; `' "index""0", g:"len over +1-"' Try it here! Takes string and returns an iterator. For testing ...
user avatar
1 vote

Runs of Ones (What Fun!)

Pip -p, 13 bytes B-%_MEa@*`\b` Takes a string containing the characters 1 and ...
user avatar
  • 33.3k
1 vote

Runs of Ones (What Fun!)

JavaScript (ES6), 55 bytes Expects a binary string. Returns a space-separated list of comma-separated 0-based indices. ...
user avatar
  • 169k
3 votes

Runs of Ones (What Fun!)

R, 52 43 bytes \(x,r=rle(c(0,x)))if(any(x))cumsum(r$l)-r$v Attempt This Online! Outputs a flat vector 1-indexed. Explanation outline: Take run length encoding of ...
user avatar
  • 12.1k
2 votes

Runs of Ones (What Fun!)

Vyxal, 9 bytes aƛ?0pøĖ¦ε Try it Online! ...
user avatar
  • 9,066
0 votes

Is it a semiprime?

cQuents, 5 bytes 2=Lq$ Try it online! 1 for truthy, 0 for falsey. Explanation ...
user avatar
  • 13.5k
0 votes

Is it a semiprime?

Alice, 15 bytes /O\cdtv @I/ nt< Try it online! Flattened ...
user avatar
  • 1,808
0 votes

Can this number be written in (3^x) - 1 format?

Kotlin, 78 bytes {val x=kotlin.math.log(it+1.0,3.0);if(kotlin.math.round(x)==x)x.toInt()else-1} kotlin.math.log and ...
user avatar
  • 310
2 votes

Exponential transform of an integer sequence

Vyxal R, 16 bytes ṗṗ'fs¹ɾ⁼;vvLİvΠ∑ Try it Online! Port of Command Master's 05AB1E answer, upvote that!
user avatar
  • 9,066
1 vote

Exponential transform of an integer sequence

Charcoal, 36 bytes FLθ⊞υ∨¬ιΣEυ××κ§θ⁻ιλ∨¬λ÷Π…⁻ιλιΠ…·¹λIυ Try it online! Link is to verbose version of code. Explanation: A translation of the recurrence formula ...
user avatar
  • 146k
3 votes

Exponential transform of an integer sequence

Haskell, 59 bytes f@(a:b)&g@(c:d)=a*c:zipWith(+)(b&g)(f&d) _&_=[] e b=1:e b&b Try it online! e accepts the ...
user avatar
1 vote

Exponential transform of an integer sequence

Python, 85 bytes import math f=lambda n,l:sum(math.comb(n-1,i)*l[i]*f(n-i-1,l)for i in range(n))+(n<1) Attempt This Online! Doesn't take the leading zero in the input. If that's not allowed, I will ...
user avatar
  • 9,066
2 votes

Exponential transform of an integer sequence

Wolfram Language (Mathematica), 37 24 bytes BellY[#,,#2]~Sum~{,0,#}& Try it online! Based on the Mathematica code given by Vladimir Reshetnikov on OEIS A256180....
user avatar
  • 9,066
12 votes

Exponential transform of an integer sequence

05AB1E, 21 20 18 16 bytes L©ææʒ˜{®Q}€€gèPO Try it online! Returns the \$ i \$-th term, zero indexed. It runs in complexity \$ \Omega(2^{2^i}) \$, so it can only ...
user avatar
1 vote

The Squaring Sequence

cQuents, 14 bytes =1111:(ZZ)[:4] Try it online! 1-indexed. Explanation ...
user avatar
  • 13.5k
0 votes

The Squaring Sequence

C++ (clang), 52 bytes void s(int&n){n=--n?s(n),n*n/1e3/(n<3163?:10):1111;} Port of Lynn's C answer using recursion, is 1 indexed and returns via out ...
user avatar
  • 500
2 votes

The Squaring Sequence

Vyxal, 6 5 bytes Ṫ(²4Ẏ Try it online, or verify all test cases. Explanation: ...
user avatar
0 votes

Can this number be written in (3^x) - 1 format?

tinylisp, 68 bytes (d F(q((N A)(i(l N A)()(i(e A N)0(a 1(F N(a(a A A)A (q((N)(F(a N 1)1 The solution is the anonymous function on the second line. Try it online! ...
user avatar
  • 33.3k
1 vote

Can this number be written in (3^x) - 1 format?

Vyxal, 7 bytes ›3•D⌊=* Try it Online! -1 thanks to Steffan. A different approach that's annoyingly longer. ...
user avatar
  • 31.6k

Top 50 recent answers are included