Post History
Haskell, 219 194 bytes h!n=x n?(a?c$d>n&&(even a?f(<)$f(==)))$h where(a,b)=e!!(c-1);(c,d)=dropWhile((<n).snd)e!!0;f g=g(n*2)$b+d x n=m?(2^(e-1)*(m+32))$e<1where(e,m)=divMod ...
Answer
#6: Post edited
# [Haskell], <del>219</del> 195 bytes- <!-- language-all: lang-hs -->
- h!n=x n?(a?c$d>n&&(even a?f(<)$f(==)))$h where(a,b)=e!!(c-1);(c,d)=dropWhile((<n).snd)e!!0;f g=g(n*2)$b+d
- x n=m?(2^(e-1)*(m+32))$e<1where(e,m)=divMod n 32
e=map(\a->(a,x a))[0..]- (a?b)c|c=a|0<1=b
[Try it online!][TIO-ku9ys2xw]- Depending on the first argument:
- * False - Encode
- * True - Decode
- [Haskell]: https://www.haskell.org/
[TIO-ku9ys2xw]: https://tio.run/##TdBdb4IwFAbge38FJsSco0igfChqJdnFkl3sakt24VxSoAoZFIOfS/zvjslse/ckffuenuZs/83L8nbL@4JeDBEDi1MzW4rBAPiJC4PFG1iguQFKEdHMjXPOGw7MSpDyfh/SsYtzSK0MadbUu4@8KDnAQqC9Fxm2CWe@MbZ0C2JI0ExGWa@dQqsYyBfw9u4QqpFH2ma@cLtqblVtV3F6rTNDGB7pcVqxHXyy8bIdezEY4sqx7XWvfWqC6TWl7OosXJrcKlYIWogDb1h6MPd5fbb/bh5FemyaH@gj2tBwls1mb4emENvxcgVPdV1aL@KAa7yt4JmVe245aP3LlfI0EsnQU/QVA8VQcaI4VYwkJ9pc4mn2NQeaQ80TzVPNqt71tH5tHRKoHuIQdeA7903fm2P3JXe4D3hKMnX/jk6@VCAVPhTJXCRzkcxFKjeRY@9LdQzlYwjxFGUTCQJc/wI "Haskell – Try It Online"
- # [Haskell], <del>219</del> 194 bytes
- <!-- language-all: lang-hs -->
- h!n=x n?(a?c$d>n&&(even a?f(<)$f(==)))$h where(a,b)=e!!(c-1);(c,d)=dropWhile((<n).snd)e!!0;f g=g(n*2)$b+d
- x n=m?(2^(e-1)*(m+32))$e<1where(e,m)=divMod n 32
- e=map((,).id<*>x)[0..]
- (a?b)c|c=a|0<1=b
- [Try it online!][TIO-kuavvk6w]
- Depending on the first argument:
- * False - Encode
- * True - Decode
- [Haskell]: https://www.haskell.org/
- [TIO-kuavvk6w]: https://tio.run/##TdBdb4IwFAbge38FJsSco0igfChKJdnFkl3sakt2YVxSoQoZFIP4sWT/3TGcbe@epG/f09OcHb94Wd5u@VDQqyESYElqZisxGgE/c2GwZAcxmjugFBHN3LjkvOHArC1SPhxCOnVxCamVIc2a@vCRFyUHiAXaR5Fhl3CWO2NP9yDGBM3tJBt0U2iVAPkE3t0dQzXxSNfMY/deza2q6yrOr3VmCMMjA04rdgCw0C6yeLy64tqx7c2ge@kW05@Ush8ndun2VrFC0EK0vGFpax7z@mL/XTyJ9NQ03zBEtKHhLFss3tqmEPvpag1PdV1aL6LFDd7W8MzKI7cctP7lSnkaiWToKfqKgWKoOFOcK0aSM20u8TT7mgPNoeaZ5rlmVe96Wr@2DglUD3GIOvCdftP35nT/kh7uA56STPXfcZcvFUiFD0UyF8lcJHORys3k2H6pO0P5GEI8RdlEggA3vw "Haskell – Try It Online"
#5: Post edited
# [Haskell], <del>219</del> 196 bytes- <!-- language-all: lang-hs -->
- h!n=x n?(a?c$d>n&&(even a?f(<)$f(==)))$h where(a,b)=e!!(c-1);(c,d)=dropWhile((<n).snd)e!!0;f g=g(n*2)$b+d
x n=m?(2^(e-1)*(m+32))$e<1where (e,m)=divMod n 32- e=map(\a->(a,x a))[0..]
- (a?b)c|c=a|0<1=b
[Try it online!][TIO-ku9ypvjx]- Depending on the first argument:
- * False - Encode
- * True - Decode
- [Haskell]: https://www.haskell.org/
[TIO-ku9ypvjx]: https://tio.run/##TdBdb4IwFAbge38FJsSco0igCIhaTXaxZBe72pJdOJcUqEIGxeDnEv87Yzjb3j1J376npxk7fPOiaJqsL@jVECtgq8RMl2IwAH7mwmCrLSzQ3AKliGhmxiXjNQdmxUh5vw/J2MU5JFaKNK2r/UeWFxxgIdA@iBTbhDPfGju6AzEkaMajtNdOoeUKyBfw9u4QypFH2ma@cLtqA7hVtmX5@bVKDWF4pMdpyfbwycbLdu7VYIhrx7Y3vfatMSa3hLKbs3Bp3JQsFzQXR16z5Ggesupi/908ieRU1z/QR7Sh5iydzd6OdS524@UanqqqsF7EETfYrOGZFQduOWj9y5XyNBLJwFOcKPqKgWKoOFWMJENtLvE0TzT7mgPNoeapZlXvelq/tg7xVQ9xiDqYON2m7/Xp/iUd3Ac8JZnqvuOuiZQvFTwUyVwkc5HMRSoXyrHdUncG8jGEeIqyifg@bn4B "Haskell – Try It Online"
- # [Haskell], <del>219</del> 195 bytes
- <!-- language-all: lang-hs -->
- h!n=x n?(a?c$d>n&&(even a?f(<)$f(==)))$h where(a,b)=e!!(c-1);(c,d)=dropWhile((<n).snd)e!!0;f g=g(n*2)$b+d
- x n=m?(2^(e-1)*(m+32))$e<1where(e,m)=divMod n 32
- e=map(\a->(a,x a))[0..]
- (a?b)c|c=a|0<1=b
- [Try it online!][TIO-ku9ys2xw]
- Depending on the first argument:
- * False - Encode
- * True - Decode
- [Haskell]: https://www.haskell.org/
- [TIO-ku9ys2xw]: https://tio.run/##TdBdb4IwFAbge38FJsSco0igfChqJdnFkl3sakt24VxSoAoZFIOfS/zvjslse/ckffuenuZs/83L8nbL@4JeDBEDi1MzW4rBAPiJC4PFG1iguQFKEdHMjXPOGw7MSpDyfh/SsYtzSK0MadbUu4@8KDnAQqC9Fxm2CWe@MbZ0C2JI0ExGWa@dQqsYyBfw9u4QqpFH2ma@cLtqblVtV3F6rTNDGB7pcVqxHXyy8bIdezEY4sqx7XWvfWqC6TWl7OosXJrcKlYIWogDb1h6MPd5fbb/bh5FemyaH@gj2tBwls1mb4emENvxcgVPdV1aL@KAa7yt4JmVe245aP3LlfI0EsnQU/QVA8VQcaI4VYwkJ9pc4mn2NQeaQ80TzVPNqt71tH5tHRKoHuIQdeA7903fm2P3JXe4D3hKMnX/jk6@VCAVPhTJXCRzkcxFKjeRY@9LdQzlYwjxFGUTCQJc/wI "Haskell – Try It Online"
#4: Post edited
# [Haskell], <del>219</del> 215 bytes- <!-- language-all: lang-hs -->
import Data.Bits- h!n=x n?(a?c$d>n&&(even a?f(<)$f(==)))$h where(a,b)=e!!(c-1);(c,d)=dropWhile((<n).snd)e!!0;f g=g(n*2)$b+d
x n=m?(2^(e-1)*(m+32))$e<1where m=n.&.31;e=div n 32- e=map(\a->(a,x a))[0..]
- (a?b)c|c=a|0<1=b
[Try it online!][TIO-ku9yllhp]- Depending on the first argument:
- * False - Encode
- * True - Decode
- [Haskell]: https://www.haskell.org/
[TIO-ku9yllhp]: https://tio.run/##TdBRa@owFAfwdz9FhCLnbLW0ia1WjcIYF@7zvbAH5yC20Za1qaR124V9d9dbtyRvP8g//5OTQrSvsqqu17I@N7ojj6ITwUPZtaNirPgHUVsQ28zLN2oyAfkmFRHbI6zROwLniOgV5L2QWoLwD8jleAzZNMIVZH6OPNfN@akoKwmwVhi0Ksc@Ea6O5MRPoO4oeof7fNRP4fUW6AvI/u4d1PeM9s1yHQ3VpOYqmAQsWkmel29EEUZHktfiDM9iuuknfxCBuAuDYD/qX3vA7DPj4jNcR/xwrUWpeKk6qUXWeW3RvAf/b15UdtH6H4wRA9BS5Mvln06X6jTd7OChaSr/t@pwj9cd/BJVK/0Q/W9FRswhNUyY5cwytkws55YLy9Rw7sylzPHMcew4cTx3vHBs6yPm9Dvr0Nj20JDag1k4bPpXX25fMiD6AbMyqeE7bpoZxUbJj1KTS00uNbnU5uZm7LDUjYl5DKXM0jTROMb9Fw "Haskell – Try It Online"
- # [Haskell], <del>219</del> 196 bytes
- <!-- language-all: lang-hs -->
- h!n=x n?(a?c$d>n&&(even a?f(<)$f(==)))$h where(a,b)=e!!(c-1);(c,d)=dropWhile((<n).snd)e!!0;f g=g(n*2)$b+d
- x n=m?(2^(e-1)*(m+32))$e<1where (e,m)=divMod n 32
- e=map(\a->(a,x a))[0..]
- (a?b)c|c=a|0<1=b
- [Try it online!][TIO-ku9ypvjx]
- Depending on the first argument:
- * False - Encode
- * True - Decode
- [Haskell]: https://www.haskell.org/
- [TIO-ku9ypvjx]: https://tio.run/##TdBdb4IwFAbge38FJsSco0igCIhaTXaxZBe72pJdOJcUqEIGxeDnEv87Yzjb3j1J376npxk7fPOiaJqsL@jVECtgq8RMl2IwAH7mwmCrLSzQ3AKliGhmxiXjNQdmxUh5vw/J2MU5JFaKNK2r/UeWFxxgIdA@iBTbhDPfGju6AzEkaMajtNdOoeUKyBfw9u4QypFH2ma@cLtqA7hVtmX5@bVKDWF4pMdpyfbwycbLdu7VYIhrx7Y3vfatMSa3hLKbs3Bp3JQsFzQXR16z5Ggesupi/908ieRU1z/QR7Sh5iydzd6OdS524@UanqqqsF7EETfYrOGZFQduOWj9y5XyNBLJwFOcKPqKgWKoOFWMJENtLvE0TzT7mgPNoeapZlXvelq/tg7xVQ9xiDqYON2m7/Xp/iUd3Ac8JZnqvuOuiZQvFTwUyVwkc5HMRSoXyrHdUncG8jGEeIqyifg@bn4B "Haskell – Try It Online"
#3: Post edited
# [Haskell], <del>219</del> 218 bytes- <!-- language-all: lang-hs -->
- import Data.Bits
- h!n=x n?(a?c$d>n&&(even a?f(<)$f(==)))$h where(a,b)=e!!(c-1);(c,d)=dropWhile((<n).snd)e!!0;f g=g(n*2)$b+d
x n=m?(2^(e-1)*(m+32))$e<1where m=n.&.31;e=shift n(-5)- e=map(\a->(a,x a))[0..]
- (a?b)c|c=a|0<1=b
[Try it online!][TIO-ku9yf4bp]- Depending on the first argument:
- * False - Encode
- * True - Decode
- [Haskell]: https://www.haskell.org/
[TIO-ku9yf4bp]: https://tio.run/##TdBda8IwFAbge39FhSLnaC1t@uE6jcIYg11vsAvnILbRlrWppHVz4H93XZ1J7h7Im/fkJGfNJy/Ly6WoDrVsrUfWMvehaJtBPhT0ZIkVsFVqZ0sxGgH/4sJiqx0s0N4BpYho59Z3ziUH5myR8uEQ0qmPc0idDGkm68NbXpQcYCHQbUSGXcKb76w93YMYE7S3k2zQTaHVCsgH8O7uGKpJQLpmvvD7aquiwh25gT/ntMmLXWsJmEY44LRiB3hn02U3/GQxxLXnuptB9@AtpueUsrO38On2UrFC0EK0XLK0tZu8/nb/bh5FepTyB4aILkjOsvv7l1YWYj9druGhrkvnWbS4wcsanljZcMdD51@@UmCQKMaBZqgZacaaM807zURxZswlgeHQcGQ4NjwzfGdY1/uB0W@sQyLdQzyiD0Kv3/RVHq9f0sO/IdBSqf47rgqVIqX4pkTlEpVLVC7RuZka2y91ZaweQ0igqZpIFOHmFw "Haskell – Try It Online"
- # [Haskell], <del>219</del> 215 bytes
- <!-- language-all: lang-hs -->
- import Data.Bits
- h!n=x n?(a?c$d>n&&(even a?f(<)$f(==)))$h where(a,b)=e!!(c-1);(c,d)=dropWhile((<n).snd)e!!0;f g=g(n*2)$b+d
- x n=m?(2^(e-1)*(m+32))$e<1where m=n.&.31;e=div n 32
- e=map(\a->(a,x a))[0..]
- (a?b)c|c=a|0<1=b
- [Try it online!][TIO-ku9yllhp]
- Depending on the first argument:
- * False - Encode
- * True - Decode
- [Haskell]: https://www.haskell.org/
- [TIO-ku9yllhp]: https://tio.run/##TdBRa@owFAfwdz9FhCLnbLW0ia1WjcIYF@7zvbAH5yC20Za1qaR124V9d9dbtyRvP8g//5OTQrSvsqqu17I@N7ojj6ITwUPZtaNirPgHUVsQ28zLN2oyAfkmFRHbI6zROwLniOgV5L2QWoLwD8jleAzZNMIVZH6OPNfN@akoKwmwVhi0Ksc@Ea6O5MRPoO4oeof7fNRP4fUW6AvI/u4d1PeM9s1yHQ3VpOYqmAQsWkmel29EEUZHktfiDM9iuuknfxCBuAuDYD/qX3vA7DPj4jNcR/xwrUWpeKk6qUXWeW3RvAf/b15UdtH6H4wRA9BS5Mvln06X6jTd7OChaSr/t@pwj9cd/BJVK/0Q/W9FRswhNUyY5cwytkws55YLy9Rw7sylzPHMcew4cTx3vHBs6yPm9Dvr0Nj20JDag1k4bPpXX25fMiD6AbMyqeE7bpoZxUbJj1KTS00uNbnU5uZm7LDUjYl5DKXM0jTROMb9Fw "Haskell – Try It Online"
#2: Post edited
# [Haskell], 219 bytes- <!-- language-all: lang-hs -->
- import Data.Bits
h!n|h=x n|0<1=a?c$d>n&&(even a?f(<)$f(==))where(a,b)=e!!(c-1);(c,d)=dropWhile((<n).snd)e!!0;f g=g(n*2)$b+d- x n=m?(2^(e-1)*(m+32))$e<1where m=n.&.31;e=shift n(-5)
- e=map(\a->(a,x a))[0..]
- (a?b)c|c=a|0<1=b
- Depending on the first argument:
- * False - Encode
- * True - Decode
[Try it online!][TIO-ktzzs86z]- [Haskell]: https://www.haskell.org/
[TIO-ktzzs86z]: https://tio.run/##TdDRasIwFAbge5@iQpFztJY2tdWqUZAx2PUGu3AOYhttWZtKWqcD3925OpPcfZA//8lJxuovXhTXa14eKtlYT6xh7ipv6k7WFZeMni1x8eY@ZcvEThei1wP@zYXFljuYo70DShFPGZccmLNFyrtdSIY@ziBxUqSprA7vWV5wgLlAtxYp3hLebGft6R5En6C9HaSd2xBaLoF8Ar/d7UM5CAiized@W22VVLg9N/BnnNZZvmssAcMQO5yW7AAfbLi4DT9bDHHtue6mA2y5xeSSUNY@fXstWS5oLhouWdLYdVad3L@bR5EcpfyBLqILkrN0On1tZC72w8UaVlVVOC@iwQ1e1/DMipo7Hjr/8pUCg0QxCjRHmqFmpDnWnGjGimNjLgkMjwyHhiPDY8MTw7reD4x@Yx0S6h7iEX0w8tpN3@Tx/iUt/AcCLZVqv@OukVKoFD0Uq1yscrHKxTo3VmPbpe6M1GMICTRVEwlD3PwC "Haskell – Try It Online"
- # [Haskell], <del>219</del> 218 bytes
- <!-- language-all: lang-hs -->
- import Data.Bits
- h!n=x n?(a?c$d>n&&(even a?f(<)$f(==)))$h where(a,b)=e!!(c-1);(c,d)=dropWhile((<n).snd)e!!0;f g=g(n*2)$b+d
- x n=m?(2^(e-1)*(m+32))$e<1where m=n.&.31;e=shift n(-5)
- e=map(\a->(a,x a))[0..]
- (a?b)c|c=a|0<1=b
- [Try it online!][TIO-ku9yf4bp]
- Depending on the first argument:
- * False - Encode
- * True - Decode
- [Haskell]: https://www.haskell.org/
- [TIO-ku9yf4bp]: https://tio.run/##TdBda8IwFAbge39FhSLnaC1t@uE6jcIYg11vsAvnILbRlrWppHVz4H93XZ1J7h7Im/fkJGfNJy/Ly6WoDrVsrUfWMvehaJtBPhT0ZIkVsFVqZ0sxGgH/4sJiqx0s0N4BpYho59Z3ziUH5myR8uEQ0qmPc0idDGkm68NbXpQcYCHQbUSGXcKb76w93YMYE7S3k2zQTaHVCsgH8O7uGKpJQLpmvvD7aquiwh25gT/ntMmLXWsJmEY44LRiB3hn02U3/GQxxLXnuptB9@AtpueUsrO38On2UrFC0EK0XLK0tZu8/nb/bh5FepTyB4aILkjOsvv7l1YWYj9druGhrkvnWbS4wcsanljZcMdD51@@UmCQKMaBZqgZacaaM807zURxZswlgeHQcGQ4NjwzfGdY1/uB0W@sQyLdQzyiD0Kv3/RVHq9f0sO/IdBSqf47rgqVIqX4pkTlEpVLVC7RuZka2y91ZaweQ0igqZpIFOHmFw "Haskell – Try It Online"
#1: Initial revision
# [Haskell], 219 bytes <!-- language-all: lang-hs --> import Data.Bits h!n|h=x n|0<1=a?c$d>n&&(even a?f(<)$f(==))where(a,b)=e!!(c-1);(c,d)=dropWhile((<n).snd)e!!0;f g=g(n*2)$b+d x n=m?(2^(e-1)*(m+32))$e<1where m=n.&.31;e=shift n(-5) e=map(\a->(a,x a))[0..] (a?b)c|c=a|0<1=b Depending on the first argument: * False - Encode * True - Decode [Try it online!][TIO-ktzzs86z] [Haskell]: https://www.haskell.org/ [TIO-ktzzs86z]: https://tio.run/##TdDRasIwFAbge5@iQpFztJY2tdWqUZAx2PUGu3AOYhttWZtKWqcD3925OpPcfZA//8lJxuovXhTXa14eKtlYT6xh7ipv6k7WFZeMni1x8eY@ZcvEThei1wP@zYXFljuYo70DShFPGZccmLNFyrtdSIY@ziBxUqSprA7vWV5wgLlAtxYp3hLebGft6R5En6C9HaSd2xBaLoF8Ar/d7UM5CAiized@W22VVLg9N/BnnNZZvmssAcMQO5yW7AAfbLi4DT9bDHHtue6mA2y5xeSSUNY@fXstWS5oLhouWdLYdVad3L@bR5EcpfyBLqILkrN0On1tZC72w8UaVlVVOC@iwQ1e1/DMipo7Hjr/8pUCg0QxCjRHmqFmpDnWnGjGimNjLgkMjwyHhiPDY8MTw7reD4x@Yx0S6h7iEX0w8tpN3@Tx/iUt/AcCLZVqv@OukVKoFD0Uq1yscrHKxTo3VmPbpe6M1GMICTRVEwlD3PwC "Haskell – Try It Online"