Their nearest neighbour makes it very hard to find a way to exclusively make fun of Canada...
Sunday, August 02, 2009
Friday, July 31, 2009
Smalltalk's become() in python
Posting this here because blogger's sucky comment system won't let me post formatted code in a comment on this post. This is an implementation of Smalltalk's become() in python. It will not work on strings, int etc. but otherwise is identical
Wednesday, July 29, 2009
Answer to 1 of the 2 puzzles and a new puzzle.
I take Nicole's comment to mean she gives up, although Nicole, it turns out that your comment has a deep relation to this problem and raises a new question.
To find out on average how many items are left unmoved by a random permutation, you can consider every permutation and how many are left unmoved by each, add them all up and divide by the total number of permutations. To avoid mathsy notations I'm going to write a tiny program that calculates this total.
You can also get to this answer by drawing a grid with all the permutations across the top and all the items down the side. You put a tick in a cell in the grid if the permutation on the top leaves the item on the left unmoved. Now count the ticks. Doing it column by column is hard but doing it row by row is easy because there will be (N-1)! ticks in each row.
So the conclusion is that if you do a perfect shuffle of a deck of cards, on average 1 card will end up in the same places as before.
So where does Nicole's comment come in? I knew it was Ralph Wiggum who said it but I couldn't remember the context turns out. I found it here. It's
Lisa: Hey Ralph, want to come with me and Alison to play "Anagrams"?
Alison: We take proper names and rearrange the letters to form a
description of that person.
Ralph: My cat's breath smells like cat food.
and what we've just shown is that given a random anagram, you'd expect 1 letter on average to end up in the same place - well kind of, that's only true if there are no repeated letters. I hadn't thought of this in terms of anagrams before and that adds a nice twist in terms of repeated letters. Thanks Nicole!
So the new puzzle is - given a string written in scrabble tiles (it can have repeated letters), if you mess up the tiles and make a new string at random, how many letters do you expect to be in the same place as before?
Sunday, July 26, 2009
No code has no bugs.
So the more no code you have, the more no bugs you have.
Saturday, July 25, 2009
Pat, "the cope" Gallagher: dishonest or just an idiot?
In his letter to the Indo calling for a "yes" to Lisbon, Pat defends our membership of the Euro. I think there are upsides and downsides to it but for Pat even the downsides are upsides. He happily points out that
The eurozone has ensured that billions of euro have been made available to Irish banks via the operation of the European Central Bank.and that
As a member of the eurozone, Ireland has benefited from very low interest rates, notwithstanding the very difficult economic situation that faces us.
Surely he must know that these 2 things are the root cause of our massive bubble. The IMF and even Brian Lenihan have said as much. So if he knows this, then to list them as upsides of eurozone membership is basically swearing that black is white and up is down. There is of course that odd "notwithstanding the very difficult economic situation that faces us" which seems to be an attempt to cover all angles - as if to say "yes I know this is what fucked up the country but still it was great craic at the time."
Of course maybe he truly disagrees with me and thinks that the oversupply of cheap credit was an entirely positive thing and we should be thankful for it. This would certainly be compatible with FF's policy over the last decade, right up the point where the shit hit the fan.
Thursday, July 16, 2009
2 fun maths puzzles
I guess they're fun because I figured them out! If there's anyone actually reading this, post your solutions in the comments. If I get any responses I'll post solutions and if I don't, I might not.
- On average, given a random permutation of N items, how many elements do we expect to stay put? E.g. if N=3 there are only 6 perumtations, 1 leaves all 3 in place, 3 leave 1 in place and 2 shift all of them (left or right). So that's (1*3 + 3*1) / 6 = 1.
- On average, given a random function from 1..N->1..N which may or may not be injective or surjective (that is there may be X and Y such that f(X) = F(Y) and there maybe be a Z such that f(X) != Z for any X), how many elements do we expect to stay put - f(X)=X? E.g. if N=2 there are 4 possible functions, f(X) = X, f(X) = 1, f(X) = 2 and f(X) = 3-X. These fix 2, 1, 1 and 0 elements respectively. So on average that's (2+1+1)/4 = 1 but what about larger N?
Sunday, June 28, 2009
Movie: Blood, the Last Vampire
I went to see it tonight. It was mostly OK, some good action scenes but often things were moving too quickly to really be able to appreciate it. I found myself wanting to watch Ong Bak,the super-awesome Thai movie starring Tony Jaa. It's super-awesome because there's no wire-work in it. I dislike wire fighting. If you're going to do it with wires, you may as well just do it with camera tricks or CGI and then even I could do it - not awesome at all. The stuff Tony Jaa does in Ong Bak is just fantastic and - more importantly - surprising and often funny.
Aaaaaanyway. Blood is essentially Blade but instead of Wesley Snipes the half-vampire vampire killer is a Japanese schoolgirl. What could possibly go wrong? Mostly nothing goes particularly wrong or right. Add in an unsatisfying ending and you've got "meh".
I would have been annoyed if I hadn't managed to get to it but I'll have forgotten about it in a month.
Sunday, June 21, 2009
Movie: A tale of two sisters
I saw this Korean movie years ago but my trip to the cinema tonight reminded me of it because there is just a single sudden fright in the movie and everyone in the cinema leapt, popcorn flew and a few seconds later everyone was nervously giggling and apologising to the complete stranger next to them. A great movie. It turns out it was remade as The Uninvited which was out a few months ago. From the reviews I can find, they made a pig's mickey of it. Ah well.
Mouth water chicken - yummy but dangerous
After my movie trip I went to Sichuan House and ate the spiciest food I've eaten for some time. I came home and ate ice cream in the vain hope that that will neutralise some of the spicy before it makes its way out again. On the menu as "口水鸡 - steamed chicken in chili sauce" (first in the list of salads if you're looking for it), it literally translates as "mouth water chicken". It's a half a cold chicken, drenched in spicy, oily sauce with peanuts, sugar, spring onions and other stuff. It smells exactly like the smell you get in a real Sichuan restaurant - it's nice to know what I was smelling way back when. It's damn tasty and I brought half of it home on the back of the bike! Not sure if I'll eat it myself. I'm going to a BBQ tomorrow, I might bring it along for others to sample. In the meantime, I think I'll go put a pack of wet-wipes in the fridge...
P.S. Ow! Jesus! I rubbed my eye! Chili, chili, chili! Ow!
Saturday, June 20, 2009
Movie: drag me to hell
I just saw Drag Me To Hell and I had a great time. It had the scariest old woman I ever saw in a movie. It had the scariest lace handkerchief I ever saw it a movie. It had lots of out-of-seat jumping. It had gumming (not a typo) and goats (also not a typo) and it made me laugh out very loud - just once, mostly it wasn't trying to be funny. I'm really glad I saw it. There's how's that for elevated expectations leading to certain disappointment?
Afterwards I ate some lovely Chinese food.
Monday, June 15, 2009
Too much syntactic sugar...
... gave Perl syntactic diabetes.
Sunday, June 14, 2009
1362 Kanji Characters
1362 might not sound like significant number but that is 2/3 of the way through the 2042 characters of Remembering the Kanji. It has become a bit of a slow slog but the progress is fairly steady. I thought I'd get more done while Midori and the kids were away but so far I haven't done anything amazing. In fact 54 in the last 7 days is less than 10 per day - I was occasionally able to beat that with the family around. It's way off the pace from my first 4 weeks but I had 2 weeks of rest before that and I was excited and motivated by the discovery of a sure-fire method of learning the kanji.
It's nice having a fixed goal of 2042. This covers the standard high school kanji and some extras that are too useful to leave out or necessary for the method. It also allows me to set motivational targets. Without a fixed goal, I could set targets of doubling my kanji count and meet the pretty easily to being with. Going from 128 to 256 in about a week was possible. After that, doubling gets harder and harder and doubling 600 to 1200 took a very long time because of lack of free time. But with a fixed target, now I'm on the down slope. The next target is 3/4 (1531), then 4/5 (1633) and so on.
The first hint of trouble begins when I finish number 2002. That's when I go across the 49/50 mark. The trouble is that I also cross the 50/51 mark which makes kanji number 2002 twice as exciting, that might not seem like trouble but more is to come. Kanji 2003 only crosses 51/62 and Kanji 2009 only crosses the 60/61 mark but from there on in every kanji crosses at least 2 marks. Kanji 2041 crosses 1020 marks! All the way from 1020/1021 to 2040/2041. But the real problem is the last kanji. When I complete that I will cross an infinite number of motivational markers, presumably resulting in infinite excitement, that can't be a good thing.
To avoid danger to myself, my family and small animals near by I have already ordered the follow on volume which covers a further 1000 useful but less common kanji. I will deploy that as soon as I feel the excitement is getting too much. Mr Heisig sure is a devious man.
Sunday, June 07, 2009
The real reason for bailing out Anglo Irish bank.
I like Gene Kerrigan's articles in the Sunday Indo. He had 2 recently: "Servile surrender sowed seed of doom" and "Saving economy while people go down" which deal with our governments obsession with saving Anglo Irish Bank and the others at the expense of absolutely everything else. Why this is happening is a really important question. He makes a lot of sense but he seems to think that the govt are simply mesmerised by the bankers, "deferential and submissive" just as they were in the past to the church. He makes it sound like the govt is just in awe of these guys and willing to do whatever they request - the same way some politicians seem to be in awe of the "free market" and espousers free market ideology. I actually don't think it's that simple (I doubt Gene Kerrigan does either).
Mr Kerrigan says that we should let Anglo go to the wall and let the bond holders take the hit. The argument is that they gambled, they knew the risks and they lost - there is no reason for the Irish government to cover their bet. The problem here is that when they placed their bet, they were ostensibly betting on regulated a bank in a modern, Western, open democracy. As such, on paper, their risk was low and their rates of returns would have been low too (I haven't checked the rates...). On paper, such a bank, regulated by a well run EU member, should never go bust. The problem is that there was no such regulation, worse still there may even have been collusion between the bank and the regulator. For the government to then say "sorry boys you lost, thanks for playing" raises some problems. These bond holders would certainly not be happy with that and would presumably draw even more attention to the misdeeds of the bank and the regulator, possibly even taking legal actions (I have no clue what recourse they would have) and at the very least making it very hard for AIB, BOI and the other to raise capital as they were and still are under the same crappy regulatory system.
The whole thing is a bit like cheating at poker in a gentleman's casino. Ireland sat at the poker table and won hand after hand. It won because it was cheating - it didn't regulate its banks properly. Come the end of the and by now everyone knows Ireland was cheating and Ireland realises that they know. Of course "gentlemen" don't like to bring up this sort of thing in public, it's impolite. Ireland has 2 choices:
- it can pretend it didn't cheat, leave the casino with its winnings - in this case it will be black-balled and no one will ever play poker with Ireland again. The genetlemen might then abandon their usual decorum, call out the cheating directly and look for their money back.
- it can say "what a splendid evening we've all had" and leave its winnings on deposit in the casino's safe, then come back and play a losing game every night until it has lost enough to repay it's cheating debt plus interest.
The good news is that finance is not the same as poker. There is a third option. We can do #1 and also avoid being black-balled and banned from every table if we can convincingly promise never to cheat again. We must acknowledge the wrong doing, punish the wrong doers and put in place legislation and regulators with real powers. They must not be mates of the politicians or the bankers and they must be willing to remain adversarial. No more jobs for the boys. Without this step, #1 would be extremely dangerous for all Irish banks. That still leaves us open to attempts to recoup our ill gotten gains but the worst that can happen is we end up paying them all back, just as in #2 except.
The bad news is that Fianna Fáil certainly don't have the balls to do this. They are much happier to take #2 whereby everybody remains gentlemanly, nobody loses face and the tax payer picks up the bill (to a large extent it was the tax payer who benefited but it will not be those who benefited most who end up paying back the most). I don't believe that any of the other parties have the balls to try it either or to even contemplate it, they don't want to rock the boat and they have all shown that jobs for the is what its all about.
Incidentally, I don't believe the bond holders were dummies either. I imagine they knew how poorly regulated the bank was. However knowing that the government would feel forced to save them, they could make their bets based on the imaginary state of regulation, not the real state of it.
Quick review: aldi and lidl tins of tomato
More of a note to myself than a review. I make a tomato dip that is a cheap and easy version of a friends more lovely but more labour intensive tomato dip. It's great with a cook-it-yourself ciabatta from Aldi. You just get a tin of chopped tomatoes (I have been using Aldi chunk chopped with herbs), add a teaspoon or two of pesto (I have been using Lidl's) maybe some extra olive oil if you like and a bit of salt and pepper.
So the point of this post is to note that when I made this with Lidl's "Nostia" chopped tomatoes it was nowhere near as nice. Theirs seems much more watery. I haven't tried it Roma. I doubt I will since they are 3 times the price of Aldi's and unlikely to be 3 times tastier!
Quick review: graco stadium duo double buggy
About 9 months ago, we bought this for about 170euro after having our second child and we're pretty happy with it. It's quite heavy and big but so much that Midori can't lift it into the boot of the car (it just fits cross-wise in the boot of a Prius). The kids are comfortable in it, Seán can sleep in the back section when its flattened out. There's plenty of space underneath for carry shopping etc and it's surprisingly maneuverable for it's size. I think Midori even went to town on the bus with it once but I wouldn't try that myself unless I knew the bus would be very empty.
Overall a thumbs up, especially at the price.