-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.sol
63 lines (52 loc) · 1.13 KB
/
2.sol
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
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.7;
contract Knight {
int8 private x;
int8 private y;
function isValidPosition() internal view returns (bool) {
return x >= 0 && x < 8 && y >= 0 && y < 8;
}
function move1() public {
x += 1;
y += 2;
require(isValidPosition());
}
function move2() public {
x += 2;
y += 1;
require(isValidPosition());
}
function move3() public {
x += 2;
y -= 1;
require(isValidPosition());
}
function move4() public {
x -= 1;
y -= 2;
require(isValidPosition());
}
function move5() public {
x -= 1;
y += 2;
require(isValidPosition());
}
function move6() public {
x -= 2;
y += 1;
require(isValidPosition());
}
function move7() public {
x -= 2;
y -= 1;
require(isValidPosition());
}
function move8() public {
x -= 1;
y -= 2;
require(isValidPosition());
}
function get_to_7_7() public view {
assert(!(x == 7 && y == 7));
}
}