-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask_15.jl
65 lines (65 loc) · 1.56 KB
/
task_15.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function mark_frame_perimetr!(r::Robot)
num_vert,num_hor = ugol(r)
for side in (Nord,Ost,Sud,West)
while isborder(r,side)==false
putmarkers!(r,side)
end
end
moves!(r, Ost, num_hor)
moves1!(r, Nord, num_vert)
end
function moves!(r::Robot,side::HorizonSide)
num_steps=0
while isborder(r,side)==false
move!(r,side)
num_steps+=1
end
return num_steps
end
function moves!(r::Robot,side::HorizonSide,num_steps::Int)
for _ in 1:num_steps
move!(r,side)
end
end
function moves1!(r::Robot,side::HorizonSide,num_steps::Int)
q=0
while q<num_steps
if isborder(r,Nord)==true
while isborder(r,side)==true
move!(r,Ost)
end
move!(r,Nord)
q+=1
if isborder(r,West)==true
while isborder(r,West)==true
move!(r,Nord)
q+=1
end
end
move!(r,West)
end
if q<num_steps
move!(r,side)
q+=1
end
end
end
function putmarkers!(r::Robot, side::HorizonSide)
while isborder(r,side)==false
move!(r,side)
putmarker!(r)
end
if isborder(r,side)==true
putmarker!(r)
end
end
function ugol(r::Robot)
num_vert=0
num_hor=0
while (isborder(r,Sud)==false || isborder(r,West)==false)
num_vert+= moves!(r, Sud)
num_hor+= moves!(r, West)
repeat
end
return num_vert,num_hor
end