/algorithms-gym

playground for algorithms in several favorite languages

Primary LanguageC++

algorithms-gym

Repo containing various algorithmic problems solutions and data structures implementations

Project structure

Directories in the src split by topic/course/etc.:

└── src
    ├── algorithms
    ├── common
    └── cses
    └── ...

Each directory may contain multiple folders with implementations in different languages.
The common folder should contain some generic functionality that could be reused across the code, like reading from stdin or file.

How to run

C++

For mac-os users:
Since mac-os uses clang (which is good for the "real" development, btw) by default and here I sometimes use bits/stdc++.h header, you'll need to install gcc for using that header:

brew install gcc

The command to compile looks like this (the same as for most competitive programming platforms):

g++ -lm -O2 -fno-stack-limit -std=c++1z -x c++ <code> -o <executable>

clang and "newer" C++:

clang++ --std=c++20 -O3 -fsanitize=address,undefined -Wall -Wextra -Werror <code> -o <executable>

Running with test examples:

./my_object_file < test.txt

Python

I've used python3.8. You can install and activate any version via pyenv.
To run the code, you can just call:

python3 <file>

Or compile the bytecode first like that:

py_compile.compile(<file>, doraise=True)

Go

Run tests:

go test -v -race <file>

Links