How to resolve the algorithm Box the compass step by step in the Euphoria programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Box the compass step by step in the Euphoria programming language
Table of Contents
Problem Statement
There be many a land lubber that knows naught of the pirate ways and gives direction by degree! They know not how to box the compass!
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Box the compass step by step in the Euphoria programming language
Source code in the euphoria programming language
constant 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"}
function deg2ind(atom degree)
return remainder(floor(degree*32/360+.5),32)+1
end function
sequence degrees
degrees = {}
for i = 0 to 32 do
degrees &= i*11.25 + 5.62*(remainder(i+1,3)-1)
end for
integer j
for i = 1 to length(degrees) do
j = deg2ind(degrees[i])
printf(1, "%6.2f %2d %-22s\n", {degrees[i], j, names[j]})
end for
You may also check:How to resolve the algorithm Regular expressions step by step in the zkl programming language
You may also check:How to resolve the algorithm Long year step by step in the Perl programming language
You may also check:How to resolve the algorithm Fraction reduction step by step in the Delphi programming language
You may also check:How to resolve the algorithm Boolean values step by step in the Brainf*** programming language
You may also check:How to resolve the algorithm Video display modes step by step in the 8086 Assembly programming language