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,...
- No external libraries or tools shall be used. Only standard, bundled libraries apply.
- "Assert" inside your solution if the function does what it is suppose to do.
- You can apply as many solutions as you want to any language you want.
- Assume that the input is always a sequence of ASCII upper-case characters (no numbers or symbols).
- 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? Yes. So far ve've published a blogposts The Compression Puzzle Challenge (on epic.blog), The Compression Puzzle Challenge (on LinkedIn) and Janko Metelko / Higher order functions test (blog post). There ware also talks about it - DragonPy Meetup in April 2022 (YouTube link) and "The Compression Puzzle Challenge at Make IT 2022, Portorož".
- How can I contact you? Try @otobrglez on Twitter or via GitHub issues or something.
# 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 c++
make crystal
make clojure
make cs
make elixir
# ...
make php
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 them a try.
# Python
python src/python/benchmarks.py
# F#
./src/fsharp/benchmark.fsx
# Crystal
./src/crystal/benchmark
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.
- The number of authors: 50
- The number of solutions: 85
- The number of programming languages: 30
- The language / solutions breakdown: Python: 15, JavaScript: 10, C#: 7, Scala: 5, Rye: 5, Ruby: 4, Lua: 3, Red: 3, Go: 3, TypeScript: 3, F#: 3, C++: 2, Kotlin: 2, Elixir: 2, Java: 2, Crystal: 2, Clojure: 1, R: 1, Rust: 1, C: 1, MS SQL: 1, Pascal: 1, Haskell: 1, Bash: 1, ReScript: 1, Assembler (x86): 1, SQLite: 1, Groovy: 1, PHP: 1, Swift: 1