New answers tagged sequence
1
vote
1
vote
Numbers with Rotational Symmetry
PHP, 49 bytes (anonymous function)
fn($s)=>$s==strrev(strtr($s,"6923457","9600000"))
Try it online!
PHP ...
0
votes
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:
...
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 ...
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
...
1
vote
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 ...
2
votes
Numbers with Rotational Symmetry
Pure bash, 99 bytes
Using shopt -s extglob:
...
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
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 ...
1
vote
1
vote
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.
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 ...
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 ...
0
votes
1
vote
Lolololololololololololol
Knight, 14 bytes
;O'L\'W1O'ol\'
Try It Online!
My first Knight answer :D
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 ...
1
vote
1
vote
Goldbach partitions
Regex 🐇 (ECMAScriptRME / Perl / PCRE), 38 bytes
^(x+)(?!(.*(?=\1$))?((xx+)\4+$|x?$))\1
Try it on replit.com! - ECMAScript (...
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:
...
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.
4
votes
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 ...
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.
...
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 ...
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?
...
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 ...
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:
...
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!
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 ...
1
vote
Runs of Ones (What Fun!)
Pip -p, 13 bytes
B-%_MEa@*`\b`
Takes a string containing the characters 1 and ...
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.
...
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 ...
2
votes
0
votes
Is it a semiprime?
cQuents, 5 bytes
2=Lq$
Try it online!
1 for truthy, 0 for falsey.
Explanation
...
0
votes
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 ...
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!
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 ...
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 ...
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 ...
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....
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 ...
1
vote
The Squaring Sequence
cQuents, 14 bytes
=1111:(ZZ)[:4]
Try it online!
1-indexed.
Explanation
...
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 ...
2
votes
The Squaring Sequence
Vyxal, 6 5 bytes
Ṫ(²4Ẏ
Try it online, or verify all test cases.
Explanation:
...
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!
...
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.
...
Top 50 recent answers are included
Related Tags
sequence × 847code-golf × 781
number × 230
math × 209
number-theory × 107
integer × 82
combinatorics × 67
primes × 63
arithmetic × 59
fibonacci × 45
binary × 36
string × 35
subsequence × 29
code-challenge × 28
cops-and-robbers × 28
decision-problem × 26
base-conversion × 25
kolmogorov-complexity × 20
array × 19
geometry × 17
permutations × 17
fastest-code × 17
grid × 15
palindrome × 12
restricted-time × 11