至少可以说,32点罗盘很有趣。
由Denelson83(自己的作品)[ GFDL或CC-BY-SA-3.0 ],通过Wikimedia Commons
您面临的挑战是采取度数测量并将其转换为32点罗盘上的方向。
每个方向都比上一个方向远11.25(360/32)度。例如,N(北)为0度,NbE(北至东)为11.25度,NNE(北-东北)为22.5度,依此类推。
至于您应该如何获得指示,
0度是N,90度是E,180度是S,270度是W。
- 这些被称为基本方向。
基本方向之间的中间点就是它们之间串联的基本方向。N或S始终排在第一位,W或E始终排在第二位。
- 这些称为顺序指示。
基本方向和顺序方向之间的中间点是它们之间的连接方向,再次之间是“-”。基本方向为第一,第二顺序。
- 这些被称为次要心内方向。
次要心轴方向与其他方向之间的中点是它们最接近的基本方向“旁”的其他方向(当然,不是紧邻其的那个方向)。
- 我不知道这些叫做什么:P
如果所有这些解释都像我一样伤害您的大脑,您可以参考此图表:
1 North N
2 North by east NbE
3 North-northeast NNE
4 Northeast by north NEbN
5 Northeast NE
6 Northeast by east NEbE
7 East-northeast ENE
8 East by north EbN
9 East E
10 East by south EbS
11 East-southeast ESE
12 Southeast by east SEbE
13 Southeast SE
14 Southeast by south SEbS
15 South-southeast SSE
16 South by east SbE
17 South S
18 South by west SbW
19 South-southwest SSW
20 Southwest by south SWbS
21 Southwest SW
22 Southwest by west SWbW
23 West-southwest WSW
24 West by south WbS
25 West W
26 West by north WbN
27 West-northwest WNW
28 Northwest by west NWbW
29 Northwest NW
30 Northwest by north NWbN
31 North-northwest NNW
32 North by west NbW
您面临的挑战是以度为单位输入,并输出其对应的指南针方向的全名及其缩写。
测试用例:
Input Output
0 North N
23.97 North-northeast NNE
33.7 Northeast by north NEbN
73.12 East-northeast ENE
73.13 East by north EbN
219 Southwest by south SWbS
275 West W
276 West by north WbN
287 West-northwest WNW
与测试用例一样,必须保留所有大写字母。小数位数的最大值是2。所有输入数字都将大于或等于0且小于360。如果存在小数点,则两边都将有数字(您不必处理.1
或1.
)。
这是code-golf,因此以字节为单位的最短代码获胜。