Abstract
In this blog post we’ll learn how to read a file as input and write the output to a file using redirection. Continue reading
Abstract
In this blog post we’ll learn how to read a file as input and write the output to a file using redirection. Continue reading
Below are implementations of the Ford-Fulkerson algorithm to compute the maximum flow in a graph with integer capacities. Breadth first search is used to find paths from the source to the target which makes this the Edmonds-Karp algorithm. To learn about this topic I recommend reading the references. Continue reading
Problem:
Suppose you are given the following input:
5 22 9 813 13 77 98 93 51 5 3 1 5 7 1 3 9 1
Your task is to print out the sum of the numbers in each line, e.g. the sum for the first line is
5 + 22 + 9 + 813 + 13 = 862
So the output should be:
862 319 25 10
The problem here is that you don’t know how many lines you are given and how many numbers there are in each line. How can you solve this problem in Python and C++?
Suppose you are given an integer. How can you check whether the number is palindromic, i.e. you get the same number if you read its digits backwards? Continue reading
Below is a Python 3.4 program that is supposed to return the number of digits of an integer. However, it does not work correctly. Continue reading
In this blog post we will examine how we can compute the next lexicographic permutation of a list. We will implement the algorithm in Python 3.4. Continue reading
In this blog post we will have a look at fast I/O methods for competitive programming in C++, Java and Python. Continue reading
In this blog post I will describe how to read the input without knowing how many lines the input has. Continue reading
In this blog post I will describe how we can create permutations in Python 3.4. Continue reading
In this blog post I will describe how to count the letter frequency in a string. We will look at two implementations, one that uses an array and the ASCII code and another that uses a dictionary. Continue reading