Post History
BQN, 24 bytesSBCS {gββΌπΒ¨β(1<β )π©βΛβ§gβ2|ββ π©} Run online! {gββΌπΒ¨β(1<β )π©βΛβ§gβ2|ββ π©} { } # Block function π with argument π© β π© # Length of π© ...
Answer
#1: Initial revision
# [BQN](https://mlochbaum.github.io/BQN/), 24 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup> ``` {gββΌπΒ¨β(1<β )π©βΛβ§gβ2|ββ π©} ``` [Run online!](https://mlochbaum.github.io/BQN/try.html#code=QkNF4oaQe+KIvuKXi/CdlYrCtPCdlaniipTLnDJ84oaV4omg8J2VqX3ijoriiqIgICAgICAgICAgIyBFbmNyeXB0CkJDROKGkHtn4oqU4oG88J2VisKo4o2fKDE84omgKfCdlaniipTLnOKIp2fihpAyfOKGleKJoPCdlal9ICAjIERlY3J5cHQKQkNEwqgg4p+oCiAgIiIKICAiQ1RZUk9QIgogICJFT1lDVE5OUFJJIgogICJSVU9FTkZTRUFGTVJESFQiCuKfqQ==) ``` {gββΌπΒ¨β(1<β )π©βΛβ§gβ2|ββ π©} { } # Block function π with argument π© β π© # Length of π© β # Range: 0,1,β¦,n gβ2| # Mod 2: 0,1,0,β¦ β§ # Sort: 0,0,β¦,1,1,β¦ π©βΛ # Group π© by the above, splitting it in two β(1<β ) # If 1 is less than the length... πΒ¨ # ...call this function on each element gββΌ # Ungroup as if grouped by 0,1,0,1,β¦ ``` BQN doesn't directly offer a "zip" function for interleaving. However, its Undo (`βΌ`) modifier can combine with [Group](https://mlochbaum.github.io/BQN/doc/group.html) to reverse an *un*interleaving. `ββΌ` isn't required [by the spec](https://mlochbaum.github.io/BQN/spec/inferred.html#undo) and dzaima/BQN doesn't support it; another 24-byte solution is `{(ββββΒ·βΎβπΒ΄π©βΛβ§)2|ββ π©}ββ’`. Using Undo means that the decoding program is similar to the encoding program given in the online link. The reason why decoding uses both normal and undone Group while encoding uses it only once is that for encoding the groups do not need to be mixed together, so [Join](https://mlochbaum.github.io/BQN/doc/join.html) (`βΎ`) can be used instead.