September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
26
Task/Box-the-compass/Julia/box-the-compass.julia
Normal file
26
Task/Box-the-compass/Julia/box-the-compass.julia
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# v0.6
|
||||
|
||||
function degree2compasspoint(d::Float64)::String
|
||||
const MAJORS = ("north", "east", "south", "ovest", "north", "east", "south", "ovest")
|
||||
const QUART1 = ("N", "N by E", "N-NE", "NE by N", "NE", "NE by E", "E-NE", "E by N")
|
||||
const QUART2 = tuple((replace(p, "NE", "EN") for p in QUART1)...)
|
||||
|
||||
d = (d % 360) + 360/64
|
||||
majorindex, minor = divrem(d, 90)
|
||||
minorindex = div(minor * 4, 45)
|
||||
majorindex += 1
|
||||
minorindex += 1
|
||||
p1, p2 = MAJORS[majorindex:majorindex+1]
|
||||
if p1 in ("north", "south"); q = QUART1
|
||||
else q = QUART1 end
|
||||
return titlecase(replace(replace(q[minorindex], 'N', p1), 'E', p2))
|
||||
end
|
||||
|
||||
for i in 0:32
|
||||
d = i * 11.25
|
||||
m = i % 3
|
||||
if m == 1; d += 5.62 end
|
||||
if m == 2; d -= 5.62 end
|
||||
n = i % 32 + 1
|
||||
@printf("%2i %-17s %10.2f°\n", n, degree2compasspoint(d), d)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue