Skip to content

Commit 49d916c

Browse files
FireControl c++
1 parent 9e3bfcc commit 49d916c

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

Puzzles/Easy/FireControl/C++.cpp

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <vector>
4+
#include <algorithm>
5+
6+
using namespace std;
7+
8+
const int FOREST_SIZE = 6;
9+
10+
int main()
11+
{
12+
int treeNeedCut = 0, countFire = 0, countNotTreeFire = 0;
13+
string forest[FOREST_SIZE];
14+
for (int i = 0; i < FOREST_SIZE; i++)
15+
{
16+
getline(cin, forest[i]);
17+
}
18+
for (int i = 0; i < FOREST_SIZE; i++)
19+
{
20+
for (int j = 0; j < FOREST_SIZE; j++)
21+
{
22+
if (forest[i][j] == '*')
23+
{
24+
countFire++;
25+
int indexHelper[24][2] = {{i - 2, j - 2}, {i - 2, j - 1}, {i - 2, j}, {i - 2, j + 1}, {i - 2, j + 2}, {i - 1, j - 2}, {i - 1, j - 1}, {i - 1, j}, {i - 1, j + 1}, {i - 1, j + 2}, {i, j - 2}, {i, j - 1}, {i, j + 1}, {i, j + 2}, {i + 1, j - 2}, {i + 1, j - 1}, {i + 1, j}, {i + 1, j + 1}, {i + 1, j + 2}, {i + 2, j - 2}, {i + 2, j - 1}, {i + 2, j}, {i + 2, j + 1}, {i + 2, j + 2}};
26+
for (int indexPos = 0; indexPos < 24; indexPos++)
27+
{
28+
int _i = indexHelper[indexPos][0];
29+
int _j = indexHelper[indexPos][1];
30+
if (_i >= 0 && _i < FOREST_SIZE && _j >= 0 && _j < FOREST_SIZE)
31+
{
32+
if (forest[_i][_j] == '#')
33+
{
34+
treeNeedCut++;
35+
forest[_i][_j] = '0';
36+
}
37+
}
38+
}
39+
}
40+
else if (forest[i][j] == '=' || forest[i][j] == 'o')
41+
{
42+
countNotTreeFire++;
43+
}
44+
}
45+
}
46+
if (countFire == 0)
47+
{
48+
cout << "RELAX\n";
49+
}
50+
else if (countFire + treeNeedCut + countNotTreeFire == 36 || treeNeedCut == 0)
51+
{
52+
cout << "JUST RUN\n";
53+
}
54+
else
55+
{
56+
cout << treeNeedCut << '\n';
57+
}
58+
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ You will find all my puzzle solutions on Codingame here. I have been registered
9595
| 081 | [Ghost Legs](https://www.codingame.com/training/easy/ghost-legs) | :heavy_check_mark: Completed | [C++](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/Ghost%20Legs/C++.cpp)<br>[Python](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/Ghost%20Legs/Python.py)<br>[JS](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/Ghost%20Legs/Javascript.js) | 20-04-2023<br>09-03-2023<br>15-04-2022 |
9696
| 082 | [ASCII Art](https://www.codingame.com/training/easy/ascii-art) | :heavy_check_mark: Completed | [C++](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/ASCII%20Art/C++.cpp)<br>[Python](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/ASCII%20Art/Python.py)<br>[JS](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/ASCII%20Art/Javascript.js)<br>[C#](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/ASCII%20Art/CSharp.cs) | 20-04-2023<br>09-03-2023<br>16-04-2022<br>28-04-2018 |
9797
| 083 | [7-segment scanner](https://www.codingame.com/training/easy/7-segment-scanner) | :heavy_check_mark: Completed | [C++](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/7-segment%20scanner/C++.cpp)<br>[Python](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/7-segment%20scanner/Python.py)<br>[JS](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/7-segment%20scanner/Javascript.js) | 20-04-2023<br>09-03-2023<br>01-05-2022 |
98-
| 084 | [FireControl](https://www.codingame.com/training/easy/firecontrol) | :heavy_check_mark: Completed | [Python](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/FireControl/Python.py)<br>[JS](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/FireControl/Javascript.js) | 09-03-2023<br>02-05-2022 |
98+
| 084 | [FireControl](https://www.codingame.com/training/easy/firecontrol) | :heavy_check_mark: Completed | [C++](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/FireControl/C++.cpp)<br>[Python](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/FireControl/Python.py)<br>[JS](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/FireControl/Javascript.js) | 09-03-2023<br>02-05-2022 |
9999
| 085 | [How time flies](https://www.codingame.com/training/easy/how-time-flies) | :heavy_check_mark: Completed | [Python](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/How%20time%20flies/Python.py)<br>[JS](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/How%20time%20flies/Javascript.js) | 09-03-2023<br>18-10-2022 |
100100
| 086 | [Unit Fractions](https://www.codingame.com/training/easy/unit-fractions) | :heavy_check_mark: Completed | [JS](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/Unit%20Fractions/Javascript.js) | 14-03-2023 |
101101
| 087 | [The broken editor](https://www.codingame.com/training/easy/the-broken-editor) | :heavy_check_mark: Completed | [JS](https://github.com/SlicedPotatoes/CodinGame/blob/main/Puzzles/Easy/The%20broken%20editor/Javascript.js) | 22-03-2023 |

0 commit comments

Comments
 (0)