rangearmentRe

Discussion of challenges you have already solved
megabreit
Posts: 141
Joined: Sat Jan 03, 2009 3:33 pm

Post by megabreit »

@gfoot: At the beginning I thought that this would be easy to solve with just shell. Everything was done in shell except the final hex-bin conversion. hex-bin conversion really sux in *sh. So I chose the right tool at the right time (could be awk or something else too, it depends on the situation and filling level of the coffee machine :-) ) At that particular point I was to lazy to re-code the whole thing in perl, the problem was solved anyway...
I'm an admin... I start typing shell commands while I'm thinking. I start programming first if this approach does not work anymore :lol: ...worked perfectly in this case.
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post by gfoot »

I know what you mean - I used to do a lot of thing in shell scripts. I just kind of realised that nearly everything I was doing with shell scripts ended up, at least somewhere in the script, either messy or completely impractical. Even things that start small often grow a bit. So I decided I might as well just go straight to Python by default. Some things end up longer, but there's always os.system if you really want to run an external tool.
rmplpmpl
Posts: 113
Joined: Sun Oct 26, 2008 10:38 am
Location: Germany

Post by rmplpmpl »

Gosh, reading about your nice solutions I feel ashamed by now.
As PHP is my best pick I wrote a small script to get me the filenames. Took ages anyway (just to get the idea to do so).
After putting the filenames into a single file and examination of the first pic I completely ran out of ideas (I checked the file lenghts of course but since the first few with the png header are identical to the file name I didn't look any further).
So it took me a hint from the forum to look again...

Actually I wasn't looking at the file sizes but at the content length (strlen)... just by reading this thread I did remember that this is of course the same for txt files.

Anyway, brilliant challenge!
MalNivek
Posts: 3
Joined: Mon Nov 28, 2011 4:47 am

Post by MalNivek »

I think this can be refined, but I'm stopping here :P

echo -e -n "`find ./ -name *.txt | sort | xargs ls -l | awk '{print $5}' | xargs printf "\\\\\x%x"`" > answer.png
User avatar
Hippo
Posts: 339
Joined: Sat Feb 01, 2014 12:05 am
Location: Praha 5

Post by Hippo »

Hmmm, I have not read the filenames. Let me see the 2nd image.

... OK :) as expected
Post Reply