News for hackers. Stuff that matters.

mudbungie

Re:Do men or women have more brothers? on Monday May 23, 2016 @05:44PM (#11757295)
I like your solution! Good use of iter().

You actually bring up an interesting question of design philosophies. I thought that the script that I posted was extremely explicit, and therefore clear. Yours is far more terse, and implicit, which means that there's less to understand, but there is some onus on the reader to decode what is happening.

I'm not sure which is better, as a policy. Obviously, solving problems with fewer lines is desirable, but it's also good to make solutions that are intrinsically obvious.

Re:Do men or women have more brothers? on Monday May 23, 2016 @05:12PM (#11757042)
Yeah, I wrote that after staring at it for a few minutes, and giving up any pretense that I could model it with confidence.
Re:Do men or women have more brothers? on Monday May 23, 2016 @05:04PM (#11756969)
Actually, line 46 is referencing the class Girl, so you wouldn't want quotes. Technically, you're supposed to use try/except duck-typing in Python, but I often find that clearer code comes out of assertions where you literally check the type of an object instead of handling errors. This was no exception. (Sorry, bad pun)

You might try throwing in a random seed. I just trusted that my system would iterate enough that it wouldn't matter, but if you're getting all boys (I'm not sure that's the case, but you said that you're getting 0 girls...), it could be that for whatever reason, the system might not be advancing the seed. Try inserting the following two lines immediately after import random:

from datetime import datetime

random.seed(datetime.now())

Re:Do men or women have more brothers? on Monday May 23, 2016 @03:59PM (#11756444)
I chose to answer the question empirically. http://pastebin.com/1g1bAEPt Turns out it's equal.