Here's the same algorithm ported to Go code from Python and made into a complete program (read file, main method etc) with a simple prompt. (As a bonus, I converted it to Turkish, first the comments, then the variable names.)