Fathers Day

Well while I enjoyed my fathers day sleep-in this morning, I worked through why the example Sieve of Eratosthenes works. When for example the outer loop is at 4, you can start at 16 (4*4) due to the 2, 3 times of 4 been taken care of when the outer loop was 2 and 3. So now I’m feeling a bit silly for not seeing it at the time. But at least I can now use it, with confidence.

I also walked through how to solve the first part of the 550 point problem. Now I going to sit down and work through the string building part.

Redemption from quick judgement (Politics)

Chris from the .Net user group mailing list often post on his blog political posts. Fair enough that’s the beauty of the web, and he even qualifies it nicely, his blog’s at “syringe.net.nz” with the tag line “Irregular injection of opinion”. So in his posts he takes what I think is a pretty hard line against the welfare system. The problem, which is mime, is I just feel so baited by his words. He’s posted some flame bait and some good points.

Anyway, he posted his power point slide from his TechEd talk, and low and behold its on smart clients, and the Composite UI Application Block. So I’m watching the slides with no voice over, wishing I could have attended the original talk. Then it occurred to me that if I had been at TechEd there would have been a high chance that I wouldn’t have attended a talk from Chris because I felt so out of touch with his apparent political stance. This is really the most silly of things.

So I started thinking how Chris could have such a strongly angled view of the welfare system (related to family/child support). I must agree there are problems, but I get the feeling he thinks it should all be scraped, so that he get more of his dollar back. But what occurred to me today when I realised that I had an issue with Chris, was maybe he’s just not experienced some things that I have, maybe he sees things as a cost to him, verse him helping other because he’s lucky. I’m not trying to saying he is where he is at due to luck and not due to a lot of hard work, but more of a maybe he hasn’t been delt some really bad hands.

More on this the angle of experiences and bad luck, a friend of mine came over from the UK to work ~3 years ago. In that time he has flown back three times due to his father getting sick and then dying and recently his mother been sick and staying until she passed away. All’n’all I think he’s been over in the UK for almost 5 months not working, and watching his family die. I’ve not experience of this. But it really makes me appreciate my parents. It’s one of the experiences you’ve had or you haven’t. Having talking over our lives with this friend I can’t help think this guy’s been hit with the bad luck stick.

So back to political things. I think a large part of the difference of opinion is also experiences. I’ve been in situations (child, and young adult) where the welfare system has been a heaven send. When my wife and I where younger and I wasn’t earning as well as I am now, we where entailed to support for our children’s preschool fees and the likes, my point is for most services we volunteered to stop receiving government support before we were required, due the hoops and constraints it put on you. But I’m thankful they where there. I thank those that helped me (via tax). So now I’m paying more taxes, I don’t see it as buying my neighbour an Xbox for there kids. Hell I’d like an Xbox first. But I’m saving my money so I’ll be better off later. And that’s maybe an area I dislike about the welfare system is that I’m paying for others to smoke, drink, gamble. Sure I buy ~2 lotto’s a year and drink some wine, but it’s not the weekly norm.

So in some sense people are just thinking of them selves. And that’s where I tie this altogether, the overwhelming feeling I original got from Chris was his sense of self. And that’s what the political parties are playing to. I’m still undecided as to which direction to chose. I’d be more interested in underlying polices than tax cuts, what are the sub points that are important to each party, what is not important. Stop with the pandering to the masses with tax.

So I apologise to Chris for been offended by his political stance, it is after all just opinion.

Post TechEd knowledge sharing.

Kevin (one of our senior developers) has returned from TechEd. The first demo he did was showing how ClickOnce works. He spent the afternoon getting our current .Net 1.1 application running in .Net 2.0 Beta 2, then configured ClickOnce and showed it working. It just worked. I love the client based roll-back support and forced upgrades features. So while I was thinking this is great, I was also thinking its about time. This is what people need to smite the ASP.Net everywhere mentality. Now deploying real apps via HTTP will be as easy as “configure and click” for the developer, and easier for customers to use.

The other topic Kevin was quite keen about was SQL Server Integration Services (SSIS). This should make life easier for us, or if not easier to do, allow us to step up to a new level of service (product stability and administratively) better than we are presently doing it. I’ve found this seven part series on SSIS (1 2 3 4 5 6 7) that I’m working my way through. Seems like a nice system.

Kevin’s got some other topics he wants to investigate to see if they will add real value to our development process. So I look forward to more reading and demo’s in the next few weeks.

TopCoder – Single Round Match 261

Well yesterday I took 2 hours off work in the middle of the day to compete. The end result was a “why did I bother”.

The first problem was a really simple prime number search problem. You had to search a range of numbers, and for those numbers that were primes, modulo the prime with a given number. Return the lowest remainder with the highest frequency. Well I wrote the fancy Sieve of Eratosthenes and stuffed it up. Another coder in my room noticed my mistake and found an example case that it failed. At lest it took him three attempts to find it, so he got no gain of points from it.

After some investigation there appears to be a couple of ways of doing the inner loop in the sieve. (Using the same variable naming as in the linked example)

The most obvious is

for( int k = i*2; k <= n; k+= i )

and how the above example code does it, which is faster

for( int k = i*i; k <= n; k+=i )

Which computes from the square up, but when tested they give the same results (tested up to 100,000,000). But my mistake was the loop termination ended at k < n and I initlised the inner loop as int k = i; thus it looked like this.

for( int k = i; k < n; k+=i )

So now at Greig‘s recommendation I’ve written it up the correct way, and I’ll keep it handy for future competitions. Of note is that I wrote my incorrect code faster than
Mark‘s correct code, in a time of 11:21 vs. 14:44. But that’s not much of a victory.

The second problem was about binary trees and was worth 550 points. I really did not know how to solve it, and after reading the post match write-up I still do not understand it, so I’ll have to try the example code, and see how it works. So in the competition I tried implementing a permutations based solution (as this looked like what was happening) but I couldn’t get it to work in time. I even went and found a C++ example, but couldn’t get it to work ether.

To add insult to injury, I challenged another person’s 550 point solution in the challenge phase, and failed.

Final competition result, a score of -25. This put me in 298th equal out of 308 instead of 215th equal if I’d not challenged. So now I’m back in Division II with a ranking score of 1009.