matthias152 / algorithms

0 stars 0 forks source link

Algorithms

Project that implements algorithms for a few problems.

Todo

  1. Knapsack problem:
    • Brute Force
    • Dynamic Algorithm
  2. Travelling Salesman Problem:
    • Brute Force
    • Dynamic Algorithm
  3. Miscellaneous:
    • Implement program that runs every implemented algorithm
    • Create random test data
    • Create option to read/write data to file

Working with branches

Its safer to work on implementation in other branches than master.

The procedure is to go back to your master branch to be sure that you have up-to-date code.

For example:

You have one file named test.py in your master branch.

You want to add second file, so you create own branch.

You created second file in your own branch.

Damian wanted to add 2 files, so he created his other branch.

He added 2 files to other branch and then merged changes to master. So now master have 3 files, but you in your own branch do not have file added to master by Damian, so you have only 2 files, the one that was in master when you created your own branch, and file that you created.

Now, if you would create new branch, without changing branch back to master and pulling changes it would still do not have files created by Damian, only yours.

To put it visually:

This is first scenerio, you create new branch own2 from branch own instead of master:

master (1 file) -> git checkout -b own -> own (2 files) -> git checkout -b own2 -> own2 (2 files)

This is what Damian did:

master (1 file) -> git checkout -b other -> other (3 files) -> git push/merge -> master (3 files)

This is the proper way to create your own2 branch. If you merged your changes from own branch to master, then it have 4 files. If you did not, there are 3 files:

master (1 file) -> git checout -b own -> own (2 files) -> git push/merge (optional) -> git checkout master -> master (1/2 files) -> git pull -> master (3/4 files) -> git checkout -b own 2 -> own2 (3/4 files)

Step 1:

Check in which branch you are.

If you are in master branch, go to Step 3
If you are in other branch, go to Step 2

Step 2:

You are in other branch. You will need to switch to master branch before creating new branch. To swich branch to master, you can use:

git checkout master

Then you should pull all chenges on master with:

git pull

Step 3

Now that you are in master branch, you can safely create new branch with:

git checkout -b <branch name>

Git Cheat-Sheet

To clone repository:

git clone https://github.com/matthias152/algorithms.git

To change/create new branch:

git checkout -b <branch name>   # without '-b' it will change branch

To add new file to current commit:

git add <file>

To confirm commit:

git commit -m "<description>"

To publish changes on Github:

git push origin <branch>