Do you guys do Atcoder? ?? I also look interesting! I thought that I started with Python. However, when it comes to writing code in a contest
The code test on the contest site is troublesome to move pages ... PyCharm is a little heavy to say ...
I felt like I couldn't find the right coding environment. .. And after trying various things, Jupyter Notebook seems to be just right! I've realized that, so I'd like to share it!
First of all, Jupyter Notebook is good! Perfect! If so, this article should end here
There is only one thing that is not very suitable for AtCoder.
That is, "there is no way to enter test cases well"! I want to receive input with input (), but I can't receive it because it is not prepared. ..
Therefore! Introducing "Easy way to receive AtCoder test cases in Jupyter Notebook".
Now open your notebook. Paste the code below into the first cell.
from ipywidgets import Textarea
def get_input(change):
global Input
Input = change["new"]
textarea = Textarea()
textarea.observe(get_input, names='value')
display(textarea)
And execute the cell ... Then a text area will appear! You can enter multiple lines in this text area, and you can paste the test case as it is!
continue, Create a cell below and paste the code below.
IN = iter(Input.split('\n')).__next__
def input():
return IN()
That's all for preparation!
Try it in "A-Welcome to At Coder" of Atcoder's resident contest "practice".
Takahashi wants to process the data. Given the integers a, b, c and the string s. Display the calculation result of a + b + c and the character string s side by side.
The input is given in the following format.
a
b c
s
Output a + b + c and s on one line separated by spaces.
1
2 3
test
6 test
By the way, it is a type that has multiple lines of input. Let's paste the input example into the text area prepared earlier! It has been cut off, but it has been pasted.
Then code. Write the code in the second cell. When I ran it ... it worked! It gets line by line from the text area with input ().
All you have to do is submit the code and you'll be happy to finish! Let's pray for AC (be careful not to accidentally include the preparation code)
How was that? ??
You can try various inputs quickly with a little preparation, so I think it will be quite comfortable! If you are worried that you haven't found a coding environment that suits you yet, please try it ~
See you soon
Recommended Posts