part 2 solution ez
This commit is contained in:
parent
33edb499c8
commit
65c3087c24
1 changed files with 21 additions and 63 deletions
|
@ -51,86 +51,44 @@ fn main() {
|
||||||
println!("width up: {}", widthup);
|
println!("width up: {}", widthup);
|
||||||
println!("width down: {}", widthdown);
|
println!("width down: {}", widthdown);
|
||||||
println!("width left: {}", widthleft);
|
println!("width left: {}", widthleft);
|
||||||
|
if widthup && widthleft && widthdown && widthright {
|
||||||
// check if start from top
|
// check if start from top
|
||||||
if widthup {
|
if frfrvec[y - 1][x - 1] == 'M' // up left
|
||||||
if frfrvec[y - 1][x] == 'M'
|
&& frfrvec[y - 1][x + 1] == 'M' // up right
|
||||||
&& frfrvec[y - 2][x] == 'A'
|
&& frfrvec[y + 1][x - 1] == 'S' // down left
|
||||||
&& frfrvec[y - 3][x] == 'S'
|
&& frfrvec[y + 1][x + 1] == 'S' // down right
|
||||||
{
|
{
|
||||||
pointcounter += 1;
|
pointcounter += 1;
|
||||||
println!("successful up");
|
println!("successful up");
|
||||||
}
|
}
|
||||||
}
|
// check if start from left
|
||||||
// check if going diag up left
|
if frfrvec[y - 1][x - 1] == 'M' // up left
|
||||||
if widthup && widthleft {
|
&& frfrvec[y - 1][x + 1] == 'S' // up right
|
||||||
if frfrvec[y - 1][x - 1] == 'M'
|
&& frfrvec[y + 1][x - 1] == 'M' // down left
|
||||||
&& frfrvec[y - 2][x - 2] == 'A'
|
&& frfrvec[y + 1][x + 1] == 'S' // down right
|
||||||
&& frfrvec[y - 3][x - 3] == 'S'
|
|
||||||
{
|
|
||||||
pointcounter += 1;
|
|
||||||
println!("successful up left");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// check if going left
|
|
||||||
if widthleft {
|
|
||||||
if frfrvec[y][x - 1] == 'M'
|
|
||||||
&& frfrvec[y][x - 2] == 'A'
|
|
||||||
&& frfrvec[y][x - 3] == 'S'
|
|
||||||
{
|
{
|
||||||
pointcounter += 1;
|
pointcounter += 1;
|
||||||
println!("successful left");
|
println!("successful left");
|
||||||
}
|
}
|
||||||
}
|
// check if start from bottom
|
||||||
// check if going diag down left
|
if frfrvec[y - 1][x - 1] == 'S' // up left
|
||||||
if widthdown && widthleft {
|
&& frfrvec[y - 1][x + 1] == 'S' // up right
|
||||||
if frfrvec[y + 1][x - 1] == 'M'
|
&& frfrvec[y + 1][x - 1] == 'M' // down left
|
||||||
&& frfrvec[y + 2][x - 2] == 'A'
|
&& frfrvec[y + 1][x + 1] == 'M' // down right
|
||||||
&& frfrvec[y + 3][x - 3] == 'S'
|
|
||||||
{
|
|
||||||
pointcounter += 1;
|
|
||||||
println!("successful down left");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// check if going down
|
|
||||||
if widthdown {
|
|
||||||
if frfrvec[y + 1][x] == 'M'
|
|
||||||
&& frfrvec[y + 2][x] == 'A'
|
|
||||||
&& frfrvec[y + 3][x] == 'S'
|
|
||||||
{
|
{
|
||||||
pointcounter += 1;
|
pointcounter += 1;
|
||||||
println!("successful down");
|
println!("successful down");
|
||||||
}
|
}
|
||||||
}
|
// check if start from right
|
||||||
// check if going diag down right
|
if frfrvec[y - 1][x - 1] == 'S' // up left
|
||||||
if widthdown && widthright {
|
&& frfrvec[y - 1][x + 1] == 'M' // up right
|
||||||
if frfrvec[y + 1][x + 1] == 'M'
|
&& frfrvec[y + 1][x - 1] == 'S' // down left
|
||||||
&& frfrvec[y + 2][x + 2] == 'A'
|
&& frfrvec[y + 1][x + 1] == 'M' // down right
|
||||||
&& frfrvec[y + 3][x + 3] == 'S'
|
|
||||||
{
|
|
||||||
pointcounter += 1;
|
|
||||||
println!("successful down right");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// check if going right
|
|
||||||
if widthright {
|
|
||||||
if frfrvec[y][x + 1] == 'M'
|
|
||||||
&& frfrvec[y][x + 2] == 'A'
|
|
||||||
&& frfrvec[y][x + 3] == 'S'
|
|
||||||
{
|
{
|
||||||
pointcounter += 1;
|
pointcounter += 1;
|
||||||
println!("successful right");
|
println!("successful right");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check if going diag right up
|
|
||||||
if widthright && widthup {
|
|
||||||
if frfrvec[y - 1][x + 1] == 'M'
|
|
||||||
&& frfrvec[y - 2][x + 2] == 'A'
|
|
||||||
&& frfrvec[y - 3][x + 3] == 'S'
|
|
||||||
{
|
|
||||||
pointcounter += 1;
|
|
||||||
println!("successful up right");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
println!("\n")
|
println!("\n")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue