So.. who was right??? Huxley?
Pic taken from: http://www.recombinantrecords.net/
So.. who was right??? Huxley?
Pic taken from: http://www.recombinantrecords.net/
Problem 24 in euler’s deals with getting the millionth lexicographical permutation of the digits 0-9. Generating permutations is not a big deal, quickly plunged into the problem and brute forced it into submission.
def problem24(): def perms_gen(seq): if len(seq): for i in range(len(seq)): curr = seq[i] remaining = seq[:i] + seq [i+1:] for gen in perms_gen(remaining): yield [curr] + gen else: yield  i = 1 perms = perms_gen(range(10)); while i < 1000000: perms.next() i+=1 print ''.join([str(i) for i in a.next()]) problem24()
The drawback was that the whole thing ran for over 10 seconds. Anyway after unlocking the problem, I checked out some of the solutions and had a why-dint-i-think-of-that moment reading this.
euler (PHP) euler is from EnglandWe know that there are n! permutations for n distinct digits and, as we’re working in lexicographical order, after 9! permutations the ten digit string will have become: 0987654321. The 9!+1 permutation will be 1023456789, the 2*9!+1=725761 permutation will be 2013456789. However, the 3*9!+1 permutation (3012456789) will be greater than one million. So we now consider the permutations of the last nine digits, 013456789: 6*8!+1 will take it to 701345689. We have now computed 967681 permutations and arrived at the number 2701345689. Then we look at the last eight digits, and work out that a further 6*7!+1 takes it to the string 2780134569 and a total of 997921 permutations… Once I discovered this method, and rather than continue by hand, I wrote a programme to complete this (tedious) task for any given number of permutations.
I’m not sure how md2perpe did it, but when I was developing this problem I initially solved it by hand.
Anyway, i have moved into level 1 and got myself a badge here
My team mates gifted me a tomato red coloured t-shirt on my birthday, yes, a tomato red tee. I usually pick and wear neutral colours, colours like muddy brown, dung brown, dry dung brown, dry cement grey, wet cement grey, dung ash grey, volcanic ash grey, slate grey, colours that would blend me into the walls and make me as inconspicuous as possible. I am a little partial to green and at times, when I feel a bit adventurous, I go for something bright, like say, mossy green.There is no way I would ever go for tomato red, any red for that matter, even if I got real high on acid, stripped off all my clothes, ran into the streets and had helicopters with chopper lights and TV camera crews on board irradiating my nakedness and the only way to stop my pulchritudinous nudity from being broadcast to 800,000 cities worldwide and accidentally to any extra terrestial life trying to get a glimpse of life on earth would be to wear a tomato red garment lying by my side, not even then, I wouldnt even bother looking at it, instead I would put on my sunglasses and wave stuff all the stuff at my disposal at the cameras. Anyway, it was a gift from friends and so I cast aside my irrationalities and wore the shirt. I went to the mirror to get an opinion, both me and the guy in the mirror were surprised, the shirt looked great and I.. I took an instant liking for the color. I went to my wardrobe, opened it and stood before the racks. I patted on the shirt like a teacher praising his favourite student in front of the class and poured scorn on all the grey shirts for not being as good as tomato red. I dint realise till then that I had so many fucking greys, what a pointless colour! Well, that’s one colour off my dont-even-think-about-wearing list, thanks to folks from work. Let me see what else is on the list.. ah… pink.. hmm…
On this day, back in the year 1922, was born a genius, a man who inspired millions by his humour, wit and humanism. There is no one better at presenting the human nature in such a simple and goofy way and yet leave us with a powerful urge to lead a kinder, gentler and wiser life.
Some of the gems that come to my mind when I think of him are
We are healthy only to the extent that our ideas are humane.
Take Care of the People, and God Almighty Will Take Care of Himself.
He also said..
I tell you, we are here on Earth to fart around, and don’t let anybody tell you different.
.. and I agree. 😀
Remember the man. Remember Kurt Vonnegut Jr.
Read my first Kafka last weekend, The Trial, the story follows the trial of Josef K, the protagonist, who has absolutely no idea what his trial is about. The book is funny, the absurdity of being tried for a crime that is not specified throughout the course of the trial is, if not anything else, comical, but it had a nervy edge to it, it was like the funny you experience when you hear your boss crack a joke and are unsure if it was a joke or not and whether it would be alright to laugh out loud at it and so on.
Consider this, K is accused of a crime, the nature of which is not known to him and is impossible to glean from the courts, for the proceedings are conducted at whim, without his knowledge or his presence, and even if it were conducted in his presence, it would be near impossible to mount a defence without knowing what the hell he is accused of. He tries hiring a lawyer, who, it turns out, is only slightly better placed than him in learning the nature of case. Sure enough, he fires his lawyer and considers taking up the case himself. The whole affair is so terrifyingly ridiculous that one cant help doubting if it is nothing more than a fabrication of a deranged mind.The book maintains its humor almost till the end where things take a rather bleak turn. The doorkeeper parable(an engaging read on the nature of law which can be read independent of the novel) serves as a prelude to darker things and sure enough, K meets his rather unexpected end.
Any mention of dystopia brings 1984 to mind and sure enough I ended up contrasting The Trial with 1984. While the latter deals with one man’s fight against a known enemy, albeit an insurmountable one, the former portrays the helplessness of an individual against a soulless behemoth beyond comprehension, what good is resistance when you dont know what you are resisting. In 1984, for all the troubles Winston Smith undergoes, I most definitely expected him to end up dead(it could be said that he is dead in a manner of speaking) but K… everything about the trial was so frivolous that I did not expect him to be put away, ‘like a dog’.On the whole wasnt really overawed, one reason could be that Kafka did not complete the book and it was only published posthumously, the other could be that translation I picked up was average. Nevertheless it was a funny, dark and engaging read.
I am tired. Tired of having tried to explain evolution to a friend, who happens to be sufficiently educated and yet summarily rejected all the evidence for evolution that I had to offer. Be it the tortoises from galapagos islands to domestication of dogs to the laryngeal nerve in a giraffe. And I kept getting the same points again and again ‘How did a deer turn into a lion?’ ‘Evolution is just a theory… ‘ and so on. The last straw was the belief in the bible concerning the age of the earth being 6000 years, dendrochronology alone proves that wrong, never mind other dating techniques.
I just cant let it go, it is not a philosophical position, It is not a case of freewill vs determinism where each can hold a set of theories and agree to disagree. Turning a blind eye to evidence while providing our existence alone as a supportive argument for the existence of god baffles me.
I have often wondered why Dawkins is so militant in his approach towards explaining evolution, having tried to do the same, I now realise that it is not some mindless aggression, but the manifestation of the frustrations at having to explain something so obvious as 2 + 2 = 4.
And I have to say this again.. just to release all the pent up anger ‘EVOLUTION IS NOT JUST A THEORY……..!!!!!!!!!!’
Remember this, seems a long time ago. I recall being the only person to vociferously dissent against the ‘scheme’ of forcing a payoff, articulating as best I could on why the whole idea was destined for failure. I was extremely pissed off at being the only one. Anyway, the scheme has blown off like a suicide bomber in the middle of Basra. Now I am being a smug bastard in syaing ‘I told you so’, but what the hell, I was right.