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
evol262
Nov 30, 2010
#!/usr/bin/perl

Mustache Ride posted:

Its funny you should say that, because the 3 other guys in my department have mustaches. Except me. I shaved mine last year when I interviewed for this job and never grew it back.
You should go to Vegas with Rhythmic Crotch.
I respect what you're saying, and it's not falling on deaf ears. You just disagree with many of the people here.

Google and Redhat both do working interviews, among others (on docs or etherpad, remote). It's common. And it is a good way to weed out bad candidates or people who can talk the talk but not actually walk the walk, or people with impressive interviews who've failed upwards. But the terribleness of shell scripting aside, awful weeder tests like fizzbuzz, much as it's trivial (and well known), are not good indicators of whether or not someone will be a good developer.

We prefer having candidates read moderately complex code they haven't seen before in a language of their choice and describing what it does, but that's not appropriate for all companies. But as said, it's already an industry with too many absolutes, too many people who do badly under pressure, and too many :smug: young developers who think they're masters of the universe and arbiters of what's good. Not to say that candidates shouldn't be able to perform under pressure or deal with absolutes, but "do you understand this code?", and "can you modify this code?" are far more practical benchmarks than fizzbuzz or the stupid locker problem or binary linked lists. All of these are great for certain jobs, but "developer" is not "f22 pilot" or anything else with so narrow a definition.

You may not be able to do my job, nor I yours, nor either of us Ratbert's or Volmarius'. There's a lot of gradation, which should go into the interview. Please don't pretend it's one-size-fits-all. This is the push back you're getting.

Adbot
ADBOT LOVES YOU

Che Delilas
Nov 23, 2009
FREE TIBET WEED

SolTerrasa posted:

you are doing it right now

e: Seriously, how can you see a post which literally only says "no one can agree on what it is you need in order to be a developer.."

Your assertion was, literally, that in order to be a developer you need to be perfect. It's absurd. You don't get a free pass because you then acknowledge that nobody can agree on what qualifies one as a developer. It's a ridiculous statement no matter what field you're in. You think professional cooks have never overcooked an egg?

You keep trying to deflect to the truer statements that you've made. I keep harping on "you made a mistake so you aren't a developer" so violently because people getting into the industry read these threads and I don't want them to take that to heart. It's precisely the opposite of reality.

Laserface
Dec 24, 2004

There are two guys that both stink in my team and the WoW stars must have aligned because they both decided to not shower today and the whole place has that aggressive, nostril stinging stench to it.

For gently caress sake people, If I am expected to be 'presentable as if you are meeting a client' on a daily basis, you should be expected to not smell like cat piss and vomit mixed with battery acid.

Che Delilas
Nov 23, 2009
FREE TIBET WEED

Laserface posted:

There are two guys that both stink in my team and the WoW stars must have aligned because they both decided to not shower today and the whole place has that aggressive, nostril stinging stench to it.

For gently caress sake people, If I am expected to be 'presentable as if you are meeting a client' on a daily basis, you should be expected to not smell like cat piss and vomit mixed with battery acid.

The worst part about this is how that stench just hangs in the air and sticks to everything, including the walls of your nasal cavity. Had to deal with one of these guys back in college, and despite the fact he rarely left his room, he managed to keep an entire hallway of the dorm permanently fumigated. I took the long way to my own room to avoid passing through that hallway.

DrAlexanderTobacco
Jun 11, 2012

Help me find my true dharma
when I was in primary school we played fizzbuzz, it was a fun game

Am I a programmer



Edit: MessageLabs is such a piece of poo poo. Why we're migrating to it I don't know.

seadweller
Mar 30, 2010
Ahh Office 365, you are a breath of fresh air after Lotus Notes.

You even offer the ability to have text messages to alert users to the arrival of email:

http://www.techadvisory.org/2013/01/new-email-get-notified-by-text/

Let's get this set up, hmm the option isn't there - strange.

"Functionality at present only available in USA, Canada and ...... Romania." :argh:

ming-the-mazdaless
Nov 30, 2005

Whore funded horsepower

seadweller posted:

Ahh Office 365, you are a breath of fresh air after Lotus Notes.

You even offer the ability to have text messages to alert users to the arrival of email:

http://www.techadvisory.org/2013/01/new-email-get-notified-by-text/

Let's get this set up, hmm the option isn't there - strange.

"Functionality at present only available in USA, Canada and ...... Romania." :argh:

Which toss bag thought it'd be a great feature to text people about e-mail arrivals?

seadweller
Mar 30, 2010

ming-the-mazdaless posted:

Which toss bag thought it'd be a great feature to text people about e-mail arrivals?

Its a shared mailbox that gets probably 5 emails a week, a text message alert would be a good way to get them dealt with promptly. Its an academic requesting it to save them having to log in to the web client and open other mail! I don't have a problem telling them to check it themselves but was just frustrated by the seemingly random choice of Romania as a place to roll the functionality out, as I'm in the U.K.

dogstile
May 1, 2012

fucking clocks
how do they work?

DrAlexanderTobacco posted:

when I was in primary school we played fizzbuzz, it was a fun game

Am I a programmer

If they were literally just testing me on Fizzbuzz, I'm a great programmer. I haven't done any real scripting for a year (just batch files to run things a bit quicker and the odd learning here and there) and I sat down and spent five minutes writing it. It worked!

In the real world though, i'm a loving awful programmer and I have to look up syntax literally every time I try. But hey, fizzbuzz = great test!

E: Oh right, content:

What's annoying me today is that while i'm in the database of a client, I know exactly what needs changing, what it needs changing to and I know it'll work, i'm not actually allowed to make the changes.

This SQL stuff is fun. Why do they try and make people learn it in Oracle? I learned in Oracle and loving hated it.

bitterandtwisted
Sep 4, 2006




Most of our users' laptops are thin clients that can't save anything to the hard drive. When a user is suspended one of the higher level managers tells us to lock their laptops up pending the inquiry. Every time I patiently explain there is no point and other people need that laptop. Every time I get told to lock it away anyway. So it sits in the server room for months until she's forgotten about it and we quietly give it to someone else.

Same person locks herself out of the HR system by mistyping her password about once a month and angrily tells us to fix the system (which we didn't develop and don't manage).

Dr. Arbitrary
Mar 15, 2006

Bleak Gremlin
10 PRINT "1"
20 PRINT "2"
30 PRINT "FIZ"
40 PRINT "4"
50 PRINT "BUZZ"
...
1000 PRINT "BUZZ"
1010 END

I don't know why you guys are making such a big deal out of it, you just have to be a fast typer.

EAT THE EGGS RICOLA
May 29, 2008

What is the easiest way for me to log on to a couple thousand remote windows machines so that a script I need to run as a logged on user works correctly?

fluppet
Feb 10, 2009
psexec?

EAT THE EGGS RICOLA
May 29, 2008


I don't think that'll do it, I need to run this script while the other user is fully logged on and psexec will just run the single command as the user that I pass to it.

Sickening
Jul 16, 2007

Black summer was the best summer.

EAT THE EGGS RICOLA posted:

What is the easiest way for me to log on to a couple thousand remote windows machines so that a script I need to run as a logged on user works correctly?

pdqdeploy

EAT THE EGGS RICOLA
May 29, 2008


I am using PDQ Deploy to do this, but the user needs to be logged in (the packages make a ton of changes to HKCU). Everyone I work with is a Pretty VIP Princess and this has to be done after hours since the package requires a few reboots and it needs to be logged back in again after each reboot.

SubjectVerbObject
Jul 27, 2009
Pissing me off today: One of our customers has managed to mess up their environment royally, mainly by growing and adding resources without any plan, and working their knowledgeable people to the point that they quit. Of course since we are their maintenance provider, this is all our fault. They have raised enough hell that they nowhave an executive embedded with them who is second guessing all of our work, and far today I have received different directives on what I should be focusing on from my manager, the executive, the service manager, and tier 1. There are additional directors and managers that I expect will be chiming in soon. In the meantime, we are still down people, about to lose someone for a while, and the company things they can make this up by hiring contractors, most of whom are close to retirement and have 30 years experience with stuff that is end of life 5 years ago.

And while I am writing this another manager is iming me with a different thing to focus on.

sfwarlock
Aug 11, 2007

ratbert90 posted:


Edit* The problem yesterday was this:

A^2 + B^2 == C^2
A + B + C == 1000
A < B < C

Find the combination that meets all 3 of those conditions.

I got bored enough to do this.


#include <stdio.h>

int main() {
int a,b,c;
for (b=0; b < 1000; ++b) {
for (a=0; a < b; ++a) {
c = 1000 - (a+b);
if ((b < c) && (a*a + b*b == c*c)) {
printf("a: %d \t b: %d \t c: %d\n",a,b,c);
}
}
}
return 0;
}

canis minor
May 4, 2011

I'm currently integrating n-th website with social/commerce capabilities (integrating as - for given HTML template I'm filling in the blanks of displaying dynamic content). Like all the websites before (and me whining about it) this one doesn't cater for the content not existing for given thing. Oh, admin created a page without an image? gently caress you, gently caress the layout. There's no pages in given section? gently caress you, no - everything will gently caress up! User created a thing and didn't put an optional title - gently caress NO, screw this poo poo! Sometimes I'm thinking that people providing templates for these things are brain dead.

This wouldn't grind my gears so much if it was first website, where you can not think about certain things, but I think I'm half way to triple digits by now.

edit; jesus loving christ, this is about people that can't get into their loving heads to put a prefix to every class uses js. I think I'll start looking for new job because it's becoming too much...

canis minor fucked around with this message at 16:30 on May 22, 2014

meanieface
Mar 27, 2012

During times of universal deceit, telling the truth becomes a revolutionary act.
Pissing me off: coworkers.

If I walk into your cube and you see me and turn your back to me because -phone call-, then I walk back and send you an IM, there's a non-negligible chance that I'm trying to give you additional information on the issue you're troubleshooting.

Of course, that realization would require some respect for me.

:yotj: needs to happen.

Cenodoxus
Mar 29, 2012

while [[ true ]] ; do
    pour()
done


SubjectVerbObject posted:

They have raised enough hell that they nowhave an executive embedded with them who is second guessing all of our work, and far today I have received different directives on what I should be focusing on from my manager, the executive, the service manager, and tier 1. There are additional directors and managers that I expect will be chiming in soon.
...
And while I am writing this another manager is iming me with a different thing to focus on.

Be firm in telling them that they need to coordinate with your manager, not you. Only do what your manager tells you to, because at the end of the day they are the person who ultimately decides who or what needs your attention the most. All of this "I've been here 20 years so I have clout and can tell anyone what to do" or "I'm a :siren:LEAD SENIOR EXECUTIVE DEPARTMENT MANAGER:siren: do my bidding you peons" bullshit is tacky and childish, and gets nothing done but stroke one's own ego.

Everybody who doesn't do your annual review can go through the chain of command or kindly :fuckoff:

FlapYoJacks
Feb 12, 2009

sfwarlock posted:

I got bored enough to do this.


#include <stdio.h>

int main() {
int a,b,c;
for (b=0; b < 1000; ++b) {
for (a=0; a < b; ++a) {
c = 1000 - (a+b);
if ((b < c) && (a*a + b*b == c*c)) {
printf("a: %d \t b: %d \t c: %d\n",a,b,c);
}
}
}
return 0;
}



I wrote it like this:

C++ code:

void Check_Theorem(int A, int B, int C)
{
	if (( A * A) + ( B * B )  == ( C * C ))
	{
            if ((A + B + C) == 1000 )
	    {
                printf("Answer is: A = %i, B = %i, C = %i\n", A, B, C);
                exit(0);
	    }
	}
}



int main (void)
{
	int a = 0, b = 0, c = 0;
	for ( c=100; c<500; c++ ) 
	{
		printf("%i\n", c);
		Check_Theorem(a,b,c);
		for ( b=0; b<c; b++ )
		{
			Check_Theorem(a,b,c);
			for ( a=0; a<b; a++ ) 
			{
				Check_Theorem(a,b,c);
			}
		}
	}
	return 0;
}


Python code:
#@Brief: Checks the Theorem and challenge conditions.
#@Params: A B and C.
#@Retval: None if the the calculation did not pass all required parameters, exit 0 on success.
def Check_Theorem(A, B, C):
    if ((A * A) + (B * B) == ( C * C)):
        if A+B+C == 1000:
            if (( A < B and B < C)):
                print("Answer is: A = %i, B = %i, C = %i"% ( A, B, C))
                exit(0)


#@Brief: Starting at 100 and going to 500
#        Keeping A < B < C  and passes those numbers to Check_Therom.
#@Params: None.
#@Retval: -1 on no answer found.
a,b,c = 0,0,0
#Start at 100, as there is no way it could be lower.
for c in range (100 , 1000 ):
    Check_Theorem(a, b, c)
    for b in range (1, c):
        Check_Theorem(a, b, c)
        for a in range (0, b):
            Check_Theorem(a, b, c)
exit(-1)
Bash code:
#!/bin/bash




#@Brief: Checks the Theorem and challenge conditions.
#@Params: A B and C.
#@Retval: None if the the calculation did not pass all required parameters, exit 0 on success.
Check_Theorem()
{
    ADD=$((${1} + ${2} + ${3}))
    A=$((${1} * ${1}))
    B=$((${2} * ${2}))
    C=$((${3} * ${3}))
    PRE=$((${A} + ${B}))
    if [[ ${PRE} == ${C} ]]; then
        if [[ ${ADD} == "1000" ]]; then
            if [[ "${A}" -lt "${B}" && "${B}" -lt "${C}" ]]; then
                echo "Answer is: A = ${1}, B = ${2}, C = ${3}"
                exit 0
			fi
		fi
	fi
}




#@Brief: Starting at 100 and going to 500
#        Keeping A < B < C  and passes those numbers to Check_Therom.
#@Params: None.
#@Retval: -1 on no answer found.
a="0"; b="0"; c="0"
#Start at 100, as there is no way it could be lower.
for (( c=100; c<1000; c++ )) do
	echo ${c}
    Check_Theorem ${a} ${b} ${c}
    for (( b=0; b<${c}; b++ )); do
		Check_Theorem ${a} ${b} ${c}
		for (( a=0; a<${b}; a++ )); do
			Check_Theorem ${a} ${b} ${c}
		done
	done
done

return -1

SubjectVerbObject
Jul 27, 2009

Cenodoxus posted:

Be firm in telling them that they need to coordinate with your manager, not you. Only do what your manager tells you to, because at the end of the day they are the person who ultimately decides who or what needs your attention the most. All of this "I've been here 20 years so I have clout and can tell anyone what to do" or "I'm a :siren:LEAD SENIOR EXECUTIVE DEPARTMENT MANAGER:siren: do my bidding you peons" bullshit is tacky and childish, and gets nothing done but stroke one's own ego.

Everybody who doesn't do your annual review can go through the chain of command or kindly :fuckoff:

Unfortunately my manager is at the hospital with a sick friend, so half of the people are trying to 'help' because she is away, and the other half are CC'ing her and making her get involved when she should be with her friend. And the people above manager that are involved are in my direct chain of command. In the past year they have added multiple layers of management whose only job is to look at reports and ask you why your tickets are not updated and why tickets are sitting unassigned.

The problem is they all have a point. I am not meeting the metrics. I have old cases that have been open too long. I have new cases I need to pick up and focus on due to escalations, and I have things I haven't statused in the past 2 days because I have been dealing with stuff on fire. At this point, I have 20 tickets, and spending any time working on one gets me in trouble with the other 19. I am not able to say that the metrics are wrong, because they hired a bunch of people and spend money developing the processes and metrics, and folks get very defensive regarding the way things are.

Dick Trauma
Nov 30, 2007

God damn it, you've got to be kind.
I saw a board presentation yesterday that showed our org chart and my box has been moved all the way to the bottom by itself, so far down that the lower half is cut off.

DrAlexanderTobacco
Jun 11, 2012

Help me find my true dharma

SubjectVerbObject posted:

Unfortunately my manager is at the hospital with a sick friend, so half of the people are trying to 'help' because she is away, and the other half are CC'ing her and making her get involved when she should be with her friend. And the people above manager that are involved are in my direct chain of command. In the past year they have added multiple layers of management whose only job is to look at reports and ask you why your tickets are not updated and why tickets are sitting unassigned.

The problem is they all have a point. I am not meeting the metrics. I have old cases that have been open too long. I have new cases I need to pick up and focus on due to escalations, and I have things I haven't statused in the past 2 days because I have been dealing with stuff on fire. At this point, I have 20 tickets, and spending any time working on one gets me in trouble with the other 19. I am not able to say that the metrics are wrong, because they hired a bunch of people and spend money developing the processes and metrics, and folks get very defensive regarding the way things are.

Can you make a case that you're working 100%, that you're not slacking - That you're overworked? Better yet, do you track your time spent in the ticketing system?

MC Fruit Stripe
Nov 26, 2002

around and around we go

Dick Trauma posted:

I saw a board presentation yesterday that showed our org chart and my box has been moved all the way to the bottom by itself, so far down that the lower half is cut off.
You get a box? Lucky.

Inspector_666
Oct 7, 2003

benny with the good hair
I've never worked at a place that had an org chart.

Dick Trauma
Nov 30, 2007

God damn it, you've got to be kind.

MC Fruit Stripe posted:

You get a box? Lucky.

Aye. In them days, we'd a' been glad to have the price of a cup o' tea.

spog
Aug 7, 2004

It's your own bloody fault.

MC Fruit Stripe posted:

You get a box? Lucky.

The best feeling in the world is when you notice that you don't appear on the org chart - therefore you can deny being subordinate to every single person who tries to dumpcrap on you.

GanjamonII
Mar 24, 2001

spog posted:

The best feeling in the world is when you notice that you don't appear on the org chart - therefore you can deny being subordinate to every single person who tries to dumpcrap on you.

In my experience the opposite is true. You're not important enough to merit a box therefore everyone who does expects you will take direction from them.

In things pissing me off today: Scope creep. 2 1/2 weeks into a 4 week project PM asks me to do about 4x the work as originally planned. My fault I think for not getting scope in writing at the start. Goodbye memorial day, and probably weekend too.

GanjamonII fucked around with this message at 17:25 on May 22, 2014

canis minor
May 4, 2011

spog posted:

The best feeling in the world is when you notice that you don't appear on the org chart - therefore you can deny being subordinate to every single person who tries to dumpcrap on you.

My brother alone is 3 departments, the last time I heard :ohdear:

Sickening
Jul 16, 2007

Black summer was the best summer.

GanjamonII posted:

In my experience the opposite is true. You're not important enough to merit a box there everyone who does expects you will take direction from them.

In things pissing me off today: Scope creep. 2 1/2 weeks into a 4 week project PM asks me to do about 4x the work as originally planned. My fault I think for not getting scope in writing at the start. Goodbye memorial day, and probably weekend too.

One of the great skills of this industry is to learn to stand up for yourself. Have you spoken this pm about the work being 4x the amount? Did you ask for more time to do these duties?

SubjectVerbObject
Jul 27, 2009

DrAlexanderTobacco posted:

Can you make a case that you're working 100%, that you're not slacking - That you're overworked? Better yet, do you track your time spent in the ticketing system?

The problem at this point is that we are no longer engineers responsible for fixing issues, were are ticket monkeys responsible for following processes. It their mind, if processes are followed, there should be no issue.

I'm leaving out a lot for brevity and to hide details, but things might come to a head at some point, and they will have to decide if people or processes are important.

GanjamonII
Mar 24, 2001

Sickening posted:

One of the great skills of this industry is to learn to stand up for yourself. Have you spoken this pm about the work being 4x the amount? Did you ask for more time to do these duties?

Yeah, upon further conversation it looks like it was a misunderstanding of scope in the first place rather than scope creep. I'll do what I can to deliver, but there is no way the whole thing is going to be ready.

Sickening
Jul 16, 2007

Black summer was the best summer.

GanjamonII posted:

Yeah, upon further conversation it looks like it was a misunderstanding of scope in the first place rather than scope creep. I'll do what I can to deliver, but there is no way the whole thing is going to be ready.

Are you the only person working this weekend or the holiday on this one?

mewse
May 2, 2006

Dick Trauma posted:

I saw a board presentation yesterday that showed our org chart and my box has been moved all the way to the bottom by itself, so far down that the lower half is cut off.

At least you have your stapler?

evol262
Nov 30, 2010
#!/usr/bin/perl

ratbert90 posted:

Python code:
#@Brief: Checks the Theorem and challenge conditions.
#@Params: A B and C.
#@Retval: None if the the calculation did not pass all required parameters, exit 0 on success.
def Check_Theorem(A, B, C):
    if ((A * A) + (B * B) == ( C * C)):
        if A+B+C == 1000:
            if (( A < B and B < C)):
                print("Answer is: A = %i, B = %i, C = %i"% ( A, B, C))
                exit(0)


#@Brief: Starting at 100 and going to 500
#        Keeping A < B < C  and passes those numbers to Check_Therom.
#@Params: None.
#@Retval: -1 on no answer found.
a,b,c = 0,0,0
#Start at 100, as there is no way it could be lower.
for c in range (100 , 1000 ):
    Check_Theorem(a, b, c)
    for b in range (1, c):
        Check_Theorem(a, b, c)
        for a in range (0, b):
            Check_Theorem(a, b, c)
exit(-1)

I know you're probably not really a Python dev, but this is super painful to look at.

No upper case function names. Unnecessary spaces, missing spaces, range instead of xrange, unnecessary parenthesis, capitalized non-constant variable names. Please use pep8.

That aside, it's possible to get this really, really fast pretty trivially.

Python code:
import timeit

def clever():
    for n in xrange(1, 500):
        for m in xrange(n + 1, 500):
            a = m*m - n*n
            b = 2 * m * n
            c = m*m + n*n
            if a + b + c == 1000 and (a*a + b*b == c*c):
                print "Clever: a = %d, b = %d, c = %d" % (a, b, c)
                break
    return True

def naive():
     for a in xrange(1,999):
        for b in xrange(a+1, 999-a):
            c = 1000 - (b + a)
            if a*a+b*b == c*c:
                print "Naive: a = %d, b = %d, c = %d" % (a, b, c)
                break
     return True

if __name__ == '__main__':
    print("Clever executed in %f seconds" %
           timeit.timeit(clever, number=1))
    print("Naive executed in %f seconds" %
           timeit.timeit(naive, number=1))
The first way is with Euclid's Formula (for pythagorean triples).

The second just on the given assumptions:
  • C can be determined from what a and b already are by subtracting from 1000, no need to loop
  • B is always larger than A, and there's no way that a+b+c can add up to more than 1000
This is about 100ms on my system.

The same in C:
C code:
#include <stdio.h>
#include <stdlib.h>

void main() {
        int a, b, c;
        for(a=1; a < 1000; a++) {
                for(b=a+1; b < 999-a; b++) {
                        c = 1000 - (b + a);
                        if ((a*a + b*b) == c*c) {
                                printf("Found a = %d, b = %d, c = %d\n", a, b, c);
                                exit(0);
                        }
                }
        }
}
Runs in 1ms. 1.

As it turns out, project euler may actually make reasonably good interview questions...

FlapYoJacks
Feb 12, 2009

evol262 posted:

I know you're probably not really a Python dev, but this is super painful to look at.
I work with C all day. :v:

quote:

No upper case function names.
function names shouldn't be upper case. :colbert:

quote:

Unnecessary spaces
You mean returns? In C I use 4 spaces between function names, it looks consistent and it's easier to read. :v:

quote:

missing spaces, range instead of xrange
I didn't even know xrange existed. :v:

quote:

unnecessary parenthesis,
Good to know, I forget that python doesn't need a bunch of parenthesis. :v:

quote:

capitalized non-constant variable names.
Non local variables must be capitalized. Local variables are lowercase. :colbert:

quote:

Please use pep8.
A standard I am not familiar with, and I will learn. Thanks!


quote:

That aside, it's possible to get this really, really fast pretty trivially.

Python code:
import timeit

def clever():
    for n in xrange(1, 500):
        for m in xrange(n + 1, 500):
            a = m*m - n*n
            b = 2 * m * n
            c = m*m + n*n
            if a + b + c == 1000 and (a*a + b*b == c*c):
                print "Clever: a = %d, b = %d, c = %d" % (a, b, c)
                break
    return True

def naive():
     for a in xrange(1,999):
        for b in xrange(a+1, 999-a):
            c = 1000 - (b + a)
            if a*a+b*b == c*c:
                print "Naive: a = %d, b = %d, c = %d" % (a, b, c)
                break
     return True

if __name__ == '__main__':
    print("Clever executed in %f seconds" %
           timeit.timeit(clever, number=1))
    print("Naive executed in %f seconds" %
           timeit.timeit(naive, number=1))

That is really neat! I was trying to just brute force it, but that is really really cool.

dogstile
May 1, 2012

fucking clocks
how do they work?
The more I learn about code, the less I know about code.

-------------------------------

In other news, i'm working from home tonight, first time they've trusted me to do work from home. Except my manager didn't know that I was booked to work from home tonight and I have a feeling he's only letting me do it because I told him an hour before we left so there was no time to rearrange. gently caress yeah, easy overtime.

Adbot
ADBOT LOVES YOU

evol262
Nov 30, 2010
#!/usr/bin/perl

ratbert90 posted:

I work with C all day. :v:

function names shouldn't be upper case. :colbert:

You mean returns? In C I use 4 spaces between function names, it looks consistent and it's easier to read. :v:

I didn't even know xrange existed. :v:

Good to know, I forget that python doesn't need a bunch of parenthesis. :v:

Non local variables must be capitalized. Local variables are lowercase. :colbert:

A standard I am not familiar with, and I will learn. Thanks!


That is really neat! I was trying to just brute force it, but that is really really cool.

You should visit the python thread! Not really appropriate here.

I commented on the function name not because it should be uppercase, but because yours was.

pep8 is basically a linter for official python standards. For example, putting spaces after commas where there are arguments but not spaces before parentehsis.

some_function(a,b) <- bad
some_function(a, b ) <- bad
some_function( a, b) <- bad
some_function(a, b) <- good

pep8 checks all these things for you and says "on line X, you violated this PEP# by doing this"

xrange goes away in python3, but not many people are using that yet...

But you should also look at variable scoping. It doesn't work the way you think it does, judging by the "non-local variable" bit, even in C:

Python code:
a = 1
def main(a):
    print(a)
if __name__ == '__main__':
    print a
    main(2)
    print a
C code:
#include <stdio.h>

void x(int a) {
        printf("%d\n",a);
}

int main() {
        int a = 3;
        printf("%d\n", a);
        x(2);
        printf("%d\n", a);
        return 0;
}
The difference is that in python, you can't even modify it. The function closure creates a new scope.
Python code:
a = 1
def main():
    a=2
    print(a)
if __name__ == '__main__':
    print a
    main()
    print a
Unless you:
Python code:
a = 1
def main():
    global a
    a=2
    print(a)
if __name__ == '__main__':
    print a
    main()
    print a
To the Python thread with you, and no more derailing from me

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