so I\'ve written the whole algorithm actually, but for some reason it doesn\'t work propperly. Please note that I\'m a beginner and code is just a sample in phase of testing