26

Python 2, 42 bytes f=lambda n,x=1:1/n*[x]or[x+1]+f(n-1,x*-~x) Try it online! The key thing to observe is that 1/n = 1/(n+1) + 1/(n*(n+1)). Therefore we can always obtain a solution with n fractions, by using a solution with n-1 fractions, and "splitting" the last fraction in two.


14

Haskell, 31 27 bytes -4 bytes thanks to Wheat Wizard! Takes an infinite list as input and returns each finite sublist an infinite number of times. f(a:l)=[]:do x<-f l;[a:x,x] Try it online!


13

Nibbles, 37 33 bytes ?, &" ";3 ! = $ `. ;~ `/ $ `D -2 :;!$ `' \@:.\$\$ `'<14>>^_$ `. 5 ~/$~ ~ >@$ @$ ~ 15a That's 66 nibbles, each taking half a byte in the binary form. This could probably be improved, and will definitely be beaten by the things that specialize in ascii art as it ...


13

brainfuck, 8 bytes ,,[..,,] Try it online!


12

Python 3, 33 bytes lambda s:sum(map(ord,s))%len(s)<1 Try it online!


12

Wolfram Language (Mathematica), 32 bytes Using Sylvester's sequence A000058 Nest[##&[#^2+#,1+#,##2]&,1,#-1]& Try it online! -8 bytes from @att


11

Python 3.8, 85 bytes Input is taken as a list of lines, with ‾ replaced with dashes (-). lambda L,n=0:len({(n:=n+2-ord(c:=max(x))//2%5)-x.index(c)+(c<'0')for x in zip(*L)})<2 Try it online!


11

Vyxal, 10 bytes ¡ɾṗ'Ė∑1=;t Try it Online! Bruteforcer. \$O\left(2^{n!}\right)\$ time complexity, searches for fractions with reciprocals \$ n! \$ which seems to be enough. ¡ # Factorial ɾṗ # All combinations of 1...n ' ; # Filtered by... Ė∑ # Sum of reciprocals 1= # is 1? t # Get the last one


11

JavaScript (ES6), 26 bytes -1 thanks to @thejonymyster -7 thanks to @Arnauld -4 thanks to @l4m2 x=>x.replace(/-2|1/,z=>~z) Swaps the first instance of -2 and 1, saving 1 byte when the program compresses itself. Takes the list of bytes as input, as a string. This is quite the community effort now :p


10

05AB1E, 1 byte æ Try it online! 05AB1E no builtin, 5 bytes [DNÏ, Try it online! Takes the input as an 05AB1E infinite lazy list [ infinite loop D create a copy of the infinite list N iteration index (starting from 0) Ï elements of the list for which the corresponding element of the index is 1 , print


10

Wolfram Language (Mathematica), 131 bytes Uncompress@"1:eJxTTMoPCt7DxMBgAAaGQIBGAkVjDAyNwJIGhthIuLwBRAM6CZbHYjKMhOrHpR0qj9VqCEnAfEOwPG7tcHlcDiDG/JHufgOC5lOWfsDyWMwHAQA6Moq3" Try it online! Uses 1 for dead cells, 0 for living and background (grey) cells. A boring answer using Mathematica's Uncompress built-in. Wolfram Language (Mathematica) + my ...


9

Jelly, 3 bytes ŻŻ+ Try it online! Using hyper's oberservation How it works ŻŻ+ - Main link. Takes a list L ŻŻ - Prepend two zeros + - Add elementwise


8

Python, 55 bytes n=0 while[print([s(b)for b in range(n)if n>>b&1])]:n+=1 Attempt This Online! Takes input using a black-box function predefined under the name s, which takes a number and outputs the corresponding 0-indexed value of the sequence. Shown in the ATO link using the powers of 2 [1, 2, 4, 8, .... Outputs to STDOUT. Uses the binary ...


8

Factor, 48 bytes [ 1 - 2 [ 3 dupn . sq - abs 1 + ] repeat 1 - . ] Try it online! Port of @ZaMoC's Mathematica answer. It prints the first n terms of Sylvester's sequence, subtracting 1 from the last number. The old way that doesn't quite work: [ [1,b] dup 1 rotate v* ]


8

J, 8 bytes #~0 2$~# Try it online! 0 2$~# Repeat the pattern 0 2 for the length of the string: Hello, World 020202020202 #~ Use that mask to "copy" the characters: zeros get deleted, twos get doubled: eell,,WWrrdd


8

convey, 8 bytes -1 thanks to Wheat Wizard! v2{ 0"!} Try it online! The 0 and 2 loop around, applying themselves to the input via ! (take), thus duping the element 0 or 2 times.


8

Python 3.8 (pre-release), 45 bytes lambda l,F:[i for i,e in enumerate(l)if F(e)] Try it online! Looks like it won't get much shorter than this. Explanation: keep all indexes (found by unpacking; the index is the first item of each 2-element tuple in the return value of enumerate) for which the function returns True for the corresponding element.


7

Retina 0.8.2, 9 bytes S`<(\w*)> Try it online! Link includes test suite that switches between [] and <> and separates the output lines for each case with - for convenience. Explanation: Simply splits on a minimal group, capturing the contents. The question now requires empty chunks, but the previous 10-byte version only required an extra _ ...


7

J, 43 39 bytes [:*/2=/@(I.@:*-1#.3 2&=+1&=)\' -\/'i.|: Try it online! ' -\/'i.|: Transpose and convert characters to integers. 2...(...)\ For each pair of rows... I.@:* Get the indices of the non-zero (non-space) element... -1#.3 2&=+1&= And adjust it as follows: 1&= If it's a - in either position, subtract 1. 3 2&= If it's a / on ...


7

JavaScript (ES6), 54 bytes f=a=>a.some(n=>+n.length!=a[0].length)?1:f(a.flat())+1 A quite simple approach: check if all elements are the same length, increment a counter if they are and repeat with the list flattened by one level, then return the counter. -3 bytes thanks to tsh. -1 more thanks to l4m2. f=a=>a.some(n=>+n.length!=a[0].length)?...


7

J, 49 bytes -1 thanks to Jonah This answer has 6 sides. [:+/@,i.@4(1==-{&(0 1,1,.i:1)@[|.!.0=)"{'_/|\'&i. Try it online! '_/|\'&i. Map walls to 0…4. i.@4 For each possible wall … |.!.0= shift the corresponding bitmap … {&(0 1,1,.i:1)@[ into the direction the wall points to. 1==- Subtract this from the original bitmap and keep the 1s. [:...


7

R, 44 38 bytes -6 bytes thanks to Dominic van Essen function(n)2^(1:n)*.75^(n:1<3)-(n<2)/2 Try it online! First Attempt function(n){k<-1:n;2^k*.75^(k>n-2)-(n==1)/2} Try it online! Port of my Excel answer.


7

Python 2, 41 bytes f=lambda s:s==s[::-1]and-~f(s[len(s)/2:]) Try it online! Simple recursive function. If the string is not a palindrome, returns false instead of 0 (which I think is allowed for Python).


7

Haskell, 28 bytes p!v=[i|(i,x)<-zip[0..]v,p x] Try it online! Explanation To get the indices we zip the list with the natural numbers [0..]. Then we use a list comprehension to get only the correct indices.


7

Perl 5 + -p -MList::Util+min, 28 bytes $\+=min$_,100+$-;$-=100-$_}{ Try it online! Explanation Adds the minimum of $_ (implicit input via -p) or 100+$- (where $- starts as 0) to $\ (which is automatically output at the end of all lines of input). $- is set to 100-$_, which is safe because $- can never be negative.


7

Haskell, 103 bytes head.([1..]>>=).g 1 0 g b i a d=[[]|a<1]++[j:o|j<-[max(div(b-1)a)i+1..div(b*d)a],o<-g(b*j)j(a*j-b)$d-1] Try it online! This uses iterative deepening depth-first search, using the bound \$\frac a{bd} ≤ \frac 1j ≤ \frac ab\$ on the first term \$\frac1j\$ of a size-\$d\$ Egyptian fraction for \$\frac ab\$. Unclear if this ...


6

Vyxal 2.4.1 K, 4 3 bytes ṁ1Ḋ Try it Online! Ah yes classic pre-2.6 jank ftw. -1 thanks to Dominic Explained ṁ1Ḋ # First, the input is converted to a list of corresponding ordinal values by the `K`(eg mode) flag: ṁ # push the arithmetic mean of that list 1Ḋ # is that divisible by 1? (i.e is it a whole number)


6

Python, 24 bytes lambda s:sum(s)%len(s)<1 Attempt This Online! Takes input as a byte string. We don't need to subtract 95 from each element, because the sum will end up having 95 * length added on, which has no effect on the result modulo length.


6

Wolfram Language (Mathematica), 30 bytes SatisfiableQ[#/.$->(#&&!#2&)]& Try it online! Takes input in the form $[$[a, $[b, c]], $[b, a]].


6

Retina, 77 bytes m/(?<=^|¶)([\\_]([_\/]|.*¶ [-\\])|[\/-][-\\]| [_\/].*¶[\/-])/+`^. ^\s*\S\s*$ Try it online! Link includes test suite that takes double-spaced test cases and converts ‾ to - which the script actually uses. Explanation: /(?<=^|¶)([\\_]([_\/]|.*¶ [-\\])|[\/-][-\\]| [_\/].*¶[\/-])/+ Repeat while the first two columns have a valid join, ...


Only top voted, non community-wiki answers of a minimum length are eligible