May, 2009


27
May 09

Scala-Euler Problem1

Finished my approach to Euler Problem 1 last night and checked everything into github.

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.

Was not happy with limiting the specific factors of 3 and 5, and limit of 1000 so i implemented a generalised solution.

def solution(fs: List[Int], max: Int ) = ( 1 until max ).filter( f => fs.exists( n => f % n == 0)).foldLeft(0)(_+_)

Where fs is a List of integer factors and max is obv the highest limit. eg(Answer is in white font, so select the line “Answer” to see it

print("Answer: ",solution(List(3,5),1000))
>Answer: 233168

Thanks to @lichtsprung for the testing help.

The general aim is to complete a few dozen of these in Scala, then switch to Java, or C/C++, or something else, and loop around until i have a complete library of euler problems for all of the languages i end up using; Nothing like having long term goals!


22
May 09

Lenovo x61 Tablet Hard Drive (Near) Disaster

So, I love my lenovo tablet, so far through all the trails, tribulations, transcontinental visits, banging, bashing, bumping, swinging, twisting, scribbling, et al, its survived and become a near essential piece of my working and personal development.

Famous…Last…Words.

Appear back at the house last night after a fwe bevvies with the guys and loe and behold,

“Error 2100 – Hard drive initialization error”

The BIOS cant see the harddrive. But wait, lenovo built in that seemingly pointless blue button to do recover right? Recovery off the hard drive… That it cant see.

Anyway, enough of the problem, on to the solution. Starting from here and here

Lots of lovely corroborating evidence telling me unless your very…VERY lucky, your out of luck. (I have the Hitachi Hard drive, and had already reseated the drive in the bay).

Now, the X61 Tablet doesn’t have a optical drive. So what does Lenovo produce to solve this out-of-nowhere-disaster? A 30MB iso. In a format that cannot be booted from USB (please, correct me if I’m wrong)

Fortunately one of the guys in work (Thanks Mossey) had an external DVD burner. Borrowed that, grabbed the firmware update from here, burnt it to a DVDR (30MB wasted on a DVD!) and while praying, booted the machine.

It dropped into a lovely old-skool PCDOS display that, after some humming and haaing politely said “No firmware upgrade available”……

Fair enough, I’m one of those unlucky people, no worries, I’m sure i can just send in the harddrive for a replacement, only a few weeks…. But just to try it, i booted again, and magically, all back to  normal.

Now, maybe i just wasnt paying attention and the firmware DID get updated while i wasnt looking, but either way its a very strange “Success” message….

UPDATE: Problem got an awful lot worse but Lenovo treated me right, detailed here


12
May 09

Staggering Unproductivity

I must apologise for my lack of activity on the blog, but more is coming.

I’ve begun working towards working with Ian Clarke on his Swarm project, that is if i can bring my Java and Scala chops up to scratch enough to give meaningful impact.

Beyond that I’m heading to NJ this week to be with my partner for her graduation and have my 21st birthday while im over there (21 means absolutly squat in Ireland, so I’m expecting a repeat of my 18th…)

Coming towards the closing stages of my placement at Ericsson and i must admit that I’m going to miss the place, and the people, and even the work, but most of all I’ll miss the free coffee. If you ever get offered a place at Ericsson, take it.

Unfortunately, the usual disclosure agreements are in place, but frankly its alot of standard shell, perl, php, MySQL, Solaris stuff that isn’t exactly “How-To”-able.

Have also been doing alot of experimentation with a variety of VM solutions, but nothing worth repeating ( My recommendation: VirtualBox. Networking and Stability still arent perfect, but for a dev environment, its great )

I’m now in a half-n-half environment; I have kept my new ThinkPad X61s as a windows vista machine (dual booting 7, which i have to say is impressive), but i keep my main box on Ubuntu.

Anyway, update is done.


Load Times Plugin made by Ares Free Download