Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Narnia

Saw Nar­nia the oth­er day.

Liked it.

Of course, the whole sto­ry makes no sense, but hey, that's how it's sup­posed to be.

If you have not seen it, and have not read the book, and in­tend to ig­nore the plot, please stop here. Ok?

There is this large li­on, Aslan.

He gives his own life to save that of a snivel­ing treach­er­ous, sil­ly kid who sells oth­ers for turk­ish de­light (a can­dy Rosario tried in Is­tan­bul, and tells me is pret­ty good, so there is some sense in him).

Ok, so the kid is ac­tu­al­ly just scared, and pet­ty, and a kid, and he's not that bad.

On the oth­er hand, the li­on...

For the whole movie, the White Witch is built up as evil, and mon­strous and a killer. But it turns out that the worse she does is freeze her vic­tim­s. Un­harmed.

She even­tu­al­ly kills some­one in a bat­tle (but so does Pe­ter, our 14-year old "hero").

The frozen guys can be re­vived at will by Aslan. Who for some rea­son had not done so.

On the oth­er hand, Aslan's big sac­ri­fice? He knew all along that he would be un­harmed. Even his mane re­grows af­ter a few hours.

At least he could have told the two poor girls who thought had seen him die. And skipped the whole heavy-­heart­ed "o­h, I am so sac­ri­fic­ing my­self" walk through the wood­s.

Oh, you may say, but the war is fought so that the true rulers of Nar­nia will as­cend to their thrones!

Well, how in hell are those four eng­lish kids the true ruler­s? They had nev­er been there, they have no con­nec­tion to any­one there!

Hell they are the on­ly four bloody hu­mans in the world!

It looks amaz­ing­ly racist to me. Species-ist?

So, hun­dreds of Nar­nia in­hab­i­tants die (and I mean re­al­ly die, not fake-die like that Aslan kit­ten) so some car­pet­bag­gers get to lord as kings over the ple­beian mass­es, in­stead of an­oth­er high­-born chick.

My sug­ges­tion to the hordes of gryphon­s, sphinx­es, po­lar bears, faun­s, cen­taurs and dwarves:

Kill them al­l, and start liv­ing a de­cent life, with­out sup­port­ing use­less par­a­sites.

Free Phillip!

PS: Yeah, I did like it ;-)

My first time

I just found here the an­nounce­ment of the first free soft­ware I pub­lished (at least, that I re­cal­l), from may 13, 1996. So, It's go­ing to be 10 years in 5 month­s!

Killer quote:

Requires:
Python 1.3 (Maybe 1.2 would work too)
XForms 0.80 (NOT 0.75)

Ok, here is how you write the shortest one

About http://www.py­con­test.net... here's how it's done.

Sad­ly, it's pret­ty much im­pos­si­ble to put the code on the web be­cause it has some re­al­ly non-ascii stuff in it ;-)

Here's the key tricks (thanks to Re­mi and the oth­er­s):

One of the key tricks is writ­ing a short ver­sion of a very long oc­tal num­ber (or three­).

I tried us­ing base36 and in­t('­gob­ledy­gook',36).

You could use 0x­hex­a­code­here.

But here's the most space-­ef­fi­cient one: use base 256!

For each byte you wan­t, cre­ate a char us­ing chr(byte). Then paste them all to­geth­er. Then put it in your code as a string. If you are lucky you will have no quotes or new­lines in it, and the python in­ter­preter will eat it.

You can lat­er get the byte num­ber x us­ing or­d('h!als­d­f'[x]), and each byte by some di­vid­ing and mod­u­lo op­er­a­tion.

An­oth­er im­por­tant piece is en­cod­ing 7 3-char­ac­ter strings as com­pact­ly as pos­si­ble, and split­ting them by off­sets (which are en­cod­ed in the pre­vio­su­ly men­tioned big num­ber in base 8 ;-)

One ex­tra squeeze is find­ing the short­est way to con­cate­nate strings.

It's ''.join(), but if you are us­ing it twice (or more), you save space by do­ing j=''.join and us­ing j lat­er.

Last one: In­stead of defin­ing a func­tion, do a lamb­da:

def sev­en_seg(x): re­turn .....

sev­en_seg=lamb­da x:

6 chars less!

And here is the short­est code I got so far (121 char­ac­ter­s, re­quires python 2.4. On 2.2, it has to be 124).

In the con­test, some guys are at 120. I don't know how. I can't even guess how ;-)

Up­date: it turns out I did know how to do it check it out I think it's the first pub­lic 120 :-)

BTW: you can't write that us­ing kwrite. Vim work­s, though.

Python Contest

There is a python con­test at http://www.py­con­test.net/

The task is writ­ing the short­est pro­gram to drive a sev­en-seg­ment LCD thingy.

I have no hope of win­ning, but here's a help­ful hin­t:

If your code is any longer than this (191 chars), it will not win ;-)

a=' _ '
b='|_|'
c='   '
d='  |'
e=' _|'
f='|_ '
g='| |'
v='agbcddaefaeecbdafeafbaddabbabe'
def seven_seg(x):
        return '\n'.join([eval('+'.join([v[int(l)*3+i]for l in x]))for i in 0,1,2])+'\n'

Note: I edit­ed this item way too many times al­ready ;-)

And yes, I can save two char­ac­ters mov­ing the re­turn up.

A much uglier, yet much short­er (151) ver­sion:

def seven_seg(x):return''.join([''.join(['|    ||__  __ || |  |'[int('a302ho6nqyp9vxvpeow',36)/10**(int(l)*3+u)%10::7]for l in x])+'\n'for u in 0,1,2])

And yes, that pret­ty much proves you can write ug­ly python. And I am giv­ing up. A short­er ver­sion prob­a­bly in­volves a dif­fer­ent al­go­rith­m, and I can't find any.

I am par­tic­u­lar­ly proud of sav­ing one char­ac­ter by writ­ing 104004334054154302114514332064 as in­t('a302ho6n­qyp9vxvpe­ow',36).

Al­so in­ter­est­ing is that the num­ber I was us­ing there orig­i­nal­ly start­ed with 4 and was ex­act­ly the same length writ­ten both ways ;-)

Since that num­ber is pret­ty ar­bi­trary (it's an in­dex ta­ble in­to the "graph­ic­s" ar­ray), I just shuf­fled the 1 and the 4. The 0 would have been bet­ter but then it did­n't work, of course :-)


Contents © 2000-2020 Roberto Alsina