Live data from Hacker News

What is the coolest thing you can do in ten lines of code?

stackoverflow.com

31–40 of 40 posts

Re: What is the coolest thing you can do in ten lines of code?

#32

Is 30 close enough to 10? I got a job with 30 lines of code appended to my resume, with a screenshot of the resultant output. Perhaps the first two pages had something to do with it but I was told that the third page was what stood out. This was a sysadmin position, the code includes bash, sed, awk, grep, tcpdump, netcat and gnuplot. Hint to anyone who tries this sort of resume stunt: You WILL be asked what the code…

That's indeed an interesting example because, by any standard, this is terrible code.

Yet for a sysadmin position it still provides valuable insight into your a) pain threshold, b) familiarity with the tools, c) willingness and ability to bend reality for the boss.

I'd just add a big disclaimer that this kind of code only happens in emergencies.

(disclaimer: I'm guilty of these gnuplot hacks myself and they always stick around way longer than they should...)

Re: What is the coolest thing you can do in ten lines of code?

#34
http://stackoverflow.com/a/811081

This person claims that simple variable usage and stdout should be all that is needed to impress. While I studied enough low-level software development to still be impressed by an adder circuit, I just don't think this will impress enoug of the people we NEED to convert. Just about everyone takes it for granted that when they log onto FB, they will see their name...and that doesnt seem like "programming" to them

Re: What is the coolest thing you can do in ten lines of code?

#35
post #32

Is 30 close enough to 10? I got a job with 30 lines of code appended to my resume, with a screenshot of the resultant output. Perhaps the first two pages had something to do with it but I was told that the third page was what stood out. This was a sysadmin position, the code includes bash, sed, awk, grep, tcpdump, netcat and gnuplot. Hint to anyone who tries this sort of resume stunt: You WILL be asked what the code…

That's indeed an interesting example because, by any standard, this is terrible code. Yet for a sysadmin position it still provides valuable insight into your a) pain threshold, b) familiarity with the tools, c) willingness and ability to bend reality for the boss. I'd just add a big disclaimer that this kind of code only happens in emergencies. (disclaimer: I'm guilty of these gnuplot hacks myself and they always st…

> They always stick around way longer than they should...

But isn't that true for all 'terrible' code? Most of the elegant and well-formed code I write ends up getting butchered for the sake of 'features,' while the quick hacks that 'just work' stick around forever.

Re: What is the coolest thing you can do in ten lines of code?

#36
Coming late to the party, but Simon Tatham's .sig is pretty cool:

    for k in [pow(x,37,0x13AC59F3ECAC3127065A9) for x in [0x195A0BCE1C2F0310B43C,
    0x73A0CE584254AB23D5A0, 0x12878657EA814421CC92, 0x7373445BB3DA69996F4A,
    0x77A7ED5BC3AA700E80B2, 0xE9C71C94ED87ADCF7367, 0xFE920395F414C1A5DB50]]:
    print "".join([chr(32+3*((k>>x)&1))for x in range(79)]) # 
It won't be completely obvious to most people why this is cool, but it's effectively RSA-signed.

Re: What is the coolest thing you can do in ten lines of code?

#37
post #5

Less than 10 bytes of code on an Apple II: ] CALL -151 * 300: AD 30 CO 20 ED FD 4C 00 03 * 300G Enjoy! For bonus points, get this down to 8 bytes.

; initialize

  CALL -151
  1000:BA 8A A8 49 80 AA 9A A9 2 48 A9 FF 48 BA 86 6 98 AA 9A A6 6 A9 30 85 6 A9 C0 85 7 A0 0 0 N 1000G
; six bytes!

  300:9A B1 6 4C ED FD
  300G

Re: What is the coolest thing you can do in ten lines of code?

#38

A colleague of mine wrote a spreadsheet in one line (253 bytes) of BASIC. I wonder if I still have it somewhere ...

That's pretty interesting. What features did it offer? Just a grid of cells, or some crude facility for summing/counting rows and columns as well?

Re: What is the coolest thing you can do in ten lines of code?

#39
post #32

Is 30 close enough to 10? I got a job with 30 lines of code appended to my resume, with a screenshot of the resultant output. Perhaps the first two pages had something to do with it but I was told that the third page was what stood out. This was a sysadmin position, the code includes bash, sed, awk, grep, tcpdump, netcat and gnuplot. Hint to anyone who tries this sort of resume stunt: You WILL be asked what the code…

That's indeed an interesting example because, by any standard, this is terrible code. Yet for a sysadmin position it still provides valuable insight into your a) pain threshold, b) familiarity with the tools, c) willingness and ability to bend reality for the boss. I'd just add a big disclaimer that this kind of code only happens in emergencies. (disclaimer: I'm guilty of these gnuplot hacks myself and they always st…

That's indeed an interesting example because, by any standard, this is terrible code.

It's not nice to criticize without being constructive. Care to explain why the code is bad, and offer better suggestions?

Re: What is the coolest thing you can do in ten lines of code?

#40

A colleague of mine wrote a spreadsheet in one line (253 bytes) of BASIC. I wonder if I still have it somewhere ...

That's pretty interesting. What features did it offer? Just a grid of cells, or some crude facility for summing/counting rows and columns as well?

It was a grid of cells. Each cell could contain a constant or a formula, strings or numbers. You selected the cell to change with a mouse, and it recomputed once per click on a button. In essence it was fully functional, just lacking file load and save.

It didn't have charts or graphics, but the cell functionality was pretty complete. Using "EVAL" meant you had access to any function in the underlying language.

I'll see if I can dig it out.

Post reply on HN