Quantcast
Channel: Enumerate the Phat-fingered-lights-out numbers - Code Golf Stack Exchange
Browsing all 14 articles
Browse latest View live

Answer by Jonah for Enumerate the Phat-fingered-lights-out numbers

J, 23 21 bytes{.(#~0=-/"1@#:)@i.@*:Try it online!Uses Tbw's observation and is basically a port of Mukundan314's APL answer

View Article



Answer by Graham for Enumerate the Phat-fingered-lights-out numbers

APL+WIN, 29 bytesPrompts for an integer and outputs the sequence up to that value. Index origin = 0(0=-⌿((⌈2⍟1⌈n)⍴2)⊤m)/m←⍳1+n←⎕Try it online! Thanks toDyalog Classic

View Article

Answer by Mukundan314 for Enumerate the Phat-fingered-lights-out numbers

APL(Dyalog Unicode), 18 bytes SBCSRequires Index Origin 0...

View Article

Answer by Neil for Enumerate the Phat-fingered-lights-out numbers

Charcoal, 23 19 bytesNθI…Φ×θ⁺³Lθ¬↨↨ι²±¹θTry it online! Link is to verbose version of code. Outputs the first n terms. Explanation: Wildly overestimates an upper bound for A039004(n), then uses @Tbw's...

View Article

Answer by Jonathan Allan for Enumerate the Phat-fingered-lights-out numbers

Jelly, 6 bytesBḅ-¬µ#A full program that accepts a positive integer, n, on stdin and prints the first n phat-fingered-lights-out numbers.Try it online!How?Every phat-flip applies to an adjacent pair of...

View Article


Answer by Tbw for Enumerate the Phat-fingered-lights-out numbers

Uiua 0.9.0, 19 bytes SBCS⍥(+1(&p.|)≠0/-⋯.)∞0Try on Uiua Pad!Takes no input and outputs the sequence (change the ∞ to some small number like 10 if you want to see the beginning)Explanation0 # push 0...

View Article

Answer by Arnauld for Enumerate the Phat-fingered-lights-out numbers

JavaScript (V8), 45 bytesA full program that prints the sequence indefinitely.This relies on arithmetic underflow to stop the recursion, making it slower than it should (+1 byte for a faster...

View Article

Enumerate the Phat-fingered-lights-out numbers

Even though the concept of phat-fingered-lights-out number should be pretty self-explanatory here is a definition:Given a nonnegative integer in binary representation a phat-fingered double-bit-flip or...

View Article


Answer by Wheat Wizard for Enumerate the Phat-fingered-lights-out numbers

Haskell+hgl, 20 bytesfl(qb sm<%uak<bs2)nnAttempt This Online!ExplanationWe convert the list to base 2, split it into digits in an even position and digits in an odd position, then check that...

View Article


Answer by Arnold Palmer for Enumerate the Phat-fingered-lights-out numbers

Python 3, 107 bytesf=lambda n,i=0,l=[]:i-1if n==sum(l)else f(n,i+1,l+[a(i,2)==a(i,3)])a=lambda n,s:sum(map(int,bin(n)[s::2]))Try it online!Uses the same logic as other solutions to sum odd and even...

View Article

Answer by Kevin Cruijssen for Enumerate the Phat-fingered-lights-out numbers

05AB1E, 7 bytes∞<ʒb®ö_Outputs a lazy infinite list.Try it online.Or:[Nb®ö_–Infinitely outputs all results on a separated newline to STDOUT.Try it online.Both are a port of @JonathanAllan's Jelly...

View Article

Answer by m90 for Enumerate the Phat-fingered-lights-out numbers

x86 32-bit machine code, 23 bytes83 C8 FF 40 BA AA AA AA AA 31 C2 F3 0F B8 D2 83 FA 10 75 EF E2 ED C3Try it online!Following the fastcall calling convention, this takes a number n in ECX and returns...

View Article

Answer by 138 Aspen for Enumerate the Phat-fingered-lights-out numbers

Scala 3, 212 bytesA port of @Arnold Palmer's Python answer in Scala.Golfed version. Attempt This Online!def f(n:Int,i:Int=0,l:Seq[Boolean]=Seq()):Int={if(n==l.count(identity))i-1 else...

View Article


Answer by Arnold Palmer for Enumerate the Phat-fingered-lights-out numbers

C (gcc), 107 bytesb[2],i,c,k;f(n){k=c=0;while(k^n){b[0]=b[1]=i=0;while(i<32)b[i%2]+=(c>>i++)&1;if(b[0]==b[1])k++;c++;}n=c-1;}Try it online!Uses a 2 element array to count odd and even...

View Article
Browsing all 14 articles
Browse latest View live




Latest Images