Questions tagged [compression]

Related to compressing or decompressing arbitrary data. Challenges which relate to compressing a single specific input should instead be tagged [kolmogorov-complexity]

Filter by
Sorted by
Tagged with
319 votes
24 answers
44k views

Write Moby Dick, approximately

Here is a 1.2Mb ASCII text file containing the text of Herman Melville's Moby-Dick; or, The Whale. Your task is to write a program or function (or class, etc. -- see below) which will be given this ...
user avatar
  • 7,182
254 votes
37 answers
48k views

Paint Starry Night, objectively, in 1kB of code

Note: a 1000 point bounty is still available for this challenge, which I will create and award if anyone takes the top score without using built-in compression. Below is a ...
user avatar
  • 7,182
59 votes
10 answers
8k views

Encode Images into Tweets (Extreme Image Compression Edition) [closed]

Based on the very successful Twitter image encoding challenge at Stack Overflow. If an image is worth 1000 words, how much of an image can you fit in 114.97 bytes? I challenge you to come up with a ...
user avatar
  • 28.5k
49 votes
7 answers
7k views

Reverse Zip Bomb

A zip bomb is a compressed file, designed so that unpacking it yields the biggest file possible. These are fairly well known, and there are examples of 42 KB files which expand into multiple petabytes ...
user avatar
43 votes
17 answers
9k views

Smallest chess board compression

Write an algorithm or program that can encode and decode a chess board. The goal is to make the smallest representation of a chessboard that could be used (once decoded) to determine all movement ...
user avatar
  • 531
42 votes
9 answers
6k views

Text compression and decompression — "Nevermore."

With the recent discussion about the use of compression tools in code golf, I thought it would be a nice challenge to write your own text compressor and decompressor. Challenge: Write two programs: ...
user avatar
39 votes
2 answers
2k views

Musical Tweet Challenge

This is the audio version of the Twitter image encoding challenge. Design an audio compression format that can represent at least one minute of music in 140 bytes or less of printable UTF-8-encoded ...
user avatar
  • 6,511
37 votes
12 answers
2k views

lc's dvntrs n Wndrlnd

The task Today's special offer: consonants and punctuation for FREE! Your program or function will be given as input the first 6 paragraphs of Lewis Carroll's famous novel Alice's Adventures in ...
user avatar
  • 168k
36 votes
18 answers
3k views

Bracket Expansion!

Your challenge is to expand some brackets in a program's input as shown: Find a string s between two matching brackets [ and ], ...
user avatar
  • 13.3k
35 votes
14 answers
6k views

Sudoku Compression

Your job is to write a program (or two separate programs) in any language that: Can take a completed Sudoku board as input (in any logical format) and compress it into a string of characters Can take ...
user avatar
  • 2,181
35 votes
10 answers
3k views

Help me recognise my monster

Background The computer game NetHack dates from 1987, before the use of graphics in computer games was widely established. There are lots of monsters in the game, and potentially a lot need to fit on ...
user avatar
34 votes
29 answers
3k views

Is it a prefix code?

In information theory, a "prefix code" is a dictionary where none of the keys are a prefix of another. In other words, this means that none of the strings starts with any of the other. For example, <...
user avatar
  • 57.2k
32 votes
20 answers
3k views

Golf a golf chart

Given a distance in meters as an integer \$60\le d \le 260\$, return the number of clubs that may be used according to the following arbitrary chart, where both \$min\$ and \$max\$ are inclusive: <...
user avatar
  • 168k
32 votes
8 answers
3k views

Latin square compression

A Latin square is a square that has no repeated symbols in the rows or columns:. 13420 21304 32041 04213 40132 And as many Sudoku players know, you don't need ...
user avatar
31 votes
2 answers
3k views

Compress an image to a 4 KiB preview

In this challenge you will be creating an image preview compression algorithm. It's goal is to reduce an arbitrary image file to a 4 KiB preview image, that can be used to quickly identify images with ...
user avatar
  • 38.7k
30 votes
11 answers
2k views

Which wire to cut

This task is about compressing and processing a sequence of conditionals. In the game Keep Talking and Nobody Explodes, a bomb defuser must disarm a bomb with the help of instructions relayed by ...
user avatar
  • 137k
29 votes
24 answers
3k views

Converting "0xUsernames"

0xUsernames There's so many people using a messaging service that they're running out of space to store all the usernames! To fix this, they are going to start storing usernames as hexadecimal, where ...
user avatar
  • 13.9k
28 votes
16 answers
7k views

.-...--..---.-...--..... the red-nosed reindeer

Can you recover a sequence of letters from a sequence of dots and dashes? In Morse code, x is represented by -..-, but without ...
user avatar
27 votes
8 answers
2k views

Somewhere On The Tube ...But On Which Lines?

The London Underground A.K.A. The Tube is the oldest underground railway in the world, it currently consists of eleven lines* servicing 267 named stations (strictly 269** stations since "Edgware ...
user avatar
25 votes
14 answers
2k views

Print a Ternary Value

Put simply, you are to print out the following number: ...
user avatar
  • 3,067
25 votes
7 answers
3k views

Big big numbers

Whilst trying to golf several of my answers, I've needed to write large integers in as few characters as possible. Now I know the best way to do that: I'll be getting you to be writing this program. ...
user avatar
  • 28.1k
25 votes
1 answer
818 views

Maximal discrepancy-2 sequence with minimal entropy

Background As noted in the PPCG challenge Compress a maximal discrepancy-2 sequence – which inspired this challenge – the authors of the paper Computer-Aided Proof of Erdős Discrepancy Properties ...
user avatar
  • 207k
22 votes
10 answers
2k views

Compressing the Atomic Ionization Energies

This is a different type of compression challenge. In a normal kolmogorov-complexity challenge, you are required to recreate a list exactly. Here, you are allowed to round the values in any way you ...
user avatar
  • 28.5k
22 votes
3 answers
840 views

Golfing Strings

I have always failed to give an answer for kolmogorov-complexity challenges which require string compression, the main reason being that I don't know to use string compression tools as effectively as ...
user avatar
  • 22.8k
22 votes
2 answers
2k views

Lossy ASCII art compression

Background PICASCII is a neat tool that converts images into ASCII art. It achieves different degrees of brightness by using the following ten ASCII characters: ...
user avatar
  • 207k
21 votes
16 answers
4k views

Who needs 8 bits for one character?

Given a string and the characters used to encode it, you need to compress the string by only using as many bits as each character needs. You will return the character codes for each character needed ...
user avatar
  • 6,550
21 votes
10 answers
871 views

Move to the printable ASCII front

Background The move-to-front transform (MTF) is a data encoding algorithm designed to improve the performance of entropy encoding techniques. In the bzip2 compression algorithm, it is applied after ...
user avatar
  • 207k
20 votes
12 answers
4k views

All your base 97 are belong to us

Many programming languages are written using solely printable ASCII, tabs and newlines. These 97 characters are then stored in 8-bit bytes (which are actually capable of holding 256 different ...
user avatar
  • 9,336
20 votes
3 answers
470 views

Decompress an integer, Jelly style

Jelly has compressed string literals, using the “...» delimiters. The way these work is by interpreting the ... as a base-250 ...
user avatar
20 votes
1 answer
503 views

Diff compression [closed]

For this challenge, you need to compress a diff. A diff is some data that represents the difference between two strings. For this challenge, you need to provide one or more programs that can: Input ...
user avatar
19 votes
19 answers
3k views

Run-Length Encoding [duplicate]

Write a program uses run-length encoding to shorten a list of non-negative integers it has to read in. You can assume the non-negative integers can fit in 32bit signed integers. Input Format The ...
user avatar
  • 2,904
19 votes
14 answers
2k views

Let's decompress a bit

Given a compressed string \$s\$ made of printable ASCII characters (32 to 126), your task is to print or return the original text by applying this simple decompression algorithm: Start with \$k=0\$ ...
user avatar
  • 168k
18 votes
34 answers
1k views

Compactify the input

Given a word, your task is to compact it by saving its first character and removing any other vowel (aeiou). Input Your input can be the word in STDIN, a function argument or any other input format ...
user avatar
18 votes
5 answers
860 views

Boggle Board Compression

When working on Non-Palindromic Polyglot Boggle, I found it quite tedious to pack the codes as efficiently as possible onto the Boggle board, even with only two strings. But we're programmers, right? ...
user avatar
18 votes
2 answers
873 views

Thwart Lepton compression

Dropbox recently released Lepton (GitHub), a method that losslessly compresses JPEG images round-trip, saving an average of 22%. Because of the pigeonhole principle, any general compression algorithm ...
user avatar
  • 3,267
17 votes
3 answers
695 views

Burrows, Wheeler and Back

Background The Burrows–Wheeler transform (BWT) is a reversible permutation of the characters of a string that results in large runs of similar characters for certain types of strings such as plain ...
user avatar
  • 207k
17 votes
2 answers
1k views

Monopoly Compression

Given a string representing the current state of a game of Monopoly at the beginning of a player's turn, compress all the necessary data into the smallest output. Answers will be judged by output size ...
user avatar
  • 19.6k
15 votes
7 answers
918 views

Send a cosmic call

The cosmic call is a message sent into space in 1999 and 2003. It's made of 23 127*127px monochrome bitmap images, as detailed here. Your mission is to write a program that displays the entire 127*...
user avatar
  • 5,759
15 votes
4 answers
901 views

Palindrome Compression

Challenge Write a program that compresses and decompresses ASCII text losslessly. It should be specialized to work well with palindromes, including case-insensitive and punctuation-insensitive ...
user avatar
  • 9,791
15 votes
4 answers
651 views

Implement bzip2's run-length encoding

Background After applying the BWT (as seen in Burrows, Wheeler and Back) and the MTF (as seen in Move to the printable ASCII front), the bzip2 compressor applies a rather unique form of run-length ...
user avatar
  • 207k
14 votes
2 answers
485 views

What's my TIO uniqueness?

Try it online! currently has 680 listed languages, all of which are searchable. For most of those languages, when searching for it, you don't have to enter the entire string. For example, entering <...
user avatar
14 votes
2 answers
970 views

Create the least compressible picture

"A picture is worth a thousand words"—so the old saying goes. The average word is about four characters long, so a picture conveys 4kB of information. But how much entropy, rather than information, ...
user avatar
  • 1,457
13 votes
13 answers
1k views

Output code-sized Lorem Ipsum

Output the same length of Lorem ipsum your code is! Rules: Code can't be identical to output No compression libraries Shortest program in two weeks wins No network usage, file reading and other ...
user avatar
  • 20.5k
13 votes
8 answers
565 views

Compress and decompress

Your task is to make a bidirectional compressor. It takes a list of bytes as input and returns a list of bytes as output. It has the property than whenever it is iterated twice it returns the original ...
user avatar
  • 6,705
13 votes
12 answers
2k views

I want 8 bits for every character!

This is the reverse of this challenge. Given an encoded list of codepoints and the characters used to encode it, you need to decompress it to its original string. For example, given the encoded list <...
user avatar
  • 6,550
12 votes
9 answers
2k views

Naïve compression

using Prefixed Length Code We are going to implement a compression of text (string, array/list of characters/bytes) by simple substitution of each character by a binary code, based on the frequency of ...
user avatar
  • 20.5k
12 votes
4 answers
5k views

Lorem Ipsum Compressor

Write a program which can compress/decompress randomly generated Lorem Ipsum text. Devise your own lossless algorithm. You may compress your data further using an existing algorithm afterwards, but ...
user avatar
  • 1,945
12 votes
4 answers
618 views

Strategies for representing a given large integer using arithmetic expression

I have a specific number in mind, but it's part of a challenge I'm doing, and I don't want people to do (all) the work for me. Here is a number which has the same digits, but shuffled: ...
user avatar
12 votes
5 answers
677 views

Implement a URL shortener

URLs are getting too long. So, you must implement an algorithm to shorten a URL. i. The Structure of a URL A URL has 2 main parts: a domain and a path. A domain is the part of the URL before the ...
user avatar
12 votes
1 answer
787 views

Lossless English language text compression challenge [closed]

Challenge: Your challenge (should you choose to accept it) is to compress and decompress the 5MB "Complete Works of William Shakespeare" as found here: http://www.gutenberg.org/cache/epub/100/pg100....
user avatar
  • 263