##
Archive for the ‘**algorithms**’ Category

### Project Euler

Posted 14/12/2009

on:I know I’m a little late, but I’ve only recently discovered the interesting site of projecteuler.net. For anybody not familiar with it, Project Euler is a site offering a vast collection of programming puzzles of mathematical nature for anybody to solve. It has a ranking system for its members, allowing every member to see others’ statistics with solving the offered puzzles. Most of the puzzles are pretty hard, even for the gifted mathematicians among us, and the majority of them can not be solved using brute force methods (it would just take far too long), so usually an efficient algorithm is required. Once you solve a problem you gain access to a forum thread about the problem, its solution, and the various techniques and algorithms other users came up with.

### Enumerating permutations

Posted 14/11/2009

on:- In: algorithms
**5**Comments

There are exactly n! different permutations of n numbers. This challenge was about writing a function which is able to enumerate all these permutations, i.e. function permute(n, idx) which is able to return permutation with index idx of n numbers. The requirement is ofcourse that all these permutations must be unique – this is in order to go over all possible permutations.

### Reset an array in constant time

Posted 05/11/2009

on:Ever wondered how to reset an entire array of N elements in a constant slice of time? This post will introduce the algorithm along with an implementation.

Let me lay out the problem. There’s an array of N integers. We would like to be able to reset that array (set all elements to zero), in a set amount of time – regardless of the value of N. The reset operation should take the same amount of time whether it operates on 100 elements or 10,000 of them.

## Recent comments