June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
15
Task/Box-the-compass/Befunge/box-the-compass.bf
Normal file
15
Task/Box-the-compass/Befunge/box-the-compass.bf
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
>>::"}"9**\4+3%79*9*5-*79*9*5--+:5>>>06p:55+%68*+v
|
||||
^_@#!`*84:+1<v*9"}"*+55,,,".",,,$$_^#!:-1g60/+55\<
|
||||
>_06g:v>55+,^>/5+55+/48*::::,,,,%:1+.9,:06p48*\-0v
|
||||
|p60-1<|<!p80:<N|Ev"northwest"0"North by west"0p8<
|
||||
>:#,_>>>_08g1-^W|S>"-htroN"0"htron yb tsewhtroN"0v
|
||||
#v"est-northwest"0"Northwest by west"0"Northwest"<
|
||||
N>"W"0"htron yb tseW"0"tseW"0"htuos yb tseW"0"ts"v
|
||||
#v0"Southwest"0"Southwest by west"0"West-southwe"<
|
||||
S>"htuos yb tsewhtuoS"0"tsewhtuos-htuoS"0"tsew y"v
|
||||
#v"h-southeast"0"South by east"0"South"0"South b"<
|
||||
E>"tuoS"0"htuos yb tsaehtuoS"0"tsaehtuoS"0"tsae "v
|
||||
#v"East by south"0"East-southeast"0"Southeast by"<
|
||||
W>0"tsaE"0"htron yb tsaE"0"tsaehtron-tsaE"0"tsae"v
|
||||
#v"rtheast by north"0"Northeast"0"Northeast by "<<
|
||||
^>"oN"0"tsaehtron-htroN"0"tsae yb htroN"0"htroN"01
|
||||
|
|
@ -1,18 +1,15 @@
|
|||
# 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)...)
|
||||
majors = ("north", "east", "south", "ovest", "north", "east", "south", "ovest")
|
||||
quart1 = ("N", "N by E", "N-NE", "NE by N", "NE", "NE by E", "E-NE", "E by N")
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
|
|
|
|||
82
Task/Box-the-compass/Modula-2/box-the-compass.mod2
Normal file
82
Task/Box-the-compass/Modula-2/box-the-compass.mod2
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
MODULE BoxTheCompass;
|
||||
FROM FormatString IMPORT FormatString;
|
||||
FROM RealStr IMPORT RealToStr;
|
||||
FROM Terminal IMPORT WriteString,WriteLn,Write,ReadChar;
|
||||
|
||||
PROCEDURE expand(cp : ARRAY OF CHAR);
|
||||
VAR i : INTEGER = 0;
|
||||
BEGIN
|
||||
WHILE cp[i] # 0C DO
|
||||
IF i=0 THEN
|
||||
CASE cp[i] OF
|
||||
'N': WriteString("North") |
|
||||
'E': WriteString("East") |
|
||||
'S': WriteString("South") |
|
||||
'W': WriteString("West") |
|
||||
'b': WriteString(" by ")
|
||||
ELSE
|
||||
WriteString("-");
|
||||
END;
|
||||
ELSE
|
||||
CASE cp[i] OF
|
||||
'N': WriteString("north") |
|
||||
'E': WriteString("east") |
|
||||
'S': WriteString("south") |
|
||||
'W': WriteString("west") |
|
||||
'b': WriteString(" by ")
|
||||
ELSE
|
||||
WriteString("-");
|
||||
END;
|
||||
END;
|
||||
INC(i)
|
||||
END;
|
||||
END expand;
|
||||
|
||||
PROCEDURE FormatReal(r : REAL);
|
||||
VAR
|
||||
buf : ARRAY[0..63] OF CHAR;
|
||||
u,v : INTEGER;
|
||||
w : REAL;
|
||||
BEGIN
|
||||
u := TRUNC(r);
|
||||
w := r - FLOAT(u);
|
||||
v := TRUNC(100.0 * w);
|
||||
|
||||
FormatString("%6i.%'02i", buf, u, v);
|
||||
WriteString(buf);
|
||||
END FormatReal;
|
||||
|
||||
VAR
|
||||
cp : ARRAY[0..31] OF ARRAY[0..4] OF CHAR = {
|
||||
"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"
|
||||
};
|
||||
buf : ARRAY[0..63] OF CHAR;
|
||||
i,index : INTEGER;
|
||||
heading : REAL;
|
||||
BEGIN
|
||||
WriteString("Index Degrees Compass point");
|
||||
WriteLn;
|
||||
WriteString("----- ------- -------------");
|
||||
WriteLn;
|
||||
FOR i:=0 TO 32 DO
|
||||
index := i MOD 32;
|
||||
heading := FLOAT(i) * 11.25;
|
||||
CASE i MOD 3 OF
|
||||
1: heading := heading + 5.62; |
|
||||
2: heading := heading - 5.62;
|
||||
ELSE
|
||||
(* empty *)
|
||||
END;
|
||||
FormatString("%2i ", buf, index+1);
|
||||
WriteString(buf);
|
||||
FormatReal(heading);
|
||||
WriteString(" ");
|
||||
expand(cp[index]);
|
||||
WriteLn
|
||||
END;
|
||||
|
||||
ReadChar
|
||||
END BoxTheCompass.
|
||||
32
Task/Box-the-compass/Ring/box-the-compass.ring
Normal file
32
Task/Box-the-compass/Ring/box-the-compass.ring
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# Project : Box the compass
|
||||
# Date : 2017/12/31
|
||||
# Author : Gal Zsolt (~ CalmoSoft ~)
|
||||
# Email : <calmosoft@gmail.com>
|
||||
|
||||
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"]
|
||||
|
||||
degrees = [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]
|
||||
|
||||
for i = 1 to len(degrees)
|
||||
j = floor((degrees[i] + 5.625) / 11.25)
|
||||
if j > 31
|
||||
j = j - 32
|
||||
ok
|
||||
see "" + degrees[i] + " " + j + " "
|
||||
if j != 0
|
||||
see "" + names[j+1] + nl
|
||||
else
|
||||
see "" + names[len(names)] + nl
|
||||
ok
|
||||
next
|
||||
Loading…
Add table
Add a link
Reference in a new issue