Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
32
Task/Box-the-compass/FreeBASIC/box-the-compass.freebasic
Normal file
32
Task/Box-the-compass/FreeBASIC/box-the-compass.freebasic
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
' version 04-11-2016
|
||||
' compile with: fbc -s console
|
||||
|
||||
Dim As String names(0 To ...) = { "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" }
|
||||
|
||||
Dim As Double degrees(0 To ...) = { 0, 16.87, 16.88, 33.75, 50.62, 50.63, _
|
||||
67.5, 84.37, 84.38, 101.25, 118.12, 118.13, 135, 151.87, 151.88, 168.75, _
|
||||
185.62, 185.63, 202.5, 219.37, 219.38, 236.25, 253.12, 253.13, 270, _
|
||||
286.87, 286.88, 303.75, 320.62, 320.63, 337.5, 354.37, 354.38 }
|
||||
|
||||
Dim As ULong i, j
|
||||
|
||||
For i = LBound(degrees) To UBound(degrees)
|
||||
j = Int((degrees(i) + 5.625) / 11.25)
|
||||
If j > 31 Then j = j - 32
|
||||
Print Using "####.## ## "; degrees(i); j;
|
||||
Print names(j)
|
||||
Next
|
||||
|
||||
' empty keyboard buffer
|
||||
While Inkey <> "" : Wend
|
||||
Print : Print "hit any key to end program"
|
||||
Sleep
|
||||
End
|
||||
52
Task/Box-the-compass/Lasso/box-the-compass.lasso
Normal file
52
Task/Box-the-compass/Lasso/box-the-compass.lasso
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
define pointsarray() => {
|
||||
local(points = array)
|
||||
loop(-from=0,-to=32) => {
|
||||
local(heading = loop_count * 11.25)
|
||||
if(loop_count % 3 == 1) => {
|
||||
#heading += 5.62
|
||||
else(loop_count % 3 == 2)
|
||||
#heading -= 5.62
|
||||
}
|
||||
#points->insert(#heading)
|
||||
}
|
||||
return #points
|
||||
}
|
||||
define compassShort => array(
|
||||
'N','Nbe','N-ne','Nebn','Ne','Nebe','E-ne','Ebn',
|
||||
'E','Ebs','E-se','Sebe','Se','Sebs','S-se','Sbe',
|
||||
'S','Sbw','S-sw','Swbs','Sw','Swbw','W-sw','Wbs',
|
||||
'W','Wbn','W-nw','Nwbw','Nw','Nwbn','N-nw','Nbw', 'N')
|
||||
define compassLong(short::string) => {
|
||||
local(o = string)
|
||||
with i in #short->values do => { #o->append(compassLongProcessor(#i)) }
|
||||
return #o
|
||||
}
|
||||
define compassLongProcessor(char::string) => {
|
||||
#char == 'N' ? return #char + 'orth'
|
||||
#char == 'S' ? return #char + 'outh'
|
||||
#char == 'E' ? return #char + 'ast'
|
||||
#char == 'W' ? return #char + 'est'
|
||||
#char == 'b' ? return ' by '
|
||||
#char == '-' ? return '-'
|
||||
}
|
||||
// test output points as decimals
|
||||
//pointsarray
|
||||
|
||||
// test output the array of text values
|
||||
//compassShort
|
||||
|
||||
// test output the long names of the text values
|
||||
//with s in compassShort do => {^ compassLong(#s) + '\r' ^}
|
||||
|
||||
'angle | box | compass point
|
||||
---------------------------------
|
||||
'
|
||||
local(counter = 0)
|
||||
with p in pointsarray do => {^
|
||||
local(pformatted = #p->asString(-precision=2))
|
||||
while(#pformatted->size < 6) => { #pformatted->append(' ') }
|
||||
#counter += 1
|
||||
#counter > 32 ? #counter = 1
|
||||
#pformatted + ' | ' + (#counter < 10 ? ' ') + #counter + ' | ' + compassLong(compassShort->get(#counter)) + '\r'
|
||||
|
||||
^}
|
||||
18
Task/Box-the-compass/Nim/box-the-compass.nim
Normal file
18
Task/Box-the-compass/Nim/box-the-compass.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import strfmt
|
||||
|
||||
const 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"]
|
||||
|
||||
for i in 0..32:
|
||||
let j = i mod 32
|
||||
var d = float(i) * 11.25
|
||||
if i mod 3 == 1: d += 5.62
|
||||
if i mod 3 == 2: d -= 5.62
|
||||
printlnfmt "{:2} {:18} {:>6.2f}", j + 1, names[j], d
|
||||
48
Task/Box-the-compass/Phix/box-the-compass.phix
Normal file
48
Task/Box-the-compass/Phix/box-the-compass.phix
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
function get225(integer d, string p1, string p2, string p4)
|
||||
string p3
|
||||
p3 = p1&'-'&lower(p2)
|
||||
p2 &= " by "&lower(p1)
|
||||
p1 &= " by "&lower(p4)
|
||||
if d then
|
||||
return {p1,p3,p2} -- eg {North by east,North-northeast,Northeast by north}
|
||||
else
|
||||
return {p2,p3,p1} -- eg {Northeast by east,East-northeast,East by north}
|
||||
end if
|
||||
end function
|
||||
|
||||
function get45(sequence res, integer d, string p1, string p2)
|
||||
string p3
|
||||
res = append(res,p1) -- North/East/South/West
|
||||
if d then
|
||||
p3 = p1&lower(p2) -- Northeast/Southwest
|
||||
else
|
||||
p3 = p2&lower(p1) -- Southeast/Northwest
|
||||
end if
|
||||
res &= get225(1,p1,p3,p2) -- eg get225(1,North,Northeast,East)
|
||||
-- -> {North by east,North-northeast,Northeast by north}
|
||||
res = append(res,p3) -- Northeast/Southeast/Southwest/Northwest
|
||||
res &= get225(0,p2,p3,p1) -- eg get225(0,East,Northeast,North)
|
||||
-- -> {Northeast by east,East-northeast,East by north}
|
||||
return res
|
||||
end function
|
||||
|
||||
function get90(sequence points)
|
||||
sequence res = {}
|
||||
for i=1 to length(points) do
|
||||
res = get45(res,remainder(i,2),points[i],points[remainder(i,4)+1])
|
||||
end for -- ie get45(1,North,East)
|
||||
-- get45(0,East,South)
|
||||
-- get45(1,South,West)
|
||||
-- get45(0,West,North)
|
||||
return res
|
||||
end function
|
||||
|
||||
constant compass_points = get90({"North","East","South","West"})
|
||||
|
||||
atom test_point
|
||||
integer compass_point
|
||||
for i = 1 to 33 do
|
||||
test_point = (i-1)*11.25 + 5.62*(remainder(i,3)-1)
|
||||
compass_point = remainder(floor(test_point*32/360+0.5),32)+1
|
||||
printf(1, "%2d %-22s %6.2f\n", {compass_point, compass_points[compass_point], test_point})
|
||||
end for
|
||||
15
Task/Box-the-compass/Sidef/box-the-compass.sidef
Normal file
15
Task/Box-the-compass/Sidef/box-the-compass.sidef
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
func point (index) {
|
||||
var ix = (index % 32);
|
||||
if (ix & 1) { "#{point((ix + 1) & 28)} by #{point(((2 - (ix & 2)) * 4) + ix & 24)}" }
|
||||
elsif (ix & 2) { "#{point((ix + 2) & 24)}-#{point((ix | 4) & 28)}" }
|
||||
elsif (ix & 4) { "#{point((ix + 8) & 16)}#{point((ix | 8) & 24)}" }
|
||||
else { <north east south west>[ix / 8] }
|
||||
}
|
||||
|
||||
func test_angle (ix) { ix * 11.25 + [0, 5.62, -5.62][ ix % 3 ] };
|
||||
func angle_to_point(𝜽) { (𝜽 / 360 * 32) + 0.5 -> floor };
|
||||
|
||||
for ix in range(0, 32) {
|
||||
var 𝜽 = test_angle(ix);
|
||||
printf(" %2d %6.2f° %s\n", ix % 32 + 1, 𝜽, point(angle_to_point(𝜽)).tc);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue