Movement that changes direction in the coordinate system I tried Python 3

Introduction

As usual, paiza's B rank level up set. It's a problem that the code is officially open to the public.

This time, the problem is almost the same as that of Nezumi Kozo, who was also in the skill check of B rank Hon-chan. It's easy to solve if you don't make a mistake in how the coordinates move when facing either direction.

zahyo_muki.py


x,y,n = [int(i) for i in input().split()]

direction = "N"


for i in range(n):
    a = input()
    
    if direction == "N":
        if a == "R":
            x += 1
            direction = "E"
        
        else:
            x -= 1
            direction = "W"
            
    
    elif direction == "E":
        if a == "R":
            y += 1
            direction = "S"
        
        else:
            y -= 1
            direction= "N"
    
    elif direction == "S":
        if a == "R":
            x -= 1
            direction = "W"
        
        else:
            x += 1
            direction = "E"
          
    
    else:
        if a == "R":
            y -= 1
            direction = "N"
        
        else:
            y += 1
            direction = "S"
    print(x,y)

Impressions

nothing special. Forcibly speaking, it was not specified which direction the test case was facing at the initial position, and it was a problem that I had to judge by the output of the test case. I think that B-rank Nezumi Kozo can solve this problem if it is a level that can be solved.

Rather than that ...

The problem just before this problem (positioning that should be easier than this) was shut out without any hands or feet. .. ..

スクリーンショット 2020-08-20 23.50.43.png

I just can't put this clockwise movement into the code. For the time being, I escaped from reality and challenged the title problem, but it was too easy to beat. I really don't know. .. .. White flag: bow_tone 4:

Recommended Posts

Movement that changes direction in the coordinate system I tried Python 3
I tried simulating the "birthday paradox" in Python
I tried the least squares method in Python
I tried to graph the packages installed in Python
I tried using TradeWave (BitCoin system trading in Python)
I tried the accuracy of three Stirling's approximations in python
I tried "a program that removes duplicate statements in Python"
I tried programming the chi-square test in Python and Java.
I tried to implement the mail sending function in Python
Miscellaneous notes that I tried using python for the matter
I wrote the queue in Python
I tried Line notification in Python
I wrote the stack in Python
I tried running the offline speech recognition system Julius with python in the Docker virtual environment
I tried running the Python Package Repository (Warehouse) that supports PyPI
I tried to implement PLSA in Python
I tried to implement permutation in Python
I tried to implement PLSA in Python 2
I tried using Bayesian Optimization in Python
I tried to implement ADALINE in Python
I tried to implement PPO in Python
Python: I tried the traveling salesman problem
A story that didn't work when I tried to log in with the Python requests module
I tried the Python Tornado Testing Framework
[Python] I tried to summarize the set type (set) in an easy-to-understand manner.
I tried to develop a Formatter that outputs Python logs in JSON
I tried "smoothing" the image with Python + OpenCV
[Python] I tried substituting the function name for the function name
vprof --I tried using the profiler for Python
A memo that I wrote a quicksort in Python
I tried "differentiating" the image with Python + OpenCV
I tried playing a typing game in Python
I tried python programming for the first time.
[Memo] I tried a pivot table in Python
I tried debugging from Python via System Console
Get the X Window System window title in Python
I tried "binarizing" the image with Python + OpenCV
I tried to implement TOPIC MODEL in Python
I tried using the Datetime module by Python
I tried non-blocking I / O Eventlet behavior in Python
I implemented the inverse gamma function in python
I tried adding a Python3 module in C
The one that displays the progress bar in Python
I tried to implement selection sort in python
I want to display the progress in Python!
I tried to create a class that can easily serialize Json in Python
I tried using the Python library "pykakasi" that can convert kanji to romaji.
I tried to predict the horses that will be in the top 3 with LightGBM
Note that I understand the least squares algorithm. And I wrote it in Python.
I tried Python on Mac for the first time.
I tried to touch the CSV file with Python
I tried Python> autopep8
I tried to solve the soma cube with python
I tried to implement a pseudo pachislot in Python
I tried python on heroku for the first time
I tried to implement Dragon Quest poker in Python
Find the part that is 575 from Wikipedia in Python
mong --I tried porting the code that randomly generates Docker container names to Python -
I tried to implement GA (genetic algorithm) in Python
[Python] I tried to graph the top 10 eyeshadow rankings
I want to write in Python! (3) Utilize the mock