Skip to content

jflaga/competitive-programming

Repository files navigation

My solutions to some competitive programming problems

NOTE: There are also READMEs in some individual folders in this repository, for example in the folder /UVa/ and /HackerRank/10DaysOfStatistics/.

UVa Online Judge - my statistics

LeetCode profile

HackerRank profile

Some NOTE for running some of the C++ programs here:

If you encounter the error 'stdin' was not declared in this scope when you run the C++ programs here, you need to add #include <cstdio> to the C++ program.

Command for running python with redirected input/output:

$ python 00100-2024-02-08_3n+1Problem-CSE-373-Fall-2020.py < input.txt > output.txt

Running Python with unit tests

python <name of file containing tests>.py

python <name of file>.py

Running C++ file with unit tests, on Windows using g++ and doctest located in /_libraries/doctest.h

Open Command Prompt (not Terminal)

See if the environment variable CPLUS_INCLUDE_PATH is already set to the \__libraries\ directory:

set CPLUS_INCLUDE_PATH

If it is not, then set it to the [**==change-me-to-root-dir==**]\_libraries\

set CPLUS_INCLUDE_PATH=[**==change-me-to-root-dir==**]\__libraries\
g++ 2024-02-29-hello-world-with-unit-tests.cpp & a

Or, if you want to specify the name of the .exe file

set CPLUS_INCLUDE_PATH=[**==change-me-to-root-dir==**]\__libraries\
g++ 2024-02-29-hello-world-with-unit-tests.cpp -o hello-world
hello-world

To tell the compiler to use specific version of C++, like C++11 only (with features of C++14 excluded):

g++ -std=c++11 2024-02-29-hello-world-with-unit-tests.cpp & a

Other g++ flags for specifying compiler version to use:

g++ -std=c++98 ...
g++ -std=c++14 ...
g++ -std=c++17 ...
g++ -std=c++2a ...

It will output something like this:

[doctest] doctest version is "2.4.11"
[doctest] run with "--help" for options
===============================================================================
[doctest] test cases: 1 | 1 passed | 0 failed | 0 skipped
[doctest] assertions: 5 | 5 passed | 0 failed |
[doctest] Status: SUCCESS!

If a test fails, it outputs something like this:

[doctest] doctest version is "2.4.11"
[doctest] run with "--help" for options
===============================================================================
2024-02-29-hello-world-with-unit-tests.cpp:6:
TEST CASE:  testing the factorial function

2024-02-29-hello-world-with-unit-tests.cpp:7: ERROR: CHECK( factorial(0) == 0 ) is NOT correct!
  values: CHECK( 1 == 0 )

===============================================================================
[doctest] test cases: 1 | 0 passed | 1 failed | 0 skipped
[doctest] assertions: 5 | 4 passed | 1 failed |
[doctest] Status: FAILURE!

References:

About

My solutions to some competitive programming problems

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages