Project Euler is a set of mathmatically-oriented open challenges for developers. I started working my way through these the other day with a bent of using C# and LINQ as much as possible.
I’ve shared my source on my public GitHub
For example: Problem #4 “Find the largest palindrome made from the product of two 3-digit numbers.”
Use of LINQ to express the cartesian join between the sets of 3 digit numbers dramatically simplifies the amount of code written. While the code is somewhat inefficient – I don’t dedupe reflexive pairs of numbers between sets – it is quite elegant.
Finally got around to putting my ITunesSync command-line utility out on my GitHub.com repository.
It fixes ITunes bloody irritating inability to “watch a folder”, keeping a folder full of music in sync with ITunes – something that Media Player and other “watcher” based systems seem to manage so easily. Find out more here:
I’ve been reading Vazirani’s Algorithms last night – quite an entertaining book considering the dry subject and similar books on the topic. Vazirani’s website has a draft of the book as PDF too.
While the book is very much language-agnostic, I thought I’d have a crack at some of the algorithms using much newer semantics of C# and the yield keyword.
The Fibonacci sequence is especially interesting because it can be a O(N2) recursive, or a O(N) linear performer depending on implementation.
I took a stab at the linear implementation, the results are surprisingly clean and simple. In the first cut, I did the traditional loop thing with a conditional guard for iteration 0 and 1. Second cut is much more elegant, removing the conditional guards all together and replacing them with a sequence of yields :
foreach(UInt64 fibNumber in FibonacciSequence())
public static IEnumerable<UInt64> FibonacciSequence()
UInt64 nminus1 = 1;
UInt64 nminus2 = 0;
UInt64 current = 1;
yield return 0;
yield return 1;
yield return current;
nminus2 = nminus1;
nminus1 = current;
current = nminus2 + nminus1;
Took a cruise to the Microsoft Company Store to get Win7 for a family member. The place is full of tech-goodies – very hard to come out with only the items you intended.
I originally went in to get Win7-Ultimate but Win7-Pro was cheaper by $10 – no significant feature differences. It was quite a novel experience for this millenium at least – the last time I held a boxed OS product was Windows NT 4.0.
With an extra $10 burning a hole in my pocket I stopped at the mice rack. We’ve lived with a Notebook Mouse on our desktop since the wireless mouse died. I picked up a Microsoft Comfort Mouse 4500 for a little over that tenner – nice and comfortable to hold without being too flashy. Tried it on Win7 and OS/X – worked right of the bat – no drivers etc needed.
On the way out I stopped to browse the the Xbox games stand and grabbed another copy of Halo Reach. Lauren’s been talking smack for ages about how good she is at multiplayer, but she only played splitscreen. We’ve got two Xboxes, and tonight I, as every parent should, mercilessly slaughtered her – headshots, beatdowns, and obligatory corpse desicration.
Finally reinstalled my office desktop and upgraded it to Windows 7. Unlike previous quantum leaps, I started from scratch – new 1 terabyte drive, new 23″ monitor to place the pre-millenial 17″ LCD, fresh OS install etc.
This is also the first time I’ve installed Windows from a USB key, to create your own:
Took around 20mins in total – pretty quick and smooth. Plug-n-Play just did its thing, everything worked immediately display, printer, scanner, webcam, mouse, keyboard, even the UPnP gateway all discovered and controllable.
My original reluctancy to pave the machine stems from the level of investment in time spent with Windows application installations. Over the last decade, I’ve been from Windows 2000, through beta versions of Windows XP all the way to Vista SP2 all with upgrade installs. However of course this includes a lot of baggage.
This time around things are a little different, beyond being Print/ITunes/Backup/File Server and general office document workhorse, we’re spending more and more of our time in the browser -
- I have far fewer applications installed, Visual Studio, and some games easily installed on demand from Steam.
- My wife only uses Office and some hokey-but-necessary Swim-team management software, otherwise preference is iPad or iPhone.
- Kids don’t have any games installed anymore, preferring their web/flash and Apple iOS games, along with burning hours on Skype and Facebook chatting with their friends.
However all is not so rosey. I can move documents and reinstall applications (200gb of Music and Video for example). However I’m increasingly dependent on complicated applications like ITunes. However it is far from a one-folder deployment, also the Apple documentation on moving that library is dire.
However the result is a machine that runs much faster in 64bit mode. And has much less junk installed on it.
If electronic books are more resource efficient than paper, and confer less rights like resale and unlimited loaning, then why are Kindle editions of books *more* expensive than paperback equivalents?
Given that there are multiple e-readers on the market, all I see is price-fixing.
Been reading a lot of code in the
riak core framework. Powerful stuff.
Fits lots of questions about managing big distributed systems in Erlang – answered a question up on StackOverflow about just such a scenario: