My own solution for problems at TopCoder