What I learned by solving 30 questions of python Project Euler

When my first level

I knew if, for, and while statements. There seems to be a list comprehension (I don't know about dictionaries and generators) attribute? Somehow, I have a masochist attribute + a glasses girl attribute?

What I learned in python

List comprehension http://docs.python.jp/2/tutorial/datastructures.html Example: Project Euler 29 http://qiita.com/cof/items/b39c28e8770fc60b074d

Dictionary comprehension (Python 2.6? Or later) ?? (In the sense of) Example: Project Euler 23 http://qiita.com/cof/items/3e02bca57b6a6dc1578a

List comprehension, dictionary comprehension, generator differences, notation (by shiracamus) See comments below http://qiita.com/cof/items/b39c28e8770fc60b074d

Is it possible to simplify the code by making the branch of the if statement into a dictionary? (I understand) (by shiracamus) See comments below http://qiita.com/cof/items/567dbc499fbf6d4aefb1

map () function http://docs.python.jp/2/library/functions.html#map Example: Project Euler 20 http://qiita.com/cof/items/400ae6793819850ce68a

reduce () function http://docs.python.jp/2/library/functions.html#reduce Example: Project Euler 22 http://qiita.com/cof/items/40519ba5d3d59db079de

lambda http://www.lifewithpython.com/2013/01/python-anonymous-function-lambda.html

time Especially time.time () http://docs.python.jp/2/library/time.html

timit () function http://docs.python.jp/2/library/timeit.html How to use http://qiita.com/cof/items/ddac98e31a5a4bf16ec7#comment-e9bb24a7450c6b0d74fd

file-> list Example: Project Euler 22 http://qiita.com/cof/items/40519ba5d3d59db079de

It is easy to understand if the constant is written in uppercase.

If you use range () in multiple loops, the speed tends to slow down, so it's a good idea to put it in a variable before the loop.

What I learned algorithmically

List comprehension is (generally) fast http://qiita.com/cof/items/ddac98e31a5a4bf16ec7#comment-e9bb24a7450c6b0d74fd

Use the dictionary and sets when referencing with in xxx. http://www.peignot.net/python-speed

When creating something, it is easy to create a function that creates the next status from the current status Example: Project Euler 28 http://qiita.com/cof/items/567dbc499fbf6d4aefb1 Project Euler 19 http://qiita.com/cof/items/44b380466e560de99e25

If the algorithm is improved by adding consideration to the data to be handled, the processing can be performed smoothly. Example: Project Euler 24 http://qiita.com/cof/items/874ddf45e86d94f817bf Project Euler 26 http://qiita.com/cof/items/567dbc499fbf6d4aefb1 Project Euler 10 http://qiita.com/cof/items/13dd1b3c29b43452cdc0

Efficient processing may be possible by modifying existing algorithms (* It is necessary to understand why existing algorithms are efficient. Example: Project Euler 21 http://qiita.com/cof/items/e86d6e6db090dd54b006 Example 2: Project Euler 12 http://qiita.com/cof/items/222d51c09b043da974af

It is important to set the final (initial) parameters when using recursion. (but slow in my implementation) Example; Project Euler 15 http://qiita.com/cof/items/e97797aa692d569164e3 Project Euler 18 http://qiita.com/cof/items/ccee79fbf84a93d21c1b

Speeding up can be measured by storing the calculation results. Example: Project Euler 14 http://qiita.com/cof/items/ddc4d797ff2979f1a3be Project Euler 9 http://qiita.com/cof/items/ef35068f3e63ede66eaf

There are many possible approaches, but they are not always faster. Example: Project Euler 4 http://qiita.com/cof/items/96fed868672ec1e0c404 Project Euler 5 http://qiita.com/cof/items/5c9670c4ac3f7988ae14

For speeding up, it is important to compare the benefits of speeding up with the costs spent on it. Example: Project Euler 2 2.21 Man spending 15 minutes to save microseconds http://qiita.com/cof/items/2591c15c6f63c89f304c

Project Euler difficulty (1st to 30th questions)

If you just ask for an answer, it's generally kind.

Comprehensive

Looking back, I learned a lot.

Recommended Posts

What I learned by solving 30 questions of python Project Euler
What I learned in Python
Conditional branching of Python learned by chemoinformatics
Project Euler # 16 "Sum of Powers" in Python
The Python project template I think of.
Project Euler # 17 "Number of Characters" in Python
Project Euler # 1 "Multiples of 3 and 5" in Python
Project Euler # 10 "sum of prime numbers" in Python
Project Euler # 13 "Sum of Large Numbers" in Python
Project Euler # 6 "Difference in sum of squares" in Python
What I learned about AI / machine learning using Python (1)
What I learned about AI / machine learning using Python (3)
What I learned by participating in the ISUCON10 qualifying
What I learned about AI / machine learning using Python (2)
What I learned about AI and machine learning using Python (4)
What I learned about Linux
What beginners learned from the basics of variables in python
What is Project Euler 3 Acceleration?
I learned Python basic grammar
What I saw by analyzing the data of the engineer market
What I learned by writing a Python Pull Request for the first time in my life
I couldn't use tkinter with python installed by pyenv of anyenv
[Super basics of Python] I learned the basics of the basics, so I summarized it briefly.
Functional programming in Python Project Euler 1
Project Euler 10 "Sum of Prime Numbers"
[Note] Project Euler in Python (Problem 1-22)
Expansion by argument of python dictionary
Functional programming in Python Project Euler 3
Project Euler # 5 "Minimum Multiples" in Python
I learned about processes in Python
Functional programming in Python Project Euler 2
Behavior of python3 by Sakura's server
Project Euler # 15 "Lattice Path" in Python
Story of power approximation by Python
Project Euler # 4 "Maximum Palindrome" in Python
Project Euler 9 Retention of calculation results
What is the XX file at the root of a popular Python project?
I tried to verify and analyze the acceleration of Python by Cython
A reminder of what I got stuck when starting Atcoder with python
Explanation of production optimization model by Python
[Python] What is inherited by multiple inheritance?
Project Euler # 3 "Maximum Prime Factors" in Python
[Learning memo] Basics of class by python
What kind of programming language is Python?
Algorithm learned with Python 8th: Evaluation of algorithm
Project Euler # 7 "1000 1st prime number" in Python
I didn't know the basics of Python
Grayscale by matrix-Reinventor of Python image processing-
Example of 3D skeleton analysis by Python
What I got from Python Boot Camp
What I did with a Python array
Pandas of the beginner, by the beginner, for the beginner [Python]
1. Statistics learned with Python 1-3. Calculation of various statistics (statistics)
Project Euler # 9 "Special Pythagorean Triple" in Python
What I learned at hackerrank on 1/30 days.
Analysis of X-ray microtomography image by Python
Project Euler # 14 "Longest Collatz Sequence" in Python
I wrote Project Euler 1 in one liner.
Project Euler # 2 "Even Fibonacci Numbers" in Python
What I was addicted to Python autorun
What I did to save Python memory