Archives

You are currently viewing archive for May 2012

2012.05.16 (14:44): read later - garage collection

Category: Tech
Posted by: modi123

2012.05.16 (14:27): read later.. php bad

Category: Tech
Posted by: modi123

2012.05.10 (11:31): Rules of the Internet..

Category: Tech
Posted by: modi123
I need to keep this as a reference.
rulesoftheinternet.com/

2012.05.10 (10:54): wolframalpha..

Category: Tech
Posted by: modi123
Isn't this fundamentally spooky...

http://www.wolframalpha.com/

Wolfram|Alpha introduces a fundamentally new way to get knowledge and answers—
not by searching the web, but by doing dynamic computations based on a vast collection of built-in data, algorithms, and methods.

2012.05.09 (16:36): MapReduce - read for later

Category: Tech
Posted by: modi123
In Lisp, a map takes as input a function and a sequence of values and applies the function to each value in the sequence.
A reduce takes as input a sequence of elements and combines all the elements using a binary operation (for example, it can use “+” to sum all the elements in the sequence).

MapReduce, inspired by these concepts, was developed as a method for writing processing algorithms for large amounts of raw data.


http://www.developerzen.com/2009/05/06/introduction-to-mapreduce-for-net-developers/

2012.05.09 (11:29): Josephus Problem

Category: Tech
Posted by: modi123
The Josephus Problem is always an amusing one. Fairly grizzly in nature... you line up N people in a circle and starting at the top you count off K number of people and then kill that person. You then repeat the K count from the next person over and eliminate that person from the group.. this continues until you are down to one person.

I forget sometimes people get asked for sequences on job interviews.. but damned if this didn't take me three minutes to knock out. Oh Probability and Combinatorics class - how I miss you!


'-- the Josephus Problem sequence
Dim listOfPeople As New List(Of Int32)

Dim lHowManyPeopleTotal As Int32 = 30
Dim lNthPerson As Int32 = 3

Dim location As Int32 = 0 '-- the temporary location to remove from the collection.

'-- fill our list with numbered people.
For i As Int32 = 1 To lHowManyPeopleTotal
listOfPeople.Add(i)
Next

lNthPerson -= 1 '-- remember the array list starts its index at 0

While listOfPeople.Count > 1 '-- run until there is only one item in the list left.
location += lNthPerson '-- from our current location add the number of steps we need to take.

While location >= listOfPeople.Count '-- if that number of steps is more than the items in the array wrap around.
location = location - listOfPeople.Count '-- this will happen frequently when when the # of steps is greater than the number of items.
End While

Console.WriteLine(listOfPeople(location)) '-- show what was removed
listOfPeople.RemoveAt(location) '-- remove it.
End While

Console.WriteLine("winner! " + listOfPeople(0).ToString) '-- show the winning spot!