|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On May 12 2013 05:51 CatNzHat wrote:Show nested quote +On May 12 2013 04:49 bangsholt wrote:Suppose you have read this python doc, so yes, it should be random. Just remember that we in general are very bad at understanding random. For the purposes of the game, python random will work fine. It's not like SecureRandom in Java, if you want to learn more about random number generators and their various levels of security (how random they actually are, what they use for seeds, etc..) then ask away.
I have no immediate questions about random seeds since I haven't really read about it but I am just wondering why are there different numbers on the weighted_choices list from the website I linked to? Is it just a number or some indication that Green is going to occur more often?
|
My experiences at work recently has got me wondering a little about how the culture is at other companies with regard to overtime. My company in particular is GENERALLY very laid back in this respect, I do not think a lot of my coworkers work an actual 40 hours let alone any overtime. I have even heard from many sources that the main two sites (I work at a smaller 3rd site) have an even far more prominant "culture of laziness". There are a few pockets of exceptions, my little task being an exception. My task lead is a workaholic and expects everyone in the group to average at least 50 hours a week (he does more). Now the part I actually start wondering is where he claims that working 40 hours a week will get to nowhere at any company, and in most software companies 50 hours is like the average. I understand at the big names like Google, Microsoft, you will be regularly working 50-60 hours and more during crunch times (and are compensated accordingly), but I wondered how generally this applied to the masses of companies. I should mention that my company doesn't actually sell any products per se, we are federally funded, and we provide mostly research knowledge and sometimes prototype software. So what's the culture at your companies?
|
On May 12 2013 06:02 GunSec wrote:Show nested quote +On May 12 2013 05:51 CatNzHat wrote:On May 12 2013 04:49 bangsholt wrote:Suppose you have read this python doc, so yes, it should be random. Just remember that we in general are very bad at understanding random. For the purposes of the game, python random will work fine. It's not like SecureRandom in Java, if you want to learn more about random number generators and their various levels of security (how random they actually are, what they use for seeds, etc..) then ask away. I have no immediate questions about random seeds since I haven't really read about it but I am just wondering why are there different numbers on the weighted_choices list from the website I linked to? Is it just a number or some indication that Green is going to occur more often?
Why did you rename your variables from the original example to make it more confusing? It is a little tricky as is, but with your changes (reusing the same variable name for 2 different things in the same line) makes it even more confusing. The example was:
>>> weighted_choices = [('Red', 3), ('Blue', 2), ('Yellow', 1), ('Green', 4)] >>> population = [val for val, cnt in weighted_choices for i in range(cnt)] >>> random.choice(population)
The weighted_choices array is an array tuples which represent your objects and and the number (cnt) of each. From that you build a "population", the population being the balls (3 Red, 2 Blue, etc.). The expression for population is a little confusing, but you can see what it actually builds by simply doing something like:
import random def test(): weighted_choices = [('Red', 3), ('Blue', 2), ('Yellow', 1), ('Green', 4)] population = [val for val, cnt in weighted_choices for i in range(cnt)] print population print random.choice(population)
test() test() test() test()
Which gave me:
['Red', 'Red', 'Red', 'Blue', 'Blue', 'Yellow', 'Green', 'Green', 'Green', 'Green'] Blue ['Red', 'Red', 'Red', 'Blue', 'Blue', 'Yellow', 'Green', 'Green', 'Green', 'Green'] Green ['Red', 'Red', 'Red', 'Blue', 'Blue', 'Yellow', 'Green', 'Green', 'Green', 'Green'] Green ['Red', 'Red', 'Red', 'Blue', 'Blue', 'Yellow', 'Green', 'Green', 'Green', 'Green'] Blue
Which helps me see that the numbers correspond to the number of each color, which means green will have a 4/10 chance of being picked since random.choice seems like it should choose each option in the list with equal probability.
Running it again in a fresh interpreter gives me:
['Red', 'Red', 'Red', 'Blue', 'Blue', 'Yellow', 'Green', 'Green', 'Green', 'Green'] Blue ['Red', 'Red', 'Red', 'Blue', 'Blue', 'Yellow', 'Green', 'Green', 'Green', 'Green'] Blue ['Red', 'Red', 'Red', 'Blue', 'Blue', 'Yellow', 'Green', 'Green', 'Green', 'Green'] Blue ['Red', 'Red', 'Red', 'Blue', 'Blue', 'Yellow', 'Green', 'Green', 'Green', 'Green'] Yellow
Which seems to indicate the seed is not the same every time (at least in this interpreter -- I'm using codepad.org since I'm too lazy to hop on my dev machine).
From here I would look at the syntax of the population expression to see if I can convince myself I understand it and tweak it to see what happens in order to make sure I really do understand it.
Popping something into the interpreter and simply seeing what it does should become second nature whenever you are confused with some new language feature.
So the takeaway is: use friendly variable names (and don't change them from your example when you don't understand what they are actually doing) and the interpreter is your friend.
edit: Also try not tot be so self-conscious about failing at programming, it is a huge impediment to learning. You should post here what you have trouble with.
|
On May 12 2013 06:14 waxypants wrote:Now the part I actually start wondering is where he claims that working 40 hours a week will get to nowhere at any company, and in most software companies 50 hours is like the average. I understand at the big names like Google, Microsoft, you will be regularly working 50-60 hours and more during crunch times (and are compensated accordingly), but I wondered how generally this applied to the masses of companies. I should mention that my company doesn't actually sell any products per se, we are federally funded, and we provide mostly research knowledge and sometimes prototype software. So what's the culture at your companies? Just a point of clarification here, 50-60 hours is rare at Amazon, Facebook, Google, Microsoft, etc.
Well, back that up and preface it a bit: depends on the person. There are definitely people at the big name companies that work a looooootttttt. You get those random work-related emails and code reviews coming in from some people at like 11pm. And there are some teams that will have serious crunch time.
But that's the exception rather than the rule. For the most part it's a pretty good work-life balance. 35-45 hours is normal. Once you get into the 50-60 hours, you start hitting diminishing returns pretty damn fast. It's much better to have 30-40 productive hours a week and then go home & recharge. This shit is hard to do, you can burn out really fast by keeping your brain running full tilt for too long.
There are also some areas and types of companies where people work a lot more on average. For example, game development.
Your tech lead sounds like a bad influence I've had tech leads who are total workaholics. However they've been pretty damn good about making sure we realize that they're just workaholics. They didn't expect the rest of us to put in those kinds of crazy hours.
|
I'd say it's bullshit. You want to be willing to put in extra hours during critical periods, but you don't need to work 60 hour weeks. I've worked 14 hour days before to meet deadlines, but that then means you get to take an early weekend if you'd like (or not and keep the overtime, but I get flat time ). The fact that you went beyond what is normal gets noticed at a decent company.
If you're at a shitty company then it really doesn't matter what you do.
|
On May 11 2013 11:18 Release wrote: In light of recent discussion in this thread, is a computer science bachelor degree worth pursuing if I'm interested in programming in the future? Or should I major in something else (finance/engineering for example) and program on my own time? major in CS if you want a career in programming, you will learn so much so quickly this way. It can be done on your own, but if you were confident enough in your ability to do it on your own you wouldn't have asked.
|
Hyrule18982 Posts
On May 12 2013 05:20 phar wrote:Show nested quote +On May 12 2013 04:42 GunSec wrote:btw, I am also wondering if I can pm some of the moderators of this thread or the creator? I have some personal stuff I want to talk about in programming and computer science in general  ! Don't think many mods or the creator post here often... Many here could probably field answers, but it's hard to say exactly without knowing what your line of questioning is about. I don't post often but I try to read every post 
I've replied to GunSec's PM already ^^
|
Can you make one specific exception catch in C++, and one general?
Like:
random code
int c = a/b; if ( b == 0) throw dividebyzero;
random code
catch ( dividebyzero ) cout << "Can't divide by zero"; catch ( ... ) cout << "Something went wrong";
So if there's a throw statement that's not dividebyzero, you will just get something went wrong?
|
|
On May 12 2013 06:14 waxypants wrote: My experiences at work recently has got me wondering a little about how the culture is at other companies with regard to overtime. My company in particular is GENERALLY very laid back in this respect, I do not think a lot of my coworkers work an actual 40 hours let alone any overtime. I have even heard from many sources that the main two sites (I work at a smaller 3rd site) have an even far more prominant "culture of laziness". There are a few pockets of exceptions, my little task being an exception. My task lead is a workaholic and expects everyone in the group to average at least 50 hours a week (he does more). Now the part I actually start wondering is where he claims that working 40 hours a week will get to nowhere at any company, and in most software companies 50 hours is like the average. I understand at the big names like Google, Microsoft, you will be regularly working 50-60 hours and more during crunch times (and are compensated accordingly), but I wondered how generally this applied to the masses of companies. I should mention that my company doesn't actually sell any products per se, we are federally funded, and we provide mostly research knowledge and sometimes prototype software. So what's the culture at your companies?
We have flexi where I work, the only real 'culture' is most people don't take the mandatory 30 minute lunch. Beyond that most people work a standard 35-40 hour week.
Some weeks people work more, especially when a release is coming up and people can work up to a 70 hour week, generally though its only those with responsibility for the release, and its a very small company, about 50 people only 20 or so in software, and those instances are very rare. If someone generally does work like that, post release they'll use the flexi they built up, our core hours are 10-2 and 2-4 so doing a few weeks of 10-4 actually works out quite nice.
So yea, our general culture is that noone expects you to work more than the standard 35-40 hour week. You are expected to pull your weight if things require it, but you're fully entitled to slow down after and work off your built up hours.
As I said though we are a small company, as far as the software team goes only me and one other guy are in our 20s, most people are at least late 30s if not 40s / 50s so maybe the culture is different because of that.
|
On May 12 2013 18:43 Arnstein wrote:Can you make one specific exception catch in C++, and one general? Like: random code
int c = a/b; if ( b == 0) throw dividebyzero;
random code
catch ( dividebyzero ) cout << "Can't divide by zero"; catch ( ... ) cout << "Something went wrong";
So if there's a throw statement that's not dividebyzero, you will just get something went wrong?
It is possible. However, you should make the verification b==0 before dividing, not after. + Show Spoiler + int b=1;//b=0; int a=2; try{ if (b==0) throw DivideByZero(); int c=a/b; throw exception(); }catch (DivideByZero e) { cout<<"cant divide by zero"<<endl; } catch(...) { cout<<"unforeseen error"<<endl; }
|
On May 12 2013 20:36 misirlou wrote:Show nested quote +On May 12 2013 18:43 Arnstein wrote:Can you make one specific exception catch in C++, and one general? Like: random code
int c = a/b; if ( b == 0) throw dividebyzero;
random code
catch ( dividebyzero ) cout << "Can't divide by zero"; catch ( ... ) cout << "Something went wrong";
So if there's a throw statement that's not dividebyzero, you will just get something went wrong? It is possible. However, you should make the verification b==0 before dividing, not after. + Show Spoiler + int b=1;//b=0; int a=2; try{ if (b==0) throw DivideByZero(); int c=a/b; throw exception(); }catch (DivideByZero e) { cout<<"cant divide by zero"<<endl; } catch(...) { cout<<"unforeseen error"<<endl; }
Thanks a lot!
|
What's so hard about the C++ syntax? It resembles Java a lot, sure cin/cout are a bit... weird, but that's ok
Alternatively, why do people say C++ is hard?
|
On May 13 2013 06:46 darkness wrote: What's so hard about the C++ syntax? It resembles Java a lot, sure cin/cout are a bit... weird, but that's ok
Alternatively, why do people say C++ is hard? C++ has a large amount of complexity and gotchas built up over the years, due to its attempts to be somewhat compatible with C and its evolution over time, and general propensity for including everything but the kitchen sink. There's a lot of "rules" and guidelines you should follow that aren't immediately obvious, especially to beginners. Java looks similar syntax-wise, but is much simpler and less powerful. There are benefits to this, in that its much harder to shoot yourself in the foot, but you do lose out on a lot of the power that C++ would give you.
|
On May 13 2013 08:00 tec27 wrote:Show nested quote +On May 13 2013 06:46 darkness wrote: What's so hard about the C++ syntax? It resembles Java a lot, sure cin/cout are a bit... weird, but that's ok
Alternatively, why do people say C++ is hard? C++ has a large amount of complexity and gotchas built up over the years, due to its attempts to be somewhat compatible with C and its evolution over time, and general propensity for including everything but the kitchen sink. There's a lot of "rules" and guidelines you should follow that aren't immediately obvious, especially to beginners. Java looks similar syntax-wise, but is much simpler and less powerful. There are benefits to this, in that its much harder to shoot yourself in the foot, but you do lose out on a lot of the power that C++ would give you. Yes. Just to add to this, Java compiles through a jvm or java virtual machine. Basically since it is in a virtual environment it has no interface to much of your operating system's hardware. It can't for instance get input from the speakers...
|
On May 13 2013 06:46 darkness wrote: What's so hard about the C++ syntax? It resembles Java a lot, sure cin/cout are a bit... weird, but that's ok
Alternatively, why do people say C++ is hard?
Firstly, Java resembles C++ a lot, not the other way round, though this is just being pedantic. It's not really the syntax which is confusing, it's because C++ can be a lot lower level and handle memory and such directly. It's also not garbage collected like Java, and less forgiving in its compiling (such as, though trivial, most compilers disallowing gets() and other unsafe functions, whilst Java will sort this automatically).
|
On May 13 2013 08:09 obesechicken13 wrote:Show nested quote +On May 13 2013 08:00 tec27 wrote:On May 13 2013 06:46 darkness wrote: What's so hard about the C++ syntax? It resembles Java a lot, sure cin/cout are a bit... weird, but that's ok
Alternatively, why do people say C++ is hard? C++ has a large amount of complexity and gotchas built up over the years, due to its attempts to be somewhat compatible with C and its evolution over time, and general propensity for including everything but the kitchen sink. There's a lot of "rules" and guidelines you should follow that aren't immediately obvious, especially to beginners. Java looks similar syntax-wise, but is much simpler and less powerful. There are benefits to this, in that its much harder to shoot yourself in the foot, but you do lose out on a lot of the power that C++ would give you. Yes. Just to add to this, Java compiles through a jvm or java virtual machine. Basically since it is in a virtual environment it has no interface to much of your operating system's hardware. It can't for instance get input from the speakers...
Although u can get input from speakers in C/C++ there is no much point to it
|
On May 13 2013 06:46 darkness wrote: What's so hard about the C++ syntax? It resembles Java a lot, sure cin/cout are a bit... weird, but that's ok
Alternatively, why do people say C++ is hard? C++ requires a lot of by-hand type handling and memory manipulation. There are also many ways to use the language poorly as a result of this, and as a result of quirky syntax and design decisions built up over years of the C++ committee making continual changes to the language.
|
Well, there is memory manipulation in C as well such as malloc, realloc and free. Is this the hard part or do you refer to destructor and/or harder memory management?
|
I'm learning Qt GUI programming with c++ and i want to create my own class which inherits from the class QPushButton. at the moment i tried just creating an empty class which inherits but doesnt add any new slots/signals.
my class definition:
class CoinButton : public QPushButton { public: CoinButton(); };
And somewhere in the code:
CoinButton but1 = new CoinButton("5 Dollars");
seeing as i didnt change anything from the parent class QPushButton shouldnt this work without a problem? It doesnt though. The Compiler complains "no matching fuction for call CoinButton::CoinButton[const char[10]]
QPushButton itsself would work fine like this:
QPushButton but1 = new QPushButton("5 Dollars");
Any QT experts around?
|
|
|
|