Skip to content

Commit 5cdb422

Browse files
committed
update
1 parent 977287a commit 5cdb422

File tree

6 files changed

+42
-2
lines changed

6 files changed

+42
-2
lines changed

.vs/Fun Practice/v14/.suo

10.5 KB
Binary file not shown.

82_ClosestEnemy2.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// For this challenge you will search in a matrix for an enemy.
2+
/*
3+
have the function ClosestEnemyII(strArr) read the matrix of numbers stored in strArr which will be a 2D matrix that contains only the integers 1, 0, or 2. Then from the position in the matrix where a 1 is, return the number of spaces either left, right, down, or up you must move to reach an enemy which is represented by a 2. You are able to wrap around one side of the matrix to the other as well. For example: if strArr is ["0000", "1000", "0002", "0002"] then this looks like the following:
4+
5+
0 0 0 0
6+
1 0 0 0
7+
0 0 0 2
8+
0 0 0 2
9+
10+
For this input your program should return 2 because the closest enemy (2) is 2 spaces away from the 1 by moving left to wrap to the other side and then moving down once. The array will contain any number of 0's and 2's, but only a single 1. It may not contain any 2's at all as well, where in that case your program should return a 0.
11+
*/
12+
13+
#include <iostream>
14+
#include <string>
15+
using namespace std;
16+
17+
18+
// NOT FINISHED
19+
20+
string ClosestEnemyII(string strArr[], int size)
21+
{
22+
23+
}
24+
25+
int main()
26+
{
27+
string A[] = { "0000", "1000", "0002", "0002" };
28+
string B[] = { "000", "100", "200" };
29+
string C[] = { "0000", "2010", "0000", "2002" };
30+
31+
cout << ClosestEnemyII(A, sizeof(A) / sizeof(A[0])) << endl; // 2
32+
cout << ClosestEnemyII(B, sizeof(B) / sizeof(B[0])) << endl; // 1
33+
cout << ClosestEnemyII(C, sizeof(C) / sizeof(C[0])) << endl; // 2
34+
35+
return 0;
36+
}

Fun Practice.VC.db

0 Bytes
Binary file not shown.

Fun Practice.vcxproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
</ItemGroup>
1313
<ItemGroup>
1414
<ClCompile Include="81_MovingMedian.cpp" />
15+
<ClCompile Include="82_ClosestEnemy2.cpp" />
1516
</ItemGroup>
1617
<PropertyGroup Label="Globals">
1718
<ProjectGuid>{48DF0788-2D72-474C-9946-5512D2A5D092}</ProjectGuid>
@@ -23,7 +24,7 @@
2324
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
2425
<ConfigurationType>Application</ConfigurationType>
2526
<UseDebugLibraries>true</UseDebugLibraries>
26-
<PlatformToolset>v120</PlatformToolset>
27+
<PlatformToolset>v140</PlatformToolset>
2728
<CharacterSet>Unicode</CharacterSet>
2829
</PropertyGroup>
2930
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">

Fun Practice.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@
1818
<ClCompile Include="81_MovingMedian.cpp">
1919
<Filter>Source Files</Filter>
2020
</ClCompile>
21+
<ClCompile Include="82_ClosestEnemy2.cpp">
22+
<Filter>Source Files</Filter>
23+
</ClCompile>
2124
</ItemGroup>
2225
</Project>

Fun Practice.vcxproj.user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<ShowAllFiles>true</ShowAllFiles>
4+
<ShowAllFiles>false</ShowAllFiles>
55
</PropertyGroup>
66
</Project>

0 commit comments

Comments
 (0)