Skip to main content
added 630 characters in body
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240
console.log([
0b1111111111001111,
0b1111111110110101,
0b1111111101111111,
0b1111111011110110,
0b1111100000111011,
0b1111100000111111,
0b1110000000001111,
0b1100000000000111,
0b1100000000000111,
0b1000000000000011,
0b1000010000000011,
0b1100010000000111,
0b1100001000000111,
0b1110000000001111,
0b1111000000011111,
0b1111110001111111
].map(x=>String.fromCharCodex=>(65535-x).toString(16)).join``join(","))

After that, we can just repeat the string n times and add a newline. This is the shortest decompression method I have found, but feel free to suggest any possibly shorter methods.

Other attempts at compressing the string:

n=>[48,74,128,265,1988,1984,8176,16376,16376,32764,31740,15352,15864,8176,4064,896].map(x=>(f=q=>q?(q&1?"  ":"##")+f(q>>1):"")(65535-x).repeat(n)).join`
`
n=>"1c,22,3k,7d,1j8,1j4,6b4,cmw,cmw,pa4,oho,bug,c8o,6b4,34w,ow".split`,`.map(x=>(f=q=>q?(q&1?"  ":"##")+f(q>>1):"")(65535-parseInt(x,36)).repeat(n)).join`
`
n=>"30,4a,80,109,7c4,7c0,1ff0,3ff8,3ff8,7ffc,7bfc,3bf8,3df8,1ff0,fe0,380".split`,`.map(x=>(f=q=>q?(q&1?"  ":"##")+f(q>>1):"")('0x'+x^65535)).repeat(n)).join`
`

The first of these is 153 bytes, so none of them come anywhere near 136...

console.log([
0b1111111111001111,
0b1111111110110101,
0b1111111101111111,
0b1111111011110110,
0b1111100000111011,
0b1111100000111111,
0b1110000000001111,
0b1100000000000111,
0b1100000000000111,
0b1000000000000011,
0b1000010000000011,
0b1100010000000111,
0b1100001000000111,
0b1110000000001111,
0b1111000000011111,
0b1111110001111111
].map(x=>String.fromCharCode(x)).join``)

After that, we can just repeat the string n times and add a newline. This is the shortest decompression method I have found, but feel free to suggest any possibly shorter methods.

console.log([
0b1111111111001111,
0b1111111110110101,
0b1111111101111111,
0b1111111011110110,
0b1111100000111011,
0b1111100000111111,
0b1110000000001111,
0b1100000000000111,
0b1100000000000111,
0b1000000000000011,
0b1000010000000011,
0b1100010000000111,
0b1100001000000111,
0b1110000000001111,
0b1111000000011111,
0b1111110001111111
].map(x=>(65535-x).toString(16)).join(","))

After that, we can just repeat the string n times and add a newline. This is the shortest decompression method I have found, but feel free to suggest any possibly shorter methods.

Other attempts at compressing the string:

n=>[48,74,128,265,1988,1984,8176,16376,16376,32764,31740,15352,15864,8176,4064,896].map(x=>(f=q=>q?(q&1?"  ":"##")+f(q>>1):"")(65535-x).repeat(n)).join`
`
n=>"1c,22,3k,7d,1j8,1j4,6b4,cmw,cmw,pa4,oho,bug,c8o,6b4,34w,ow".split`,`.map(x=>(f=q=>q?(q&1?"  ":"##")+f(q>>1):"")(65535-parseInt(x,36)).repeat(n)).join`
`
n=>"30,4a,80,109,7c4,7c0,1ff0,3ff8,3ff8,7ffc,7bfc,3bf8,3df8,1ff0,fe0,380".split`,`.map(x=>(f=q=>q?(q&1?"  ":"##")+f(q>>1):"")('0x'+x^65535)).repeat(n)).join`
`

The first of these is 153 bytes, so none of them come anywhere near 136...

golfed 4 bytes thanks to Missy Elliott
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240

JavaScript (ES6), 159 154 140140 136 bytes

n=>[..."ఀ刀Ā邀⏠Ϡ࿸ῼῼ㿾㿞῜ᾼ࿸߰ǀ"]"ᅬᄉソﻶ쀇쀇考萃쐇숇ﱿ"].map(x=>(f=q=>q>1f=q=>q?f(q>>1)+(q&1?"##":"  ":"##")+f(q>>1):"")(65536+xx.charCodeAt()).repeat(n)).join`
`

That's 112104 chars, but 140(sadly) 136 UTF-8 bytes. The string was generated with this snippet:

console.log([
0b00001100000000000b1111111111001111,
0b01010010000000000b1111111110110101,
0b00000001000000000b1111111101111111,
0b10010000100000000b1111111011110110,
0b00100011111000000b1111100000111011,
0b00000011111000000b1111100000111111,
0b00001111111110000b1110000000001111,
0b00011111111111000b1100000000000111,
0b00011111111111000b1100000000000111,
0b00111111111111100b1000000000000011,
0b00111111110111100b1000010000000011,
0b00011111110111000b1100010000000111,
0b00011111101111000b1100001000000111,
0b00001111111110000b1110000000001111,
0b00000111111100000b1111000000011111,
0b00000001110000000b1111110001111111
].map(x=>String.fromCharCode(x)).join``)
n=>"ఀ刀Ā邀⏠Ϡ࿸ῼῼ㿾㿞῜ᾼ࿸߰ǀ"n=>"ᅬᄉソﻶ쀇쀇考萃쐇숇ﱿ".replace(/./g,x=>(f=q=>q>1f=q=>q?f(q>>1)+(q&1?"##":"  ":"##")+f(q>>1):"")(65536+xx.charCodeAt()).repeat(n)+`
`)

Since each row of the raw data can be represented as a 16-bit number, we can store the entire file in a 16-char string. The compression algorithm simply takes each 16-bit char-codebinary row, flips it and reverses it (since every row in the original ends in a 0, every row in the modified version now starts with a 1), then turns it into a char, and concatenates the resulting characters.

(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(x.charCodeAt())

However, the result is not padded, which causes a problem. A basic way to do this would be to pad the beginning with a bunch of spaces, then take the last 32 chars:

(" ".repeat(32)+(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(x.charCodeAt())).slice(-32)

Obviously, that's a little long. ES7 actually has a built-in for this; let's try using that:

(f=q=>q>1?f+f(q>>1)+(q&1?"##":"  "):"")(x.charCodeAt()).padStart(32," ")

Better, but not good enough. Another way to do it would be to padf repeatedly takes the number itself with zeroes before stringifying it:

(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt()).slice(2)

That's even betterlast bit of q, butselecting two spaces if it's 1 or two hashes if it's 0, then concatenates that with the result of running .slice(2)f still seems like a little bitin the rest of a wasteq. It turns out that there's an easy way around this: since there's always a final unnecessaryThis is run on 1x.charCodeAt(), we can just ignoreturning the result when it gets down to 1char-code into the correct string of spaces and hashes. This saves

(There was a fewlot more bytes:drama here before, but the 4-byte-saving technique erased all of that.)

(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt())

JavaScript (ES6), 159 154 140 bytes

n=>[..."ఀ刀Ā邀⏠Ϡ࿸ῼῼ㿾㿞῜ᾼ࿸߰ǀ"].map(x=>(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt()).repeat(n)).join`
`

That's 112 chars, but 140 UTF-8 bytes. The string was generated with this snippet:

console.log([
0b0000110000000000,
0b0101001000000000,
0b0000000100000000,
0b1001000010000000,
0b0010001111100000,
0b0000001111100000,
0b0000111111111000,
0b0001111111111100,
0b0001111111111100,
0b0011111111111110,
0b0011111111011110,
0b0001111111011100,
0b0001111110111100,
0b0000111111111000,
0b0000011111110000,
0b0000000111000000
].map(x=>String.fromCharCode(x)).join``)
n=>"ఀ刀Ā邀⏠Ϡ࿸ῼῼ㿾㿞῜ᾼ࿸߰ǀ".replace(/./g,x=>(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt()).repeat(n)+`
`)

Since each row of the raw data can be represented as a 16-bit number, we can store the entire file in a 16-char string. The compression algorithm simply takes each 16-bit char-code, turns it into a char, and concatenates the resulting characters.

(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(x.charCodeAt())

However, the result is not padded, which causes a problem. A basic way to do this would be to pad the beginning with a bunch of spaces, then take the last 32 chars:

(" ".repeat(32)+(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(x.charCodeAt())).slice(-32)

Obviously, that's a little long. ES7 actually has a built-in for this; let's try using that:

(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(x.charCodeAt()).padStart(32," ")

Better, but not good enough. Another way to do it would be to pad the number itself with zeroes before stringifying it:

(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt()).slice(2)

That's even better, but the .slice(2) still seems like a little bit of a waste. It turns out that there's an easy way around this: since there's always a final unnecessary 1, we can just ignore the result when it gets down to 1. This saves a few more bytes:

(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt())

JavaScript (ES6), 159 154 140 136 bytes

n=>[..."ᅬᄉソﻶ쀇쀇考萃쐇숇ﱿ"].map(x=>(f=q=>q?(q&1?"  ":"##")+f(q>>1):"")(x.charCodeAt()).repeat(n)).join`
`

That's 104 chars, but (sadly) 136 UTF-8 bytes. The string was generated with this snippet:

console.log([
0b1111111111001111,
0b1111111110110101,
0b1111111101111111,
0b1111111011110110,
0b1111100000111011,
0b1111100000111111,
0b1110000000001111,
0b1100000000000111,
0b1100000000000111,
0b1000000000000011,
0b1000010000000011,
0b1100010000000111,
0b1100001000000111,
0b1110000000001111,
0b1111000000011111,
0b1111110001111111
].map(x=>String.fromCharCode(x)).join``)
n=>"ᅬᄉソﻶ쀇쀇考萃쐇숇ﱿ".replace(/./g,x=>(f=q=>q?(q&1?"  ":"##")+f(q>>1):"")(x.charCodeAt()).repeat(n)+`
`)

Since each row of the raw data can be represented as a 16-bit number, we can store the entire file in a 16-char string. The compression algorithm takes each binary row, flips it and reverses it (since every row in the original ends in a 0, every row in the modified version now starts with a 1), then turns it into a char, and concatenates the resulting characters.

(f=q=>q?(q&1?"  ":"##")+f(q>>1):"")(x.charCodeAt())

f repeatedly takes the last bit of q, selecting two spaces if it's 1 or two hashes if it's 0, then concatenates that with the result of running f in the rest of q. This is run on x.charCodeAt(), turning the char-code into the correct string of spaces and hashes.

(There was a lot more drama here before, but the 4-byte-saving technique erased all of that.)

add padStart mention
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240

JavaScript (ES6), 159 154 140 bytes

Saved lots of bytes thanks to @Hedi and @Arnauld

n=>[..."ఀ刀Ā邀⏠Ϡ࿸ῼῼ㿾㿞῜ᾼ࿸߰ǀ"].map(x=>(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt()).repeat(n)).join`
`

That's 112 chars, but 140 UTF-8 bytes. The string was generated with this snippet:

console.log([
0b0000110000000000,
0b0101001000000000,
0b0000000100000000,
0b1001000010000000,
0b0010001111100000,
0b0000001111100000,
0b0000111111111000,
0b0001111111111100,
0b0001111111111100,
0b0011111111111110,
0b0011111111011110,
0b0001111111011100,
0b0001111110111100,
0b0000111111111000,
0b0000011111110000,
0b0000000111000000
].map(x=>String.fromCharCode(x)).join``)

Using .replace instead of [...string].map is equally long:

n=>"ఀ刀Ā邀⏠Ϡ࿸ῼῼ㿾㿞῜ᾼ࿸߰ǀ".replace(/./g,x=>(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt()).repeat(n)+`
`)

How it works

Since each row of the raw data can be represented as a 16-bit number, we can store the entire file in a 16-char string. The compression algorithm simply takes each 16-bit char-code, turns it into a char, and concatenates the resulting characters.

To decompress it, we need to extract the charcode and turn its binary representation into a string of hashes and spaces. This can be done with a recursive function, like so:

(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(x.charCodeAt())

However, the result is not padded, which causes a problem. A basic way to do this would be to pad the beginning with a bunch of spaces, then take the last 32 chars:

(" ".repeat(32)+(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(x.charCodeAt())).slice(-32)

Obviously, that's a little long. ES7 actually has a built-in for this; let's try using that:

(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(x.charCodeAt()).padStart(32," ")

Better, but not good enough. Another way to do it would be to pad the number itself with zeroes before stringifying it:

(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt()).slice(2)

That's even better, but the .slice(2) still seems like a little bit of a waste. It turns out that there's an easy way around this: since there's always a final unnecessary 1, we can just ignore the result when it gets down to 1. This saves a few more bytes:

(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt())

After that, we can just repeat the string n times and add a newline. This is the shortest decompression method I have found, but feel free to suggest any possibly shorter methods.

JavaScript (ES6), 159 154 140 bytes

Saved lots of bytes thanks to @Hedi and @Arnauld

n=>[..."ఀ刀Ā邀⏠Ϡ࿸ῼῼ㿾㿞῜ᾼ࿸߰ǀ"].map(x=>(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt()).repeat(n)).join`
`

That's 112 chars, but 140 UTF-8 bytes. The string was generated with this snippet:

console.log([
0b0000110000000000,
0b0101001000000000,
0b0000000100000000,
0b1001000010000000,
0b0010001111100000,
0b0000001111100000,
0b0000111111111000,
0b0001111111111100,
0b0001111111111100,
0b0011111111111110,
0b0011111111011110,
0b0001111111011100,
0b0001111110111100,
0b0000111111111000,
0b0000011111110000,
0b0000000111000000
].map(x=>String.fromCharCode(x)).join``)

Using .replace instead of [...string].map is equally long:

n=>"ఀ刀Ā邀⏠Ϡ࿸ῼῼ㿾㿞῜ᾼ࿸߰ǀ".replace(/./g,x=>(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt()).repeat(n)+`
`)

How it works

Since each row of the raw data can be represented as a 16-bit number, we can store the entire file in a 16-char string. The compression algorithm simply takes each 16-bit char-code, turns it into a char, and concatenates the resulting characters.

To decompress it, we need to extract the charcode and turn its binary representation into a string of hashes and spaces. This can be done with a recursive function, like so:

(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(x.charCodeAt())

However, the result is not padded, which causes a problem. A basic way to do this would be to pad the beginning with a bunch of spaces, then take the last 32 chars:

(" ".repeat(32)+(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(x.charCodeAt())).slice(-32)

Obviously, that's a little long. Another way to do it would be to pad the number itself with zeroes before stringifying it:

(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt()).slice(2)

That's better, but the .slice(2) still seems like a little bit of a waste. It turns out that there's an easy way around this: since there's always a final unnecessary 1, we can just ignore the result when it gets down to 1. This saves a few more bytes:

(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt())

After that, we can just repeat the string n times and add a newline. This is the shortest decompression method I have found, but feel free to suggest any possibly shorter methods.

JavaScript (ES6), 159 154 140 bytes

Saved lots of bytes thanks to @Hedi and @Arnauld

n=>[..."ఀ刀Ā邀⏠Ϡ࿸ῼῼ㿾㿞῜ᾼ࿸߰ǀ"].map(x=>(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt()).repeat(n)).join`
`

That's 112 chars, but 140 UTF-8 bytes. The string was generated with this snippet:

console.log([
0b0000110000000000,
0b0101001000000000,
0b0000000100000000,
0b1001000010000000,
0b0010001111100000,
0b0000001111100000,
0b0000111111111000,
0b0001111111111100,
0b0001111111111100,
0b0011111111111110,
0b0011111111011110,
0b0001111111011100,
0b0001111110111100,
0b0000111111111000,
0b0000011111110000,
0b0000000111000000
].map(x=>String.fromCharCode(x)).join``)

Using .replace instead of [...string].map is equally long:

n=>"ఀ刀Ā邀⏠Ϡ࿸ῼῼ㿾㿞῜ᾼ࿸߰ǀ".replace(/./g,x=>(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt()).repeat(n)+`
`)

How it works

Since each row of the raw data can be represented as a 16-bit number, we can store the entire file in a 16-char string. The compression algorithm simply takes each 16-bit char-code, turns it into a char, and concatenates the resulting characters.

To decompress it, we need to extract the charcode and turn its binary representation into a string of hashes and spaces. This can be done with a recursive function, like so:

(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(x.charCodeAt())

However, the result is not padded, which causes a problem. A basic way to do this would be to pad the beginning with a bunch of spaces, then take the last 32 chars:

(" ".repeat(32)+(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(x.charCodeAt())).slice(-32)

Obviously, that's a little long. ES7 actually has a built-in for this; let's try using that:

(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(x.charCodeAt()).padStart(32," ")

Better, but not good enough. Another way to do it would be to pad the number itself with zeroes before stringifying it:

(f=q=>q?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt()).slice(2)

That's even better, but the .slice(2) still seems like a little bit of a waste. It turns out that there's an easy way around this: since there's always a final unnecessary 1, we can just ignore the result when it gets down to 1. This saves a few more bytes:

(f=q=>q>1?f(q>>1)+(q&1?"##":"  "):"")(65536+x.charCodeAt())

After that, we can just repeat the string n times and add a newline. This is the shortest decompression method I have found, but feel free to suggest any possibly shorter methods.

edit snippet
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240
Loading
added explanation
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240
Loading
golfed 14 bytes
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240
Loading
golfed 5 bytes
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240
Loading
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240
Loading