# Niranjan Nagaraju

I am Vini – Vini The Pooh aka Niranjan. I am a little “sheep in the big city”. A self-proclaimed atheist, freelance writer and cartoonist; The latter two are an avocation as yet, but I believe they really are my medium. Oh, and I code for a living. :)

Jabber/GTalk: vinithepooh

## Combinatorial Algorithms

0

Combinatorial algorithms(permutations, combinations, powersets, subsets et, al) had never been my forte.

Infact, I was quite scared of them.
Presumably an irrational fear that stuck with after a failed effort in my graduate years.

No matter, This weekend, I set out to remedy that.
I didn’t want to read on the algorithms before implementing and decided I’d go pencil-and-paper and implement one that occurs naturally to me.

Here goes the result of that –

## Project Euler Problem 22

0

Whilst trying Project Euler problems, I often write a prototype in Python before trying out an implementation in Haskell.
This problem however was screaming for “Functional Programming”.

In fact this time around, I started with a Haskell implementation and went on to translate to Python just for kicks. 🙂

Suffice to say, I am very pleased with myself. 😀

import Char
import List

names = [<List of names from problem specification>]

{- For each string s in list, Calculate sum of the characters’ alpha positions -}
sumChars :: [String] -> [Int]
sumChars [] = []
sumChars (x:xs) =
(foldl (\acc ltr -> acc + (ord(ltr)-ord(‘A’) + 1)) 0 x) : sumChars xs

main = do
let sortedNames = sort(names)
let zippedSumAndIndex = zip [1 .. length(sortedNames)] (sumChars sortedNames)
let total = foldl (\x y -> x + fst(y) * snd(y)) 0 zippedSumAndIndex
print total

## Tag. You’re it.

6

I have been tagged.
Labelled. Like a lab-rat.
Much against my stymieing efforts.
As to those who are wondering what am I prattling about; This, and this is what I mean.

Long story short. Gurumaata has initiated a new activity, One that she believes will help us mere mortals know better about each other. The social networks after all, are so chock full of baloney and reek of egotistical trumpets.
As to the activity itself, All one has to do is write a blog post mentioning 7 things about himself/herself and tag 7 of their friends who are to follow suit.

0