News for hackers. Stuff that matters.
Re:I'm a cargo cult programmer, help me by pokoleo on Friday February 25, 2011 @07:06PM (#2264339)
I've got a project for you:

In terms of algorithms and data structures, this is about the best that you can get: Given a list of 10k unordered sets of 5 letters (let's say a .txt file, 5 letters per line), print what set occurs most often.

It's much more challenging than you'd expect, and my suggestion would be to implement any sorting that you wish to do, yourself. (not use Arrays.sort, or any library like that).

It's a problem that I was given in highschool, and was pretty exciting.

For an example data set, my suggestion would be to get a random character generator printing 5 characters per link, 10k times.

Re:I'm a cargo cult programmer, help me by flozimm on Saturday February 26, 2011 @05:35AM (#2265277)
Would this work as a solution:

i) convert the array of arrays of chars into an array of arrays of integers (the letters ASCII values).

ii) create a new integer array containing the sum of the cubes of each ASCII value for each entry

iii) create an empty hash table and fill it with (key|value) pairs containing (integer|number of occurrences) by looping through the previous array

iv) sort the hash table by 'number of occurrences' and store the biggest (key|value) pair

v) look for the first match in the original array to find which chars it represents

Efficient/correct or not?

Re:I'm a cargo cult programmer, help me by jimktrains2 on Tuesday March 01, 2011 @11:43AM (#2276093)
Why not just use a tree?