-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from fkdl0048/17-algospot-게임판-덮기
Sovle: BOARDCOVER
- Loading branch information
Showing
30 changed files
with
470 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BOARDCOVER", "BOARDCOVER.csproj", "{F82CED6D-BF45-4BE6-989F-BBADEB6BCB2D}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{F82CED6D-BF45-4BE6-989F-BBADEB6BCB2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{F82CED6D-BF45-4BE6-989F-BBADEB6BCB2D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{F82CED6D-BF45-4BE6-989F-BBADEB6BCB2D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{F82CED6D-BF45-4BE6-989F-BBADEB6BCB2D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {A23235E6-4196-4513-8249-34414E3E8A8B} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
namespace BOARDCOVER | ||
{ | ||
public class Board | ||
{ | ||
private static readonly int[,,] coverType = new int[4, 3, 2] | ||
{ | ||
{ { 0, 0 }, { 1, 0 }, { 0, 1 } }, | ||
{ { 0, 0 }, { 1, 0 }, { 1, 1 } }, | ||
{ { 0, 0 }, { 0, 1 }, { 1, 1 } }, | ||
{ { 0, 0 }, { 0, 1 }, { -1, 1 } } | ||
}; | ||
|
||
public int Hight { get; } | ||
public int Width { get; } | ||
private readonly bool[,] _board; | ||
|
||
public Board(int hight, int width) | ||
{ | ||
Hight = hight; | ||
Width = width; | ||
|
||
_board = new bool[Hight, Width]; | ||
|
||
for (var i = 0; i < Hight; i++) | ||
{ | ||
for (var j = 0; j < Width; j++) | ||
{ | ||
_board[i, j] = true; | ||
} | ||
} | ||
} | ||
|
||
public void SetBlock(int y, int x) | ||
{ | ||
_board[y, x] = false; | ||
} | ||
|
||
public void SetBlock(int x, int y, int type) | ||
{ | ||
for (var i = 0; i < 3; i++) | ||
{ | ||
var nx = x + coverType[type, i, 0]; | ||
var ny = y + coverType[type, i, 1]; | ||
|
||
SetBlock(ny, nx); | ||
} | ||
} | ||
|
||
public bool IsBlock(int y, int x) | ||
{ | ||
return _board[y, x]; | ||
} | ||
|
||
public bool CanSetBlock(int x, int y, int type) | ||
{ | ||
for (var i = 0; i < 3; i++) | ||
{ | ||
var nx = x + coverType[type, i, 0]; | ||
var ny = y + coverType[type, i, 1]; | ||
|
||
if (nx < 0 || nx >= Width || ny < 0 || ny >= Hight) | ||
{ | ||
return false; | ||
} | ||
|
||
if (!IsBlock(ny, nx)) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public void RemoveBlock(int x, int y, int type) | ||
{ | ||
for (var i = 0; i < 3; i++) | ||
{ | ||
var nx = x + coverType[type, i, 0]; | ||
var ny = y + coverType[type, i, 1]; | ||
|
||
_board[ny, nx] = true; | ||
} | ||
} | ||
|
||
public void Print() | ||
{ | ||
for (var i = 0; i < Hight; i++) | ||
{ | ||
for (var j = 0; j < Width; j++) | ||
{ | ||
System.Console.Write(_board[i, j] ? '.' : '#'); | ||
} | ||
|
||
System.Console.WriteLine(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
namespace BOARDCOVER | ||
{ | ||
public class BoardCalculator | ||
{ | ||
private readonly Board _board; | ||
|
||
public BoardCalculator(Board board) | ||
{ | ||
_board = board; | ||
} | ||
|
||
public (int y, int x) GetFirstBlock() | ||
{ | ||
for (var i = 0; i < _board.Hight; i++) | ||
{ | ||
for (var j = 0; j < _board.Width; j++) | ||
{ | ||
if (_board.IsBlock(i, j)) | ||
{ | ||
return (i, j); | ||
} | ||
} | ||
} | ||
|
||
return (-1, -1); | ||
} | ||
|
||
public int GetCoverCount() | ||
{ | ||
var (y, x) = GetFirstBlock(); | ||
|
||
if (y == -1) | ||
{ | ||
return 1; | ||
} | ||
|
||
var count = 0; | ||
|
||
for (var i = 0; i < 4; i++) | ||
{ | ||
if (_board.CanSetBlock(x, y, i)) | ||
{ | ||
_board.SetBlock(x, y, i); | ||
count += GetCoverCount(); | ||
_board.RemoveBlock(x, y, i); | ||
} | ||
} | ||
|
||
return count; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace BOARDCOVER | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var testCaseNumber = int.Parse(Console.ReadLine()!); | ||
|
||
for (int i = 0; i < testCaseNumber; i++) | ||
{ | ||
var input = Console.ReadLine()!.Split(' '); | ||
|
||
var hight = int.Parse(input[0]); | ||
var width = int.Parse(input[1]); | ||
|
||
var board = new Board(hight, width); | ||
|
||
for (var j = 0; j < hight; j++) | ||
{ | ||
var line = Console.ReadLine()!; | ||
|
||
for (var k = 0; k < width; k++) | ||
{ | ||
if (line[k] == '#') | ||
{ | ||
board.SetBlock(j, k); | ||
} | ||
} | ||
} | ||
|
||
var calculator = new BoardCalculator(board); | ||
|
||
Console.WriteLine(calculator.GetCoverCount()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"runtimeTarget": { | ||
"name": ".NETCoreApp,Version=v7.0", | ||
"signature": "" | ||
}, | ||
"compilationOptions": {}, | ||
"targets": { | ||
".NETCoreApp,Version=v7.0": { | ||
"BOARDCOVER/1.0.0": { | ||
"runtime": { | ||
"BOARDCOVER.dll": {} | ||
} | ||
} | ||
} | ||
}, | ||
"libraries": { | ||
"BOARDCOVER/1.0.0": { | ||
"type": "project", | ||
"serviceable": false, | ||
"sha512": "" | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions
9
2023/BOARDCOVER/bin/Debug/net7.0/BOARDCOVER.runtimeconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"runtimeOptions": { | ||
"tfm": "net7.0", | ||
"framework": { | ||
"name": "Microsoft.NETCore.App", | ||
"version": "7.0.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"format": 1, | ||
"restore": { | ||
"D:\\Algorithm\\2023\\BOARDCOVER\\BOARDCOVER.csproj": {} | ||
}, | ||
"projects": { | ||
"D:\\Algorithm\\2023\\BOARDCOVER\\BOARDCOVER.csproj": { | ||
"version": "1.0.0", | ||
"restore": { | ||
"projectUniqueName": "D:\\Algorithm\\2023\\BOARDCOVER\\BOARDCOVER.csproj", | ||
"projectName": "BOARDCOVER", | ||
"projectPath": "D:\\Algorithm\\2023\\BOARDCOVER\\BOARDCOVER.csproj", | ||
"packagesPath": "C:\\Users\\USER\\.nuget\\packages\\", | ||
"outputPath": "D:\\Algorithm\\2023\\BOARDCOVER\\obj\\", | ||
"projectStyle": "PackageReference", | ||
"configFilePaths": [ | ||
"C:\\Users\\USER\\AppData\\Roaming\\NuGet\\NuGet.Config" | ||
], | ||
"originalTargetFrameworks": [ | ||
"net7.0" | ||
], | ||
"sources": { | ||
"https://api.nuget.org/v3/index.json": {} | ||
}, | ||
"frameworks": { | ||
"net7.0": { | ||
"targetAlias": "net7.0", | ||
"projectReferences": {} | ||
} | ||
}, | ||
"warningProperties": { | ||
"warnAsError": [ | ||
"NU1605" | ||
] | ||
} | ||
}, | ||
"frameworks": { | ||
"net7.0": { | ||
"targetAlias": "net7.0", | ||
"imports": [ | ||
"net461", | ||
"net462", | ||
"net47", | ||
"net471", | ||
"net472", | ||
"net48", | ||
"net481" | ||
], | ||
"assetTargetFallback": true, | ||
"warn": true, | ||
"frameworkReferences": { | ||
"Microsoft.NETCore.App": { | ||
"privateAssets": "all" | ||
} | ||
}, | ||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.306\\RuntimeIdentifierGraph.json" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no"?> | ||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> | ||
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess> | ||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool> | ||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile> | ||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot> | ||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\USER\.nuget\packages\</NuGetPackageFolders> | ||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle> | ||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.6.0</NuGetToolVersion> | ||
</PropertyGroup> | ||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> | ||
<SourceRoot Include="C:\Users\USER\.nuget\packages\" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no"?> | ||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" /> |
4 changes: 4 additions & 0 deletions
4
2023/BOARDCOVER/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// <autogenerated /> | ||
using System; | ||
using System.Reflection; | ||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")] |
22 changes: 22 additions & 0 deletions
22
2023/BOARDCOVER/obj/Debug/net7.0/BOARDCOVER.AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
using System; | ||
using System.Reflection; | ||
|
||
[assembly: System.Reflection.AssemblyCompanyAttribute("BOARDCOVER")] | ||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] | ||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] | ||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] | ||
[assembly: System.Reflection.AssemblyProductAttribute("BOARDCOVER")] | ||
[assembly: System.Reflection.AssemblyTitleAttribute("BOARDCOVER")] | ||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] | ||
|
||
// Generated by the MSBuild WriteCodeFragment class. | ||
|
1 change: 1 addition & 0 deletions
1
2023/BOARDCOVER/obj/Debug/net7.0/BOARDCOVER.AssemblyInfoInputs.cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
083fce3fe7764a68a5c0219dfaea3c0a07959b30 |
11 changes: 11 additions & 0 deletions
11
2023/BOARDCOVER/obj/Debug/net7.0/BOARDCOVER.GeneratedMSBuildEditorConfig.editorconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
is_global = true | ||
build_property.TargetFramework = net7.0 | ||
build_property.TargetPlatformMinVersion = | ||
build_property.UsingMicrosoftNETSdkWeb = | ||
build_property.ProjectTypeGuids = | ||
build_property.InvariantGlobalization = | ||
build_property.PlatformNeutralAssembly = | ||
build_property.EnforceExtendedAnalyzerRules = | ||
build_property._SupportedPlatformList = Linux,macOS,Windows | ||
build_property.RootNamespace = BOARDCOVER | ||
build_property.ProjectDir = D:\Algorithm\2023\BOARDCOVER\ |
Oops, something went wrong.