lknix / compression-puzzle

Attempts to crack the "compression puzzle".

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.
  4. Assume that the input is always a sequence of ASCII upper-case characters (no numbers or symbols).

Additional Q/A

  • What if my language is not yet supported? No problem. Just pretend that it does and provide some instructions on how can it be ran in the PR. We'll try to use the wizzardy of Nix and/or Docker to compile and run it along with others.
  • Can I submit multiple solutions? Yes; please do.
  • Should we benchmark the solutions agains each other? Possibly.
  • Why are you doing this? Because its fun!
  • Will there be any recap/summary/article written? Hopefully, yes.
  • How can I contact you? Try @otobrglez on Twitter or via GitHub issues or something.

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 clojure
make elixir
make fs
make go
make haskell
make javascript
make kotlin
make python
make rescript
make ruby
make rust
make rye
make scala
make sqlite
make typescript

Benchmarking

Although benchmarking is not the primary goal of this project; some authors are really kean to measure the performance of their solutions and compare them to others.

These languages have benchmarking suites made and feel free to give the ma try.

# Python
python src/python/benchmarks.py

# F#
./src/fsharp/benchmark.fsx

P.s.: If you feel the urge that you need to benchmark your solution agains others; please feel free to do so and attach some instructions to your PR.

Authors

Author Solutions
Andraž Brodnik Python
David Ličen JavaScript: compress_da01.js, compress_da02.js
Goran Kodrun JavaScript, TypeScript
Janko Metelko Rye: compress_jm_rec.rye, compress_jm_rec_steps.rye, SQLite
Jernej Virag Kotlin
Klemen Kogovšek JavaScript, ReScript
Krištof Črnivec Ruby: compress-kbc-0.rb, compress-kbc-1.rb
Luka Kacil Bash, Python: compress_luka.py, compress_luka_faster.py, compress_luka_rec1.py, compress_luka_rec2.py, compress_luka_tailrec.py
Marek Fajkus Haskell
Miha Novak Kotlin
Mitja Živković Go
Oto Brglez JavaScript, Python, Scala: CompressionPuzzle01.scala, CompressionPuzzle02.scala
Peter Keše F#: compress-pk1.fsx, compress-pk2.fsx, compress-pk3.fsx
Simon Belak Clojure
Simon Žlender Elixir: compress.exs, compress_rec.exs
Tit Petrič Go
Urban Škudnik Python

The Stats 📈

  • The number of authors: 17
  • The number of solutions: 34
  • The number of programming languages: 15
  • The language / solutions breakdown: Python: 8, JavaScript: 5, F#: 3, Elixir: 2, Rye: 2, Kotlin: 2, Ruby: 2, Go: 2, Scala: 2, Haskell: 1, Clojure: 1, TypeScript: 1, ReScript: 1, SQLite: 1, Bash: 1

About

Attempts to crack the "compression puzzle".


Languages

Language:Python 20.6%Language:F# 12.8%Language:Makefile 10.0%Language:Ruby 9.7%Language:Red 9.1%Language:JavaScript 8.3%Language:Kotlin 4.3%Language:Go 4.1%Language:Elixir 3.7%Language:TypeScript 3.4%Language:Scala 3.0%Language:ReScript 2.3%Language:Haskell 2.0%Language:Nix 1.8%Language:Rust 1.8%Language:Clojure 1.7%Language:Shell 1.4%