Box the compass: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: added syntax colouring, marked p2js compatible) |
|||
Line 5,367: | Line 5,367: | ||
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span> |
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span> |
||
<!--</lang>--> |
<!--</lang>--> |
||
=={{header|Picat}}== |
|||
(Inspired by the Nim solution.) |
|||
<lang Picat>go => |
|||
Names = ["North", "North by east", "North-northeast", "Northeast by north", |
|||
"Northeast", "Northeast by east", "East-northeast", "East by north", |
|||
"East", "East by south", "East-southeast", "Southeast by east", |
|||
"Southeast", "Southeast by south","South-southeast", "South by east", |
|||
"South", "South by west", "South-southwest", "Southwest by south", |
|||
"Southwest", "Southwest by west", "West-southwest", "West by south", |
|||
"West", "West by north", "West-northwest", "Northwest by west", |
|||
"Northwest", "Northwest by north", "North-northwest", "North by west", "North" |
|||
], |
|||
foreach(I in 0..32) |
|||
J = I mod 32, |
|||
D = I * 11.25, |
|||
if I mod 3 == 1 then D := D + 5.62 end, |
|||
if I mod 3 == 2 then D := D - 5.62 end, |
|||
printf("%2d %-20s %6.2f\n", J+1, Names[J+1], D) |
|||
end, |
|||
nl.</lang> |
|||
Output: |
|||
<pre> 1 North 0.00 |
|||
2 North by east 16.87 |
|||
3 North-northeast 16.88 |
|||
4 Northeast by north 33.75 |
|||
5 Northeast 50.62 |
|||
6 Northeast by east 50.63 |
|||
7 East-northeast 67.50 |
|||
8 East by North 84.37 |
|||
9 East 84.38 |
|||
10 East by south 101.25 |
|||
11 East-southeast 118.12 |
|||
12 Southeast by east 118.13 |
|||
13 Southeast 135.00 |
|||
14 Southeast by south 151.87 |
|||
15 South-southeast 151.88 |
|||
16 South by east 168.75 |
|||
17 South 185.62 |
|||
18 South by west 185.63 |
|||
19 South-southwest 202.50 |
|||
20 Southwest by south 219.37 |
|||
21 Southwest 219.38 |
|||
22 Southwest by west 236.25 |
|||
23 West-southwest 253.12 |
|||
24 West by south 253.13 |
|||
25 West 270.00 |
|||
26 West by north 286.87 |
|||
27 West-northwest 286.88 |
|||
28 Northwest by west 303.75 |
|||
29 Northwest 320.62 |
|||
30 Northwest by north 320.63 |
|||
31 North-northwest 337.50 |
|||
32 North by west 354.37 |
|||
1 North 354.38</pre> |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |