Back
Close

Hazards in the water

Statement

 Goal

IALA buoyage cardinal marks (North, South, East, West) are used to warn of hazards so that ships don't go aground. They indicate the direction away from the hazard.

The cardinal marks are represented on 2 lines as shown.

Cardinal Mark:  North     South     East     West

Top symbol: ^ v ^ v
Bottom symbol: ^ v v ^


Your job is to output the direction toward the hazard shown by the cardinal marks.

NOTE: 2 cardinal marks may be seen in any order, always output the correctly combined direction toward the hazard. e.g. North-East in this example;

vv
^v
decodes as a West cardinal mark followed by a South cardinal mark pointing away from the hazard.
The valid direction toward the hazard becomes North-East since East-North is not a correct compass direction.

Valid compass directions are: North, North-East, East, South-East, South, South-West, West, North-West.
Input
Line 1 A string topSymbol for symbol/s on the top of the mark.
Line 2 A string bottomSymbol for symbol/s on the bottom of the mark.
Output
A single line showing the direction toward the hazard.

If 2 directions then separate with a -
Constraints
1 <= length topSymbol <= 2
1 <= length bottomSymbol <= 2

length topSymbol = length bottomSymbol
Example
Input
^
^
Output
South

Game modes
Fastest, Shortest

Test cases
Easy Test
Input
^ ^
Output
South

Validator 1 Validator
Input
v v
Output
North

Easy 2 Test
Input
^ v
Output
West

Validator 2 Validator
Input
v ^
Output
East

2 marks Test
Input
^^ ^v
Output
South-West

Validator 3 Validator
Input
^v ^^
Output
South-East

2 marks reversed Test
Input
vv ^v
Output
North-East

Validator 4 Validator
Input
^v vv
Output
North-West

Solution language

Solution

Stub generator input