No.1806 Rotating Golem
タグ : / 解いたユーザー数 272
作問者 :
MasKoaTS
/ テスター :
Problem Statement
The wizard Koa has summoned a golem.
The golem initially faces one of the directions "East", "West", "South", or "North",
and each time Koa gives $1$ command, the direction the golem faces rotates $90$ degrees to the right.
That is, if the golem was facing north, it changes to east; if east, to south; if south, to west; and if west, to north.
You are given characters $A$, $B$ representing directions.
Each of them is $1$ character, one of E, W, S, N,
corresponding to "East", "West", "South", and "North", respectively.
When Koa gives $0$ or more commands to change the direction the golem faces from $A$ to $B$,
what is the minimum number of commands required?
Constraints
$A$, $B$ are each $1$ character, one of
E,W,S,N
Input
The input is given in the following format.
$A$ $B$
Line $1$ contains $A$
Line $2$ contains $B$
Output
Print the answer on $1$ line, followed by a newline.
Sample
Sample 1
Input
E N
Output
3
If $3$ commands are given, the golem's direction changes as follows.
Command $1$ : East → South
Command $2$ : South → West
Command $3$ : West → North
Therefore, the answer is $3$.
Sample 2
Input
S S
Output
0
The golem is facing south from the start, so no commands need to be given.
Sample 3
Input
W E
Output
2
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。