-
Notifications
You must be signed in to change notification settings - Fork 0
/
d5.q
54 lines (41 loc) · 740 Bytes
/
d5.q
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
data:read0`:d5.txt
step:{[move; range]
diff:floor 0.5*range[1]-range[0];
map:"FBLR"!(
(range[0];range[0]+diff);
(range[1]-diff; range[1]);
(range[0];range[0]+diff);
(range[1]-diff; range[1])
);
map[move]
}
getSeat:{[bp]
i:0;
rows:0 127;
while[i<7;
rows:step[bp[i]; rows];
i+:1;
];
row:first rows;
colms:0 7;
while[i<10;
colms:step[bp[i]; colms];
i+:1;
];
colm:first colms;
(row;colm)
}
getID:{x[1]+8*x[0]}
getSeatID:{[bp] getID getSeat bp}
.d5.p1:{
max getSeatID each data
}
/ .d5.p1[]
.d5.p2:{
seats:8 cut asc getSeat each data;
badRow:seats -1+first where not 0=last each first each seats;
row:first first badRow;
colm:first (til 7) except last each badRow;
getID (row;colm)
}
/ .d5.p2[]