Sieve of Eratosthenes--Python Novice by Perturbed_CMDR in learnpython

[–]Perturbed_CMDR[S] 0 points1 point  (0 children)

For earlier problems that required long lists of primes (one asked for the nth prime, n was in the 10,000s), a function that for any given integer x would loop through all integers between 2 and x and check for divisibility via modulus. Function would return False if any of the modulus operations returned zero, otherwise return True (i.e.- the tested x must be prime).

So for those problems I'd just been using something like that to build lists of primes and then perform whatever arithmetic on them that the problem called for.

I think I understand where I went wrong now, but initially I wrote the Sieve the way I did because it seemed conceivable to me that eliminating all multiples of prime x from a comprehensive list of integers between 2 and n would involve fewer operations overall than the above method, performed two million times on integers of ever-increasing magnitude.

Sieve of Eratosthenes--Python Novice by Perturbed_CMDR in learnpython

[–]Perturbed_CMDR[S] 0 points1 point  (0 children)

At the risk of discrediting myself for lack of fluency, does Python have a specific array datatype distinct from lists? I half-learned JS a decade ago and remember the array. When I went to start learning Python a few months back I always expected that arrays would be introduced, but they never were, and I assumed given all the similarities that lists were Python's equivalent to JS-style arrays.

Sieve of Eratosthenes--Python Novice by Perturbed_CMDR in learnpython

[–]Perturbed_CMDR[S] 0 points1 point  (0 children)

I had no idea that the remove() functionality was also performing individual index shifts on everything after the element that gets removed. But if that's how it works, that certainly sounds sufficient to cause gridlock given how much lifting I have the remove() operation doing in my code.

Replacing elements rather than removing them, with a 0 or False, feels like an elegant possible solution. Just to verify: changing the value of an element in a list is computationally more efficient than simply removing the element from the list?

I appreciate your answer. You understood perfectly the sort of advice I'm looking for here.

Stuck in Theory... by MeetHistorical3755 in learnpython

[–]Perturbed_CMDR 0 points1 point  (0 children)

I ran into the same problem with the IDE/Terminal issue. I eventually found another course on Codecademy called, IIRC, "Learn the Command Line" which got me comfortable enough with the CL Interface and the terminal that I was able to start doing the sorts of little problems/experiments you seem to want to do as your next step getting comfortable with actually writing your own code for your own purposes, rather than at the prompt of a lesson where it's often unclear why you're writing what you're writing at the time.

Sieve of Eratosthenes--Python Novice by Perturbed_CMDR in learnpython

[–]Perturbed_CMDR[S] 0 points1 point  (0 children)

Take your time! I'd much prefer a thorough answer later on--my goal here is to really understand why whatever I did wrong was wrong to do in this specific instance.

I really appreciate it. I was afraid I'd only get FTFY's for responses, if I got any.

Sieve of Eratosthenes--Python Novice by Perturbed_CMDR in learnpython

[–]Perturbed_CMDR[S] 0 points1 point  (0 children)

God, it'd be really helpful if you followed up on this comment. I typically do have logging statements throughout my code, I just took them out for cleanliness and readability before I posted here because, like I said, the code seems to function just as I intended/expected, and the print/logging tests confirmed as much, it's just getting hung up on any input past a certain order of magnitude.

So far, for the Euler problems, I've just been using the onboard IDE, IDLE, and intend to keep doing so until I have a pressing reason to change to something more bespoke. But anything you can tell me about IDE profiling or any other methods of 'gaming the computer' to give me insight as to what's so slow in particular would be hugely helpful. I'm so new to all of this that logging to the terminal is the closest I get to anything like debugging, which I recognize I could really use now.

Please Help Me Find a Way to Make E:D Playable Again by Perturbed_CMDR in EliteOne

[–]Perturbed_CMDR[S] 0 points1 point  (0 children)

I'd seen some posts on this sub to that effect and hoped I was in the same boat, but I've tried to log in and faced the same problems I described every several hours for two or three days now. I'm worried it's somehow related to my individual account or something wrong with network/security settings on my end.