Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Hot answers tagged

5 votes
Accepted

The smallest positive number that is evenly divisible by all of the numbers from 1 to 20

Straight. If you - defined "the range-LCM" in a function with a docsting - presented imports  and test cases or usage examples, - added boundary checks (try ...
user avatar
  • 4,398
4 votes
Accepted

Calculate the first largest factor of 600851475143

Couple of points: Use integer division, the double slash //. This has an update partner //= too so ...
user avatar
  • 291
4 votes
Accepted

Implement a Python frozenmap

Library code cannot resort to global variable hacks. You are attempting to implement a data structure. That's a bedrock kind of library code. As such, it cannot resort to crazy mechanisms like setting ...
user avatar
  • 9,630
3 votes
Accepted

The largest palindrome made from the product of two 3-digit numbers

Outsource secondary calculations to helper functions. Your current code is reasonable. Its primary drawback is that the Euler-solving code is cluttered up with the details of checking for palindrome ...
user avatar
  • 9,630
3 votes

Calculate the first largest factor of 600851475143

There is a style guide for Python you can consult. There is no use in trying to be creative when formatting the code, so you should write _ ...
user avatar
  • 1,257
3 votes
Accepted

Project Euler - Problem #1 - Multiples of 3 or 5 - Python

Put all of your code in functions. Including the code to represent Euler problem 1, along with the code to exercise that function. Implement automated tests for those functions. While implementing ...
user avatar
  • 9,630
2 votes
Accepted

Calculate the sum of even Fibonacci numbers

Modularity We have the printing and the constraints (the constant 4000000) mixed in with the logic of the code. If we create a function, we can unit-test it, and ...
user avatar
  • 57.8k
1 vote

The largest palindrome made from the product of two 3-digit numbers

Your upper_limit and lower_limit variable definition is a little bit complicated because it involves integer division. _ ...
user avatar
  • 1,257
1 vote

The largest palindrome made from the product of two 3-digit numbers

Style Guide for Python Code A few PEP 8 items: parenthesis are unnecessary in (10**(n))-1; write 10 ** n - 1 use a space around ...
user avatar
  • 30.4k
1 vote
Accepted

Returning all divisors of a number as a matrix with N X 2 dimensions

PEP8 specifies CapWords for class names. But you should figure out a better class name than DataStructure, since that's not very descriptive. Your docstring starts out "from any input". ...
user avatar
  • 674

Only top scored, non community-wiki answers of a minimum length are eligible