Your first example has nice trickery in it but I prefer the original version. I think it is important to keep it simple.
Compressed code is often not the best way to do it; adding a few lines of verbosity can reduce the time it takes to understand the code to a fraction while sacrificing very little in terms of performance.