So, tomorrow is Google Code Jam Latin America. I'll give it a try, but I expect to get my arse kicked. Although I've been practicing a bit at SPOJ and acm.uva.es, I really suck at thinking under pressure. Ah well, let's see how it goes.
So, tomorrow is Google Code Jam Latin America. I'll give it a try, but I expect to get my arse kicked. Although I've been practicing a bit at SPOJ and acm.uva.es, I really suck at thinking under pressure. Ah well, let's see how it goes.
1.
#define is_odd(x) (((x)&1) != 0) #define is_even(x) (((x)&1) == 0)
2. if you're out to disprove the Collatz conjecture, use GMP or something.
It's all demonstrated in this wonderful IOCCC winner (hint file).
[elided]
Free software
Haven't touched my personal projects in a while, partly because of lack of time, partly because of the SPOJ addiction, partly because of general pissedoffness, but anyway I packed together the minor changes I did on vulcan in the past couple of months (lots of bugfixes) and called it 0.3.1.
Speaking of SPOJ, I recently ordered Sedgewick's algorithms book with the specific purpose of improving my SPOJ score. Whee.
Where can we find the updated mod_virgule code?
SPOJ
Phew. This took a lot of work. I exchanged the first place with the guy that's currently second several times until finally changing algorithms and getting to the first place with a decent margin.
Changelog, ex posto facto:
For future reference, here's a neat trick to find the multiplicative inverse of a number modulo 2^k, lightning fast (this was needed in the pre-calculation phase of Montgomery). First, two facts:
To get q^-1 (mod 2^k), with k even, first get (b^2)^-1 from a table (for e.g. k=32 it will be a small table) and then use fact #2. With k odd, do that for k-1 and then use fact #1.
It would be really sad to see it go away. wingo put it nicely.
While it's still here, I'll keep on rambling...
SPOJ
I fell a bit behind on work and personal projects due to a recently-acquired addiction to the oddly-named website Sphere Online Judge. It's full of programming problems, mostly algorithmic. You post a solution and it gets compiled and tested automatically. Each problem has a ranking with the best solutions. It accepts everything from C to Haskell to Common Lisp to Intercal (really). This is my current status.
Hopefully I have the addiction firmly under control now. On the plus side, working on the problems is giving me the motivation I needed to finally do something about the gaping lacunae in my knowledge of algorithms.
On other news - clever population-count function, via pmk:
int f(unsigned x) { unsigned y=0; int j; for (j=0;j<32;j++) y += (x<<j) + (x>>32-j); return -y;}
Ghost in the Shell 2: Innocence
Minor quibble: call me squeamish if you will, but I could do without the extreme violence.
New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.
Keep up with the latest Advogato features by reading the Advogato status blog.
If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!