Quick n dirty solution in C.