Algorithmics
This repository contains solutions to common (and some unusual) algorithmics problems.
ships.cpp
๐ All of us have propably ever played a game of ships. This program finds sizes of all ships on a board.
How to use
- Create a file named
ships.txt
- Fill the file with a square of size 8x8 filled with
0
(water) and1
(ship).
๐ก Tip: If you are not sure how the file should look like, feel free to take a look at the example in
./samples/
directory.
- Compile the program
g++ ships.cpp -o ships.out
- Run the program and watch the console window
./ships.out
lzw.cpp
๐ช Compresses a file using Lempel-Ziv-Welch technique
How to use
- Create a file named
input.txt
- Fill the file with some text (eg. lorem ipsum)
- Compile the program
g++ lzw.cpp -o lzw.out
- Run the program
./lzw.out
- Open the newly created
compressed.txt
spiral.cpp
๐ Fills spirally a square array with consecutive numbers in the choosen direction.
How to use
- Compile the program
g++ spiral.cpp -o spiral.out
- Run the program
./spiral.out
- Input a direction
0
for counter-clockwise1
for clockwise
- Type in a size
- Watch the console window