Attempts to crack the compression puzzle.

Overview

The Compression Puzzle

GitHub Actions Status

One lovely Friday we were faced with this nice yet intriguing programming puzzle.

One shall write a program that compresses string "AAABBAAC" to its compressed form "3A2B2A1C".

These attempts were made,...

Basic rules

  1. No external libraries or tools shall be used. Only standard, bundled libraries apply.
  2. "Assert" inside your solution if the function does what it is suppose to do.
  3. You can apply as many solutions as you want to any language you want.

Development

# Via Nix Shell
$ nix-shell shell.nix --run "make run"
# if you preffer to roll your own local brew
$ make

To run individual languages use:

make bash
make fs
make go
make javascript
make python
make ruby
make scala

Authors

Comments
  • Added Red solution

    Added Red solution

    This is a solution written in Red language. It’s a one-liner but split into commented multiple lines for easier understanding. As a bonus, I added decompression also.

    language support needed red 
    opened by rebolek 9
  • Working Red Nix/Docker setup + solutions

    Working Red Nix/Docker setup + solutions

    Red scripts work via rebolek/red docker hub image. Makefile is fixed so all red scripts get executer with Nix command:

    nix-shell shell.nix --run "make red-docker" 
    

    I collected and tested all Red solutions, from other PR-s and Red gitter chat. I hope it's OK, but I wanted to see all Red solutions work.

    opened by InvoiceFox 4
  • Python scripts don't seem to get invoked

    Python scripts don't seem to get invoked

    It seems python3 doesn't run scripts with

    python3 src/python/*.py 
    

    like it's written in the make file. Maybe there is a more elegant solution but this works

    find src/python/ -name "*.py" -print0 | xargs -0 -n 2 python3
    
    bug 
    opened by refaktor 2
  • python, short, reduce examples

    python, short, reduce examples

    I've tried my luck golfing also in python :)

    in 108 bytes: s=lambda s:reduce(lambda a,b:([a[0]+str(a[1])+b[0],1],[a[0],a[1]+1])[b[0]==b[1]],zip(s,s[1:]+'0'),['',1])[0]

    opened by eranws 1
  • Asm 80x86

    Asm 80x86

    Example built for Windows using FASM. https://flatassembler.net/ Uses: FASM macro to invoke C functions C runtime library for "printf" function. Windows kernel library for "ExitProcess"

    opened by kev-m 1
  • Add romunov's solution to Python benchmark

    Add romunov's solution to Python benchmark

    Added my el cheapo Python solution to benchmarks.

    ➜ python src/python/benchmarks.py 
    Brodul 0.0321615369994106
    Luka faster 0.027532846999747562
    Luka 0.02394970400018792
    Oto 0.03818903700084775
    Urban, iterative 0.04462564499954169
    Urban, recursion 0.04826400199999625
    romunov, babysteps 0.013087426999845775
    
    opened by romunov 1
  • Add crystal solution using a lexer pattern

    Add crystal solution using a lexer pattern

    In the majority of real life scenarios I'd likely just use a more simple solution, such as the solution @robcole presented earlier, but this is over 4x faster and uses a Lexer pattern to seek through the string, so it is interesting and could be a better pattern to use in real life, but practical scenarios (seeking through strings at a framework level, for instance)

    Definitely an interesting solution, and while the solution doesn't look the most elegant, this pattern would look a lot more coarse in other languages and that makes the outcome interesting to me!

    opened by grepsedawk 1
  • Add R solution by romunov

    Add R solution by romunov

    My attempt at solving the puzzle using three basic R functions (#24) strsplit, rle and paste (paste0 is just a synonym with a default value for a separator set to "").

    In addition to the solution I've also added myself to the authors, bumped stats and tried to add R to the run chain. I'm pretty sure I somehow botched the last part.

    opened by romunov 1
  • Single character compressions

    Single character compressions

    In the example, There is only 1 C that gets compressed into 1C. If we take the knowledge that all "multi character" will have a number, and all singles do not have this prefix number, we can improve the compression ratio of this problem

    enhancement 
    opened by grepsedawk 3
  • Common test suite

    Common test suite

    It would make sense to run a common test suite against all the solutions through stdin or something like that. Either that or make the solutions also test the empty case (compress("") == ""). I've ran into solutions where the empty case resulted in compress("") == "0" while prototyping, and I wouldn't be surprised if some existing or future submissions had the same issue.

    opened by szlend 1
  • The

    The "Wanted" Languages

    In what other languages would you like to see solutions, and do you know anyone who could provide them?

    I would be interested to see Kotlin solution. There are probably some Android devs that use it. And Rust, and Julia ...

    opened by refaktor 1
Owner
Oto Brglez
Oto Brglez
Let's renew the puzzle collection. We'll produce a collection of new puzzles out of the lichess game database.

Let's renew the puzzle collection. We'll produce a collection of new puzzles out of the lichess game database.

Thibault Duplessis 96 Jan 3, 2023
Python implementation of Gorilla time series compression

Gorilla Time Series Compression This is an implementation (with some adaptations) of the compression algorithm described in section 4.1 (Time series c

Ghiles Meddour 19 Jan 1, 2023
Selamat Datang DiTools Crack-Old, Crack Old Adalah Sebuah Crack Tanpa Login Dan Crack Menggunakan Akun Facebook Tua/Old.

Selamat Datang DiTools Crack-Old, Crack Old Adalah Sebuah Crack Tanpa Login Dan Crack Menggunakan Akun Facebook Tua/Old. ([Welcome to Crack-Old Tools, Old Crack Is A Crack Without Login And Crack Using An Old Facebook Account ])

Risky [ Zero Tow ] 7 Dec 25, 2022
We will see a basic program that is basically a hint to brute force attack to crack passwords. In other words, we will make a program to Crack Any Password Using Python. Show some ❤️ by starring this repository!

Crack Any Password Using Python We will see a basic program that is basically a hint to brute force attack to crack passwords. In other words, we will

Ananya Chatterjee 11 Dec 3, 2022
Archive-Crack - A Tools for crack file archive

Install In TERMUX > apt update && apt upgrade -y > pkg install python git unrar

X - MrG3P5 10 Oct 6, 2022
Easy compression and extraction for any compression or archival format.

Tzar: Tar, Zip, Anything Really Easy compression and extraction for any compression or archival format. Usage/Examples tzar compress large-dir compres

DanielVZ 37 Nov 2, 2022
Revisiting Discriminator in GAN Compression: A Generator-discriminator Cooperative Compression Scheme (NeurIPS2021)

Revisiting Discriminator in GAN Compression: A Generator-discriminator Cooperative Compression Scheme (NeurIPS2021) Overview Prerequisites Linux Pytho

Shaojie Li 34 Mar 31, 2022
An Image compression simulator that uses Source Extractor and Monte Carlo methods to examine the post compressive effects different compression algorithms have.

ImageCompressionSimulation An Image compression simulator that uses Source Extractor and Monte Carlo methods to examine the post compressive effects o

James Park 1 Dec 11, 2021
Script that attempts to force M1 macs into RGB mode when used with monitors that are defaulting to YPbPr.

fix_m1_rgb Script that attempts to force M1 macs into RGB mode when used with monitors that are defaulting to YPbPr. No warranty provided for using th

Kevin Gao 116 Jan 1, 2023
Detector for Log4Shell exploitation attempts

log4shell-detector Detector for Log4Shell exploitation attempts Idea The problem with the log4j CVE-2021-44228 exploitation is that the string can be

Florian Roth 729 Dec 25, 2022
A model that attempts to learn and benefit from data collected on card counting.

A model that attempts to learn and benefit from data collected on card counting. A decision tree like model is built to win more often than loose and increase the bet of the player appropriately to come out winning as much money as possible.

null 1 Dec 17, 2021
S3-cleaner - A Python script attempts to delete the all objects/delete markers/versions from specific S3 bucket

Remove All Objects From S3 Bucket This Python script attempts to delete the all

null 9 Jan 27, 2022
Keep track of failed login attempts in Django-powered sites.

django-axes Axes is a Django plugin for keeping track of suspicious login attempts for your Django based website and implementing simple brute-force a

Jazzband 1.1k Dec 30, 2022
Handles SDVX EXCEED GEAR result screen photos and attempts to read it.

Handles SDVX EXCEED GEAR result screen photos and attempts to read it.

silverhawke 1 Jan 8, 2022
Algorithm to solve Wordle correctly 100% of the time within 6 attempts.

WordleSolver © Zulkarnine, 2022. Algorithm to solve Wordle 100% of the time within 6 attempts. You can go ahead and run main.py to run it for all 2315

Zulkarnine Mahmud 69 Dec 11, 2022
This library attempts to abstract the handling of Sigma rules in Python

This library attempts to abstract the handling of Sigma rules in Python. The rules are parsed using a schema defined with pydantic, and can be easily loaded from YAML files into a structured Python object.

Caleb Stewart 44 Oct 29, 2022
Wordle is a web-based word game. Players have six attempts to guess a five-letter word;

Wordle is a web-based word game. Players have six attempts to guess a five-letter word; feedback is given for each guess, in the form of colored tiles, indicating when letters match or occupy the correct position. This program helps solving wordle problems.

Abhishek 2 May 21, 2022
Attempts to solve Wordle-like puzzles.

Attempts to solve Wordle-like puzzles.

cotman 1 Feb 14, 2022
Puzzle-CAM: Improved localization via matching partial and full features.

Puzzle-CAM The official implementation of "Puzzle-CAM: Improved localization via matching partial and full features".

Sanghyun Jo 150 Nov 14, 2022
Wordplay, an artificial Intelligence based crossword puzzle solver.

Wordplay, AI based crossword puzzle solver A crossword is a word puzzle that usually takes the form of a square or a rectangular grid of white- and bl

Vaibhaw 4 Nov 16, 2022