About Bjarki Ágúst

Find Bjarki Ágúst on:

UVa Online Judge New Platform

UVa Online Judge New Platform

17 April 2013

1 Comment

We at MathBlog have written about a couple of problems from the UVa Online Judge. The current UVa OJ platform is almost 7 years old, and so the UVa OJ team thinks it's time for an upgrade. They intend to build the platform up from scratch, but to do that, they need funding. Therefore, they've set up a campaign, located here, where you can donate and help fund the project.There are 6 days left of the campaign, so we encourage you to let others know, and perhaps even donate yourself.

Continue reading...
UVa 102: Ecological Bin Packing

UVa 102: Ecological Bin Packing

2 January 2013

1 Comment

Problem 102 at the UVa online judge deals with a special kind of bin packing problem, where we are asked to recycle glass in the most efficient way possible.We solve the problem by simple brute force. It may though be harder to implement than might seem at first sight. In any case, this is yet another easy problem from the UVa online judge.

Continue reading...
Monday links

Monday links

13 August 2012

5 Comments

Another Monday is upon us, and another batch of links is due. This week I'm going to focus on Dynamic Programming (or DP for short). The reason is that upcoming Project Euler problems are DP- and memoization heavy. Another reason is that DP problems are quite popular, so it's definitely a good skill to have.Take a look inside for more.

Continue reading...
Monday links

Monday links

30 July 2012

5 Comments

This Monday I have a couple of links lined up, both math related and non-math related. An interesting mathematics Wikibook, an exciting website with a collection of fun programming exercises, introduction to Git and introduction to primality testing, all in today's Monday links. Take a look inside the post for further details.

Continue reading...
Disjoint-set data structure

Disjoint-set data structure

25 July 2012

9 Comments

I'm going to introduce you to a simple, but very effective, data structure called the Disjoint-set data structure (or the Union-Find data structure, but Union and Find are its main operations). We are going to use it in the upcoming Project Euler 107, and it might come in handy in future Project Euler or UVa Online Judge problems.

Continue reading...
UVa 10055: Hashmat the brave warrior

UVa 10055: Hashmat the brave warrior

5 July 2012

15 Comments

In problem 10055 at the UVa online judge, we are asked to help Hashmat, the brave warrior, to decide whether he should fight against his opponents. We do that be calculating the difference between the number of Hashmat's soldiers and the number of his opponent's soldiers.The problem is an easy one, but has still eluded many. After little work we end up with an almost one-line solution.

Continue reading...
UVa 10783: Odd Sum

UVa 10783: Odd Sum

13 June 2012

2 Comments

Problem 10783 at the UVa Online Judge, also known as Odd Sum, asks us to compute the sum of odd numbers in a given range. The problem is easy, but fun, and can be solved in a similar way to the first Project Euler problem. We start off by creating a straight-forward solution which unfortunately works due to small test cases. We do one minor optimization and then finally finish with a neat closed-form solution.

Continue reading...
UVa 530: Binomial Showdown

UVa 530: Binomial Showdown

6 June 2012

3 Comments

Problem 530 at the UVa Online Judge, also known as Binomial Showdown, asks us to compute the number of ways one can choose k elements out of n elements, not taking order into account. The problem is a classical one (n choose k, anyone?), but with a twist. The input numbers are big, and we need to be really careful not to overflow integers in our intermediate computations. We discover a formula that has smaller intermediate values than the direct formula, and with one more small observation, we're done.

Continue reading...
UVa 10268: 498-bis

UVa 10268: 498-bis

24 May 2012

0 Comments

Problem 10268 at the UVa Online Judge, 498', asks us to evaluate the derivative of a polynomial. It is, like the name suggests, a version of problem 498, which we've already covered here. We solved problem 498 with code reuse in mind. We created a Polynomial class which we can extend to solve this problem, but all we need is to know a formula and then its just a matter of plugging the correct values in.

Continue reading...
UVa 498: Polly the Polynomial

UVa 498: Polly the Polynomial

22 May 2012

0 Comments

In Problem 498 at UVa Online Judge, Polly the Polynomial, we are asked to evaluate a polynomial. The problem is easier that usual, but its designed to help engineers remember the basic algebra skills, which they supposedly forget as they progress further in their studies. We focus on code reuse and put a little extra work into this problem, but that extra work might save us some work the next time we need to work with polynomials. We also did some manual input parsing, but that can be a handy skill to have.

Continue reading...