« first day (2088 days earlier)      last day (2875 days later) » 

6:00 PM
@PM2Ring ah yes that's what I've done before
 
@daOnlyBG probably some silly syntax error, or you put the wrong number into sqrt
except it can't be a syntax error
 
Here's what I had before the constraint
 
if it's long, consider using pastebin or a github gist
 
^^ pastebin
 
gotcha
 
6:02 PM
I was hoping you'd ask "what is too long" to which I'd have replied "whatever makes davidism bin your message"
 
lol
 
I feel like Andras is the sassy cousin of the SOPython room.
 
OK, so I entered it on pastebin
 
The one that gets all the good lines in a sitcom
 
6:03 PM
nah, that has to be Kevin
I'm only trying to stay afloat
 
Should I embed it here, or..?
 
Isn't he basically Chandler?
Just a link I reckon. oops, edited by accident.
 
@daOnlyBG You need to click the Fixed Font button, or hit Ctrl-k when posting code. Otherwise indentation gets lost. You have a couple of minutes to edit a post, and you can quickly retrieve your previous post by hitting the up arrow key.
 
6:05 PM
@PM2Ring Thanks
 
Did not know that.
 
For those who want to see it here:
    primes = [3]
    x = 5

    while(len(primes)<100):
        counter = 0
        for p in primes:
            if x%p != 0:
                counter += 1
        if counter == len(primes):
            primes.append(x)
        x += 2
 
@Withnail you should also check out directed replies and corresponding links/highlighting then:)
 
Cool, will do!
 
To add the constraint, though, I'm not exactly sure what I'd do. My intuition tells me to scrap the while loop and just add a "if...then" constraint
I tried the while loop initially but that got me stuck
 
6:10 PM
if you want minimal change, you need to break the for loop at around sqrt(x), but you need to rethink your condition for appending x then
actually, break could already help you a lot if you rethink your conditionals, without touching the ceiling of the for loop
(compare "let me see if all these primes are not divisors" with "let me see if any of these primes are divisors")
 
hm
 
@daOnlyBG What Andras just said. BTW, a "hand-made" loop using while and x += 2 is slower than using a range, since range does the arithmetic at C speed. But that will only make a minor speed difference compared to what you'll get by following Andras' hint.
 
I'm not sure I follow what Andras said
 
I'm intentionally being a bit vague, lest I rob you of the joy of problemsolving:)
I can be more direct if you wish
 
I think you're telling me to break when something happens, presumably when p^2 exceeds x, the number I'm testing
 
6:19 PM
@daOnlyBG well I originally told you that, but then I realized you're doing brute force very inefficiently
 
@daOnlyBG Maybe a concrete example will help. Is 1000005 prime?
 
no sir
 
@PM2Ring good idea:)
 
@daOnlyBG How many factors did you have to test to determine that?
 
1, I suppose
it's a multiple of both 3 and 5
(but 5 came to mind first)
 
6:21 PM
hey, does anyone know if beautiful soup runs asynchronously in python 2
 
So as soon as you've found 1 factor you can stop testing that number, and go onto the next.
 
oh hey- that makes sense. Thanks!
 
No worries!
 
I have a python script that basically does a lookup for the price of a textbook on amazon and then returns the price. it works well when run thru IDLE/terminal, but when I try to execute the script thru php echo exec("python file path $variables"); I only get a null value in return. I'd really appreciate some help lol
 
6:28 PM
@xxmbabanexx Please read the room rules. If you still don't have a satisfactory answer to your question in another day, then you may ask about it here.
 
hmm... I must have implemented it incorrectly
`primes = [2]

x = 3

while(len(primes)<10001):
    for p in primes:
        if x%p == 0:
            break
        else:
            primes.append(x)
    x += 2`
I don't think the break I added gets me out of the for p in primes loop
 
You only want to append x if you don't find a factor.
 
that counter might come in handy, maybe. let me try something else.
 
I suggest you change that 10001 to something smaller (eg 101 or 1001) while you're developing this, and chuck in print calls at various places so you can check that what you think is happening is really happening.
 
woah
I did it
it took 5 seconds
I didn't even optimize for square root of n
primes = [2]

x = 3

while(len(primes)<10001):
    counter = 0
    for p in primes:
        if x%p == 0:
            counter = 1
            break
    if counter == 0:
        primes.append(x)
    x += 2
 
6:34 PM
@daOnlyBG You can actually make that a bit nicer by putting an else clause on your for loop. See here for a demo: stackoverflow.com/questions/9979970/…
 
you should do that now, the ceiling bit
that should also give more than a factor of two, right?
right, for x=100 you only need test up to p=10 instead of 100
 
@PM2Ring Just replacing the second if with an else?
 
@daOnlyBG Correct.
 
Thanks. I didn't know we could use else clauses with for loops. You people have taught me so much already. Thank you. Now to add that ceiling constraint...
 
@daOnlyBG don't take this as a hostile comment, I'm really trying to be helpful: the whole point of this is for you to learn new syntax and methods. Try to look at links the others provide you, and put it together on your own. Then you'll have a reusable set of new skills:)
it's way too easy to rely step by step on the help of others, and forgetting to really learn along the way
You're doing great, so really, don't be alarmed. Really just a friendly remark.
 
6:38 PM
@AndrasDeak Not at all a hostile comment. I'm mainly asking for clarification. I've actually been doing quite a bit of coding while asking you questions based on the hints you've given me. I agree wholeheartedly with your sentiments, fwiw.
 
Good:) I'm just often worried about coming across as a bit too harsh (not being a native English speaker, and lacking all non-verbal communication online), so I find it better to be explicit when in doubt
 
@daOnlyBG Now that I know what your code looks like, I recommend doing a test like if p*p > x: break
 
@AndrasDeak Haha, I try to give people the benefit of the doubt- especially when they're taking the time to point me in the right direction. Even if you were being condescending (which you aren't), all I have to do is leave the chatroom. I'm still here, though :D
 
Glad to hear that:)
 
I learned object oriented programming in college for a semester or so and proceeded to pick up C#. Python is a bit different, apparently- I've made my fair share of mistakes these past couple of days
 
6:43 PM
Of course another reason for my caution is that I'm often genuinely, intentionally hostile towards those people who deserve it:P And I'm mildly worried about developing a habit of being constantly condescending:D
 
haha
mildly?
 
well, after all, I rarely try to make it clear that I'm trying to be a nice person for a change
 
@AndrasDeak Just embrace it.
 
:D
@Ffisegydd just in time for life coach advice
 
Always.
 
6:48 PM
You know, upon thinking some more...
...I don't think that ceiling constraint will make a difference
the entire point of Andras' hint was that we should stop testing divisors once we find one
 
The trick is to test it and see.
 
that inherently carries the ceiling constraint
 
@daOnlyBG nope
 
because that first divisor will show up below sqrt(n)
 
if you have a new prime, you'd test all existing ones
what you're saying is only valid for new non-primes
consider the new candidate 103
(that's a prime)
you'd go all the way to 97 without finding a divisor
 
6:50 PM
@daOnlyBG It will when the number you're currently testing actually is a prime.
 
Is it a fizzy prime though?
 
oops, 101 is also a prime
that's what you get for talking to a physicist about math
 
Remind me to never get in anything powered by your particle accelerator.
 
If we have a non-prime, i.e., 102, then we only have to test up to sqrt(102) to find its first prime divisor. However, if there is no prime divisor from 1 to sqrt(102), is it not prime?
 
@Withnail will do
 
6:55 PM
1 / 97 is rather cute in base 10. It has a period of 96, and you can see a nice geometric progression in the initial digits: 0.01030927
 
@daOnlyBG if you have a non-prime, e.g. 102, you'll surely find a divisor, which will be smaller than sqrt(102)
but if you didn't find a divisor up to sqrt(x), there's no chance of finding another divisor after that one
 
@AndrasDeak Exactly!
 
simply because if n is a divisor of x, then x/n is also a divisor; but if n>sqrt(x) then x/n<sqrt(x)
 
Oh, I understand now why we have to add that constraint
Because the code will unnecessarily run longer for prime numbers
 
yes, hence inefficiency:)
not error, but inefficiency
 
6:57 PM
right
 
FWIW, I've been writing prime-related code off & on for decades, and I can still have fun with it. I'll probably never understand the most advanced techniques, but that's ok. OTOH, I do understand how Miller-Rabin works, and that can do some pretty impressive stuff.
 
I always love an answer that starts with This doesn't answer your question :D
 
:) Thanks, guys. I honestly wasn't fishing for votes. But they don't hurt. :D
 
@PM2Ring Thanks for sharing- I've only heard of Miller-Rabin in a discrete math course I took in college (quite the tangential topic tbqh), along with Pocklington's and Fermat's little, but didn't quite delve into it much. I'm glad these questions in the Euler Project are improving my knowledge in both fields.
After implementing the sqrt(x) constraint, I was able to shave off ~0.25 seconds. Does this seem reasonable to you?
primes = [2]

x = 3

while(len(primes)<10001):
    for p in primes:
        if p*p <= x:
            if x%p == 0:
                break
    else:
        primes.append(x)
    x += 2
(actually, running the code several more times shows that perhaps there wasn't a statistically significant improvement to begin with)
 
31 mins ago, by PM 2Ring
@daOnlyBG Now that I know what your code looks like, I recommend doing a test like if p*p > x: break
 
7:13 PM
hm... more infinite loops. I'll play around with it. Thanks again, everyone!
 
rbrb all.
 
Me too. It's ridiculously late here. Rhubarb
 
7:29 PM
night
 
user559633
^that's cool, thanks for sharing
 
Nice share.
 
I'm full of blog posts. I got what you need fam.
 
user559633
8:08 PM
[unrelated] @idjaw i'd recommend mixing in a little sumac to mujadara -- it gives this delicious aftertaste that clears out the heavy lentil finish
 
@tristan nice touch! You should also try some caramelized crispy onions as well. Something like this: fae-magazine.com/2012/09/23/…
really really good
 
user559633
oh yeah, totally! i did that with the last batch -- adding a bit of sugar helps give them a crispy coating
 
user559633
i made it twice before letting my inner fat kid tweak the recipe
 
8:31 PM
Hey all
 
user559633
hi :)
 
I have a little issues, maybe some of you could help me out with it :- )
 
recbg
 
I run PyQT to spawm main window, that spawn 100 QWidgets....
when I reach to 300 QWidgets I get
QWidget::create: Failed to create window (The current process has used all of its system allowance of handles for Window Manager objects.)
Where can I look for help on this? It feels to me like I'm hitting some kind of limits but not sure how can I lift them
 
I don't know python guis, but...why do you want to spawn 300 widgets?:P
 
8:34 PM
render layer system for rendering
like furnitur configurator
300 options of furniture to send to render
can be more can be lest... I'm writing a manager to deal with that massive list of jobs to render
but I did not expect to reach that cap or even know that it existed I thought I can spawn as many Qwidgets as I want...
 
@Dariusz I would look at the source code where that is triggered and work your way up from there
maybe you'll find the option to increase the limit
 
you mean in PyQT files?
 
yep
 
oh thats way above my skill set :D
but thanks for suggestion maybe I'll start digging in there once I fail everywhere else :- )
 
source code can be intimidating but if you know what you are looking for and have at least intermediate python knowledge, you can make it through and find the answer
good luck :)
 
8:41 PM
yea, I think I'll just loop over my python folder in search for that error code line and see what its around it then I'll start adding 99999 everywhere to increase the size hahaha
 
user559633
I'd check if the number of handlers is configurable, and if not, that probably means there's a pattern that's preferred by PyQT
 
user559633
300 widgets is both small (in terms of a limitation) and very large (in terms of UX)
 
yea it did took me by srurprise when my manager crashed on me hehe
 
Quick on, I don;t follow how this evaluates...
( cel.group(agg_set) | done.s() ).apply_async()
'cel' is import celery as cel
'agg_set' is a list with celery tasks
'done.s()' is a celery task that calls .set_complete on a django object
'.apply_async()' is a celery task that applies tasks asynchronously by sending a message.
All of it together leaves me confused, on how the | operator applies in this case
 
That depends on the object, read the docs for celery
 
8:51 PM
@Ffisegydd have read em, made sure I did my homework before posting here
I dont see how ( func | func ).func is a valid statement, irrespective of celery
 
it's not exactly func|func, it's func_call | func_call
 
@AndrasDeak right right, my fault
 
if the functions return something that is of a class for which | makes sense and is of the same class and callable...it could work
right?
>>> class t(int):
   ...     def __or__(self,other):
   ...         print(self-other)
   ...
>>> t2=t(2)
>>> t2|4
-2
so it shouldn't be that hard to define | for your objects
 
mmmm @AndrasDeak but done.s() does not return anything. But I see what you are getting at
Thanks for the assist, I have some direction to dig at
 
Consider me a high-maintenance rubber duck:)
 
9:00 PM
@AndrasDeak lol roger that
 
Adz
9:58 PM
guys why does django complain about this? Your URL pattern '^$' uses include with a regex ending with a '$'. Remove the dollar from the regex to avoid problems including URLs.
if i remove the dollar sign django calls that url for everything
 
Evening
 
@JRichardSnape good evening
 
How's things @Andras? Practising constant condescension? :D
 
@JRichardSnape Not that the likes of you could appreciate it, but yes.
;)
I'm fine, thanks, trying to post-process some stuff
how are you?
 
:)
Interestingly enough I've been post-processing optimisation outputs today.
And musing on why the results are as they are. Not yet made my mind up exactly what's going on.
Which is fun.
 
10:06 PM
:)
science, the eternal cycle of WTF?!s and AHA!s
 
TBH it'll probably turn out that I've messed something up. That follows ~70% of all my WTFs.
I also make up 95% of my percentages on the spot.
 
:D
as do we all
 
cbg :)
 
10:40 PM
 np.einsum('ba,dbc,ca->ad',kxkykzmat,Jhyp,kxkykzmat)
I love numpy.einsum
 
11:15 PM
what's up people
 

« first day (2088 days earlier)      last day (2875 days later) »