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.


15

convey, 108 bytes You never said that the program must have an output, you said in fact "a program that displays exactly the following ASCII animation" And my program has that animation inside it: >>,'######'[ ^<v ^< >>>v >>>v >,<<< ,<<< ^ >v'######'[ ^<< >^,'######'[ ...


15

Python 3.8 (pre-release), 287 bytes f=lambda g=0,n=1,c=0,s=set():g<n**(n*n)and(s:=s|{g,sum(i//n*n**i for i in range(n*n)),sum(i%n*n**i for i in range(n*n))})+f(g+1,n,c+([s:=s|{sum(g//n**(l//n**i%n*n+r//n**i%n)%n*n**i for i in range(n*n))}for _ in"a"*n**(n*n) for l in s for r in s]and len(s)==n**(n*n)))or print(c)+f(0,n+1) Try it online! Uses a ...


15

BQN, 3 bytesSBCS Perfect challenge for BQN's occurence count builtin. +⟜⊒ Run online! The modifier ⟜ composes two functions. If there is a single argument (as is the case here), the right function is called on that argument, and then the left function is called with that result and the original argument: (f⟜g x) ≡ (x f g x) The builtin ⊒ takes a vector and ...


15

Python 3.8, 48 46 bytes 2-byte savings jointly contributed by Jonathan Allan and dingledooper lambda L,j=1:[n-(j:=j-1)-L.index(n)for n in L] Try it online! Explanation The original 48-byte solution is easier to explain: lambda L:[n+i-L.index(n)for i,n in enumerate(L)] Consider each number \$n\$ in the list together with its index \$i\$. Suppose that we ...


15

Python, 34 bytes lambda p:{*p[::2]}<{*p}>{*p[1::2]} Attempt This Online! Accepts a single string. Works for any distinct 4 characters for empty,black,white,newline. How? Uses the fact that including the linebreak lines have odd length, hence going over the entire string skipping every other character separates black and white squares. Both subsets must ...


15

Brachylog, 3 bytes p↰ᵐ Try it online! Explanation This takes the first list as the input variable, and the second list as the output variable. The interpreter then prints true. if it is possible to satisfy this predicate with these variables, and false. otherwise. p The output is a permutation of the input ↰ᵐ Recursively call this predicate on each ...


15

Factor, 37 16 bytes [ mean fixnum? ] Try it online! Is the mean of the input an integer? Why does this work? Four reasons. Strings in Factor are just sequences of code points. Because the question is asking for a sum divided by a length. Otherwise known as the mean. The mean word returns a ratio, not a float. In Factor, ratios automatically reduce to ...


14

CP-1610 machine code, 33 DECLEs1 ≈ 42 bytes2 1. A CP-1610 opcode is encoded with a 10-bit value (0x000 to 0x3FF), known as a 'DECLE'. 2. As per the exception described in this meta answer, the exact score is 41.25 bytes (330 bits) Uses $'s and spaces. Loops forever. Each frame is displayed during ~650 ms. This is a full program mapped in the memory range $...


14

Python 3, 47 bytes lambda l:(sorted({*l},key=l.count)*2)[-len(l):] Try it online!


14

Python, 29 bytes lambda l:[x+max(l)for x in l] Try it online! Just adds the list maximum to each element, producing values greater than any in the original list. The max of the resulting list is double the original max, so we can invert by lowering each element by half the new max. decoder=lambda r:[x-max(r)//2 for x in r] You can encode with sum in place ...


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

Python 2, 57 bytes lambda l:[x for c in 1,2,1for x in set(l)if l.count(x)-c] Try it online! Iterates through the distinct elements of l 3 times, first outputting those that appear twice in l, then those that appear once, then twice again. -1 byte by att Python 3.8, 47 bytes def f(l):*map(l.remove,s:={*l}),;l+=[*s-{*l}]+l Try it online! -3 bytes by pxeger ...


13

Python, 54 bytes (-1 @Jonathan Allan, -1 me) f=lambda n,d:n and'gf'[p:=n*d>0]+f(p*n-d,[n,d][p])or'' Attempt This Online! Old Python, 56 bytes (@tsh) f=lambda n,d:n*d<0and'g'+f(-d,n)or n and'f'+f(n-d,d)or'' Attempt This Online! Old Python, 57 bytes f=lambda n,d:n//d<0and'g'+f(-d,n)or n and'f'+f(...


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 2, 41 bytes f=lambda n:ord(`map(f,n*[n/4])+[5]`[1+n]) Attempt This Online! Thanks to @loopywalt Uses Python's string representation of tuples to get the , parts of the sequence (44 32). Python 2, 42 bytes f=lambda n:ord("5"[n:]or`f(n/4),1`[1+n%4]) Attempt This Online! Here are some variations, but I've not been able to get any of them ...


12

Perl 5, 23 bytes s/[aeiou]/$&^$"x$|--/ge Try it online! Explanation s///ubstitutes each of the lowercase vowels with itself XORed with either 1 or 0 spaces ($" defaults to space) based on $|-- which will alternate each time it's decremented.


12

BQN*, 53 45 bytesSBCS {1+⊑⍒+˝+´(∨∨∨˝∘×⎉1‿∞)⍟n˜∨⟜⍉∨˝𝕩≡⌜1+⋈⌜˜n←↕⌈´∾𝕩} Run online! Theory: Let \$k\$ be the maximum node id. Then the node IDs are \$\{1, 2, ..., k\}\$. For the given adjacency list we can construct an adjancency matrix \$A=(a_{ij}) \in \{0,1\}^{k \times k}\$, where \$a_{ij} = 1\$ iff \$i=j\$ or node \$i\$ and node \$j\$ are adjacent. The ...


12

R, 42 39 33 bytes function(w)!mean(utf8ToInt(w))%%1 Try it online! -6 bytes thanks to m90.


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

C (gcc), 61 bytes A full program, where input is taken from STDIN. x;main(c){for(;read(0,&c,1);)putchar('Xz'%c?c:c^x++%2*32);} Try it online! Checking for vowels Vowels are aeiou, which have the corresponding ASCII codes 97,101,105,111,117. The LCM of these numbers is 1484392455, which has the property of being evenly divisible by only the ...


11

Haskell, 45 bytes The top line is a function that returns the nth digit (0-based). (!!)=<<f 1 f d n=1:(f(1-d)=<<[d..n-1+d])++[0] Try it online! The function f generates both \$f(n)\$ with d=1 and \$g(n)\$ with d=0. The top line is a point free version of h n = f 1 n !! n where !! is Haskells indexing operator.


11

Python 3, 49 bytes lambda x,y:g(x)==g(y) g=lambda a:sorted(map(g,a)) Try it online!


11

Pyth, 7 bytes s^S4^5* We could construct a universal sequence of length \$2^{2n(n-1)} ⋅ n^2 ⋅ (2n^2 - 2) < 5^{n^2}\$. Start with the empty sequence; then for each of the at most \$2^{2n(n-1)}\$ mazes and \$n^2\$ possible starts, imagine following all the previously appended commands to get a new location, and append \$2n^2 - 2\$ more commands ...


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

Charcoal, 21 bytes ↶⁴FNF⁵«↷¹X²÷⁺﹪κ²ι²↷¹¶ Try it online! Link is to verbose version of code. Explanation: ↶⁴ Make the output upside-down relative to the output Charcoal would like to produce. FN Loop over each quadrilateral. F⁵« Draw five sides, so that the cursor is in the correct place to draw the next one. ↷¹X²÷⁺﹪κ²ι²↷¹¶ Draw one diagonal of the ...


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