Box the compass: Difference between revisions
m
J: format numbers more regularly
(+Java, fix VB.NET highlighting) |
m (J: format numbers more regularly) |
||
Line 34:
As for the required example, sometimes it's simpler to do just a small bit of "extra" work:
<lang j>
1 North
2 North by east 5.63 11.25 16.87
3 North-northeast 16.88
4 Northeast by north 28.13 33.75 39.37
5 Northeast 39.38
6 Northeast by east 50.63 56.25 61.87
7 Northeast-east 61.88
8 East by north 73.13 78.75 84.37
9 East 84.38
10 East by south 95.63 101.25 106.87
11 East-southeast 106.88
12 Southeast by east 118.13 123.75 129.37
13 Southeast 129.38
14 Southeast by south 140.63 146.25 151.87
15 Southeast-south 151.88
16 South by east 163.13 168.75 174.37
17 South 174.38
18 South by west 185.63 191.25 196.87
19 South-southwest 196.88
20 Southwest by south 208.13 213.75 219.37
21 Southwest 219.38
22 Southwest by west 230.63 236.25 241.87
23 Southwest-west 241.88
24 West by south 253.13 258.75 264.37
25 West 264.38
26 West by north 275.63 281.25 286.87
27 West-northwest 286.88
28 Northwest by west 298.13 303.75 309.37
29 Northwest 309.38
30 Northwest by north 320.63 326.25 331.87
31 Northwest-north 331.88
32 North by west 343.13 348.75 354.37
1 North 354.38
Here, I compute the name (and index) for each of the numbers, and then find the unique list of names (and indices) represented in each row -- which is always only one name (and only one index) -- and convert the whole thing to characters.
=={{header|Java}}==
{{trans|Visual Basic .NET}}
|