Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
chips
Dec 25, 2004
Mein Führer! I can walk!

Scaevolus posted:





The first part of someone's solution:
code:
#First load the file and sort it.
x = eval( '[' + open( '.../names.txt' ).readlines()[ 0 ] + ']' )
x.sort()
On principle, using eval is always wrong.

I dont think it's really fair to complain about software engineering rights and wrongs in projecteuler answers. I thought it was a reasonable way to get everything in rapidly - not like there was going to be a code injection attack in the middle of it (and maybe he even checked)

Adbot
ADBOT LOVES YOU

chips
Dec 25, 2004
Mein Führer! I can walk!
For some reason when I did problem 17 on eulerproject, I decided to do this for teens:

code:
if($n == 11) $output .=  "eleven\n";
else if($n == 12) $output .=  "twelve\n";
else if($n == 13) $output .=  "thirteen\n";
else if($n == 15) $output .=  "fifteen\n";
else if($n > 12 && $n < 20) $output .=  str_replace("tt", "t", $numbers[$n % 10] . "teen") . "\n";
else $output .=  $tens[$n / 10] . " " . $numbers[$n % 10] . "\n"; 
I'm sure it made sense at the time, except it takes up more space.

To contribute something other than my lovely code - the Fortran code I'm seeing as a vacation student in a physics department makes me cringe. Maybe I'm just too dumb to understand what the indecipherable variable names are for (given that all the code is in a single function anyway, all 12 pages or so), or understand the flow given the complete lack of comments.

chips
Dec 25, 2004
Mein Führer! I can walk!
Who are Dmitry and Sara why are they allowed near PHP?

edit: Ok I do sometimes use goto in C++ :(

chips
Dec 25, 2004
Mein Führer! I can walk!

Bhaal posted:

If you have complex resource building that can fail at multiple points and requires multiple cleanup, it's probably not a good idea to try and house the whole drat thing in one scope. Here's that same logic broken into functions. It has some early returns but if that's an issue we all know ways to solve it, I'm just being lazy.

Obviously you can have much more meaningful function names, but with this you can more easily abstract the surrounding logical branching of where you're at and just focus on one segment at a time. (This would also be one of those times to write a function that you know will only ever get called in a single place).

If stage 3 construction fails, how does stage 2 cleanup happen? I suppose

code:
if ( ... || !build_3rd_stage(...))
  {
    cleanup2();
  }
Works, right?

chips
Dec 25, 2004
Mein Führer! I can walk!
Sorry guys but I'm out, you're cramping my style.

http://www.newscientist.com/article/mg20327195.600-breaking-down-social-networks-could-foster-innovation.html

chips
Dec 25, 2004
Mein Führer! I can walk!

Mustach posted:

Here's some more barrels from our UI code:
code:
/**
 *
 * Not implemented
 *
 */
public void showTitle(String title, int thing)
{
    showTitle(title, thing);
}
Elsewhere...
code:
try
{
    somebody.showTitle(title, thing);
    // etc...
}
catch(Throwable t)
{
    logger.log("Error while blah-di-dah: ", t);
}

Does this deliberately cause a stack depth exception of some kind?

chips
Dec 25, 2004
Mein Führer! I can walk!

tombom posted:

I'm sure this has been posted somewhere around here before, but I haven't seen it.
Spectate Swamp Desktop Search It kind of speaks for itself. He posts a lot and it seems he writes code like this professionally.

SpectateSwamp posted:

Keep going with your Search. The big players in desktop search just don't get it. What sorta works for billions of web pages doesn't when matched up against SSDS. And random is key. If you had tons of family pictures you'd realize the importance. If you had thousands of video clips you would know. I sometimes forget that few, if any of you have or use video to the degree that I do. I probably keep more notes that the rest of you too. Because it's easy for me. SSDS allows me to backup 1 folder and have all my valuable data secure. With secure data. I don't worry about anything.

SSDS code may be not so perfect when it comes to coding standards. But as some of us know, that doesn't matter an iota. If it isn't broke don't fix it. Don't look a gift horse in the mouth. So many of the old adages hold true here. Sharing your imperfect source is brave of you. Good going.

I don't know the full context of this, but he seems hilarious. A search engine that returns random results? How useful

Adbot
ADBOT LOVES YOU

chips
Dec 25, 2004
Mein Führer! I can walk!
Here he has a screencast that explains how to set up the Visual Basic 5.0 project for SSDS

Rather than just distributing the VB project files.

http://video.google.ca/videoplay?docid=-7589648200316339053

chips fucked around with this message at 22:59 on Jan 1, 2010

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply