I sent out the Python codes for challenge 7 a little over a week ago. Well, I only got one attempt to improve code, but it was a good one!
Greg honed his code, and it is now a full second faster than my code (when run on the same hardware/environment). This is now what the performance chart looks like:
When asked what made his so much better, Greg responded:
"The thing that made my code twice as fast was not trying any even numbers because even numbers divided by 2 will result in another even number until it reaches 1. For example 8 dived by 2 is 4 that divided by 2 is 2 and 2 dived by 2 is 1.
another thing that significantly sped up my program was using integer division rather than floating point division. Integer division also known as floor division returns an integer rather than a float so the program has to do less work divining floating point numbers and it therefor goes faster. "
No comments:
Post a Comment