[PYTHON] I don't want to take a coding test

I don't want to take a coding test

I will take a coding test, so make a note of it. I will make a note so I will update it. Please forgive me because it is a texto

2019/12/15 For the time being, I will do it with python that I usually use. Should I move to C ++ if I'm a competition pro?

2019/12/16 I want to solve the past questions of AtCoder For the time being, I made a repository on github. βshort repository

Competitive professional relationship?

paiza AOJ AtCoder

problem

  1. AtCoder Beginners Selection
  2. AtCoder problem

Reference & link

  1. What to do next after registering with AtCoder-If you solve this much, you can fight enough! Past questions selected 10 questions ~
  2. Cheat sheet for competitive programming used in Python
  3. https://1kohei1.com/leetcode/
  4. https://www.madopro.net/entry/2016/09/05/135126
  5. https://www.freecodecamp.org/news/coding-interviews-for-dummies-5e048933b82b/
  6. https://qiita.com/yohachi/items/e4bef4035da135a4808d
  7. https://app.codility.com/programmers/lessons/1-iterations/
  8. I tried to solve 10 selected past questions that should be solved after registering with AtCoder

Python notes

This is a memo related to grammar and numpy.

Input relationship

Reference: https://qiita.com/fmhr/items/77fc453e2fb1bc02e392

Multiple numbers to the specified variable

a, b, c, d = map(int, input().split())

List multiple numbers

#Input 1 3 4 5
a = [int(i) for i in input().split()] 
#a=[1 3 4 5]

List multiple strings

a = [i for i in input().split()] 

Output relation

Zero padded output

In case of multiple, specify by index For 2-digit decimal

#{Index number:Format specification}.format()
print("{0:02d}".format(1))
#01

No line breaks

print("Characters etc.", end='')

Decimal point

#Round up
math.ceil()
#Truncate
math.floor()
#Rounding
round()

n-ary

Binary: bin () Eighth number: oct () Hexadecimal: hex ()

match

All match'abc'=='abcd' is False Negation is! =

Partial match'abc' in'abcd' is True Negation is not in

String

How many'a' are in the string s

s.count('a')
s.replace("Before replacement", "After replacement")

I want to replace (assign) the character of the specified index

#String=>list
s = list("String")
s[2] = "formula"
s = "".join(s) 

list https://docs.python.org/ja/3/tutorial/datastructures.html To count the number of each element (the number of occurrences for each element), use the count () method.

a.append("Value you want to store")
a.remove("Value you want to delete")
a.pop()

List comprehension

[i for i in range(10)]
#ascending order
a.sort()
#descending order
a.sort(reverse=True)
sum(a)

map is an apply function in pandas

map(func, list)

set

a.add()
a.delete()

dict

numpy

np.zeros('shape')
np.ones('shape')
np.full('shape', 'value')

Number of elements in an array that meets the conditions

np.count_nonzero(a < 4)

Index of the maximum value of the array

#https://qiita.com/shippokun/items/01c85e36b8de7afd01a6

maxValue = np.max(a)
maxIndex = []
for i in range(len(a)):
    if maxVaule == a[i]:
        maxIndex.append(i)
print(maxIndex)    # [1, 4]

Conditional branching for each element of the numpy array

np.where(conditions, True, False))

Recommended Posts

I don't want to take a coding test
100 image processing knocks !! (021-030) I want to take a break ...
I want to write in Python! (2) Let's write a test
I want to print in a comprehension
I want to make matplotlib a dark theme
I want to do Dunnett's test in Python
I want to easily create a Noise Model
I want to INSERT a DataFrame into MSSQL
I don't want to use -inf with np.log
I want to create a plug-in type implementation
I want to easily find a delicious restaurant
I want to write to a file with Python
I want to upload a Django app to heroku
I want to embed a variable in a Python string
I want to easily implement a timeout in python
I want to iterate a Python generator many times
I want DQN Puniki to hit a home run
I want to give a group_id to a pandas data frame
I want to generate a UUID quickly (memorandum) ~ Python ~
I want to transition with a button in flask
I want to climb a mountain with reinforcement learning
I want to find a popular package on PyPi
I want to randomly sample a file in Python
I want to easily build a model-based development environment
I want to work with a robot in python.
I want to split a character string with hiragana
I want to install a package of Php Redis
[Python] I want to make a nested list a tuple
I want to manually create a legend with matplotlib
I want to send a business start email automatically
I want to run a quantum computer with Python
I want to bind a local variable with lambda
I want a mox generator
I want to solve Sudoku (Sudoku)
I want a mox generator (2)
I want to take a screenshot of the site on Docker using any font
I want to make a blog editor with django admin
I want to start a jupyter environment with one command
[Python] I want to get a common set between numpy
I want to make a click macro with pyautogui (desire)
I want to automatically generate a modern metal band name
NikuGan ~ I want to see a lot of delicious meat! !!
I want to make a click macro with pyautogui (outlook)
I want to use a virtual environment with jupyter notebook!
I want to install a package from requirements.txt with poetry
I want to send a message from Python to LINE Bot
[Visualization] I want to draw a beautiful graph with Plotly
I want to make input () a nice complement in python
I want to create a Dockerfile for the time being.
I want to understand systemd roughly
I want to scrape images to learn
I want to do ○○ with Pandas
I want to copy yolo annotations
I want to debug with Python
I want to record the execution time and keep a log.
I want to use a wildcard that I want to shell with Python remove
MacBookPro Setup After all I want to do a clean installation
numpy: I want to convert a single type ndarray to a structured array
Don't you want to say that you made a face recognition program?
Qiskit: I want to create a circuit that creates arbitrary states! !!
I want to do a full text search with elasticsearch + python