Completed Day 11 !
This commit is contained in:
parent
aaf61c24f1
commit
f0d9f9b787
@ -130,6 +130,8 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="olcPixelGameEngine.h" />
|
||||
<ClInclude Include="stb_image.h" />
|
||||
<ClInclude Include="stb_image_write.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
|
@ -18,6 +18,12 @@
|
||||
<ClInclude Include="olcPixelGameEngine.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stb_image.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stb_image_write.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
|
BIN
Day 10/day10_examplerender.png
Normal file
BIN
Day 10/day10_examplerender.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 3.6 KiB |
BIN
Day 10/day10_fullrender.png
Normal file
BIN
Day 10/day10_fullrender.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 756 KiB |
@ -1,4 +1,8 @@
|
||||
#pragma region Hidden Setup Stuff
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
#define OLC_IMAGE_STB
|
||||
#define OLC_PGE_APPLICATION
|
||||
#include "olcPixelGameEngine.h"
|
||||
|
||||
@ -19,12 +23,13 @@ void wait(int pauseMs=0){
|
||||
waitForRender=true;
|
||||
while(waitForRender);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(pauseMs));
|
||||
stbi_write_png("file.png", GetDrawTarget()->width, GetDrawTarget()->height, 4, GetDrawTarget()->GetData(), GetDrawTarget()->width * 4);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
const int DAY = 10;
|
||||
Run runInput=FILE2;
|
||||
Run runInput=FILE1;
|
||||
|
||||
|
||||
enum Direction{
|
||||
@ -324,6 +329,7 @@ void doStuff(){
|
||||
}
|
||||
*/
|
||||
void draw(){ //Only use Sprites! If using decals, you must reference global variables!
|
||||
SetScreenSize(tiles[0].size()*8,tiles.size()*8);
|
||||
Clear(BLACK);
|
||||
int count=0;
|
||||
for(int y=0;std::vector<Pipe>&row:tiles){
|
||||
|
7987
Day 10/stb_image.h
Normal file
7987
Day 10/stb_image.h
Normal file
File diff suppressed because it is too large
Load Diff
1724
Day 10/stb_image_write.h
Normal file
1724
Day 10/stb_image_write.h
Normal file
File diff suppressed because it is too large
Load Diff
140
Day 11/Day 11.vcxproj
Normal file
140
Day 11/Day 11.vcxproj
Normal file
@ -0,0 +1,140 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{520a82a0-bd04-44d6-b361-07f095a5aba0}</ProjectGuid>
|
||||
<RootNamespace>Day_11</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="olcPixelGameEngine.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
27
Day 11/Day 11.vcxproj.filters
Normal file
27
Day 11/Day 11.vcxproj.filters
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="olcPixelGameEngine.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
10
Day 11/day11_1.txt
Normal file
10
Day 11/day11_1.txt
Normal file
@ -0,0 +1,10 @@
|
||||
...#......
|
||||
.......#..
|
||||
#.........
|
||||
..........
|
||||
......#...
|
||||
.#........
|
||||
.........#
|
||||
..........
|
||||
.......#..
|
||||
#...#.....
|
140
Day 11/day11_2.txt
Normal file
140
Day 11/day11_2.txt
Normal file
@ -0,0 +1,140 @@
|
||||
.....................#..................#..................................................................#...........#....................
|
||||
................................................................#..................#........................................................
|
||||
..........................#.....#.............................................................#........#..................................#.
|
||||
...#.......#...........................................#........................................................#...........................
|
||||
............................................................................................................................................
|
||||
........................................................................#.....#.................................................#......#....
|
||||
...............................................#.................#...................#......#..............#................................
|
||||
.................#.................#.....................................................................................#.................#
|
||||
......................#....................................................#................................................................
|
||||
...........#.......................................................................................#........................................
|
||||
...........................#......................#............................#.......#.....................................#..............
|
||||
........................................................#......#.......#................................#.........................#......#..
|
||||
...............................................................................................#............................................
|
||||
.#.....................#..................#.....................................................................#...........................
|
||||
..............................#......#.................................................................................#....................
|
||||
................#....................................#.......................#..............................................................
|
||||
........#...................................................................................#..............................................#
|
||||
.........................#....................................#.......................................#............#........................
|
||||
...................................................................#..............#.........................................................
|
||||
..................................#...........#...............................................................#.............................
|
||||
.#.................................................................................................#.....................#..................
|
||||
.........#...................................................................................#..............................................
|
||||
..............#........................#...............#.............#...............................................................#......
|
||||
..........................#............................................................................#.............#......................
|
||||
.................................................................................#.....#....................................................
|
||||
.......#...................................................#...............#....................................................#...........
|
||||
....................................#.......#.....................................................#.........................................
|
||||
#...............................................................#.....................................................................#.....
|
||||
...............#..................................#.........................................................#..........#....................
|
||||
................................#.................................................................................................#.........
|
||||
.........................#.......................................................#.........................................................#
|
||||
............................................................#...........#...............#...................................................
|
||||
....#......#.....................................................#..........................................................................
|
||||
........................................................................................................#.......................#.....#.....
|
||||
.............................................................................................#..............................................
|
||||
....................................#........#.......................................#.....................................#................
|
||||
...........................................................................................................#.......#........................
|
||||
#........................#.............................#..........................................................................#.........
|
||||
...........#......................................#.........................#..........................#.................................#..
|
||||
................#.....................#...........................................#.........................................................
|
||||
...#.............................#...........................................................................#.........#....................
|
||||
............................................#.......................#...........................#...........................................
|
||||
.....................................................................................................#......................#...............
|
||||
#.........................................................................................#.................................................
|
||||
.............................#.......................................................................................#....................#.
|
||||
...........#.............................#......#........#.....#.......#......#.............................#...............................
|
||||
...................#........................................................................................................................
|
||||
...................................................................................................................................#........
|
||||
.#............#.............................#......#...............................#....................................#...................
|
||||
..........................#.........#...................................................................#...................................
|
||||
.....................................................................#.............................#...........................#............
|
||||
................................................................................................................#...........................
|
||||
...........................................................#..................................#.............................................
|
||||
........#....................#....................................#...................#.................................................#...
|
||||
...#...............#.............................#.....................................................................#....................
|
||||
.........................#..........#.....#................................#........................#.......................................
|
||||
................................................................................#..............................#................#...........
|
||||
............................................................................................................................................
|
||||
....................................................................................#........#..............................................
|
||||
............................................................#..........#..........................#.........................................
|
||||
.............................#........#................#................................................#...............#...................
|
||||
......................#............................................#........................................................................
|
||||
.#..........#.........................................................................#.....................................................
|
||||
..................#..........................................................................................#...................#..........
|
||||
.......#.........................#................#..........................#.......................#................#................#....
|
||||
.........................................................#..................................................................................
|
||||
.....................................................................#......................................................................
|
||||
............................................#...................#....................#.............................#........................
|
||||
......................................#.....................................................................................................
|
||||
...#.......................................................................................................................#................
|
||||
.......................#..........................#......................................................#.....#............................
|
||||
.................................#..........................................................................................................
|
||||
.............#....................................................#........#...........................................................#....
|
||||
............................................................................................................................................
|
||||
............................................................................................................................................
|
||||
.................................................#.....#....................................#......................#..............#.........
|
||||
.................#............................................................#.............................#.............................#.
|
||||
............#............................#.........................................#.............#..........................................
|
||||
.......#...............#........................................................................................#...........................
|
||||
..................................#............#..............#.....#..................................#....................................
|
||||
...........................................................................#................................................................
|
||||
..#.......#.....#............#...........................#............................#..............................#......................
|
||||
........................................#.......................................#.................#.......................................#.
|
||||
............................................................................................................................................
|
||||
..........................#.......................#..............#..........................................................................
|
||||
..................................#.........................................................................................................
|
||||
.#..................................................................................................................#.......................
|
||||
................#.....................#.....................#...............#...................#............#..............................
|
||||
.........#..................................................................................................................................
|
||||
................................#..............#........................#.................#........................................#........
|
||||
............................................................................................................................................
|
||||
#...................#...................#.......................................................................#........................#..
|
||||
............................#....................................#............#.......#....................#................................
|
||||
............................................................#......................................#........................................
|
||||
...................................................................................................................#.........#..............
|
||||
..................................................#.................#....................#..............................#...................
|
||||
........................#..............................#..........................#.........................................................
|
||||
............#..........................#...................................#.....................#.......#..........................#.......
|
||||
..................#.............#...........................................................................................................
|
||||
.....#......................................................................................................................................
|
||||
.......................................................................#..............................................#.....................
|
||||
.........#................#................................#........................#.......................#...............................
|
||||
....................#................#.......#.....................................................................................#........
|
||||
..................................................#.........................#........................#.............#..........#.............
|
||||
.#...................................................................#......................................................................
|
||||
.................................................................................#......#.....................#........#....................
|
||||
.....#...................................#..................................................................................................
|
||||
.....................................................#.................................................#....................................
|
||||
..............#...................#.............................#.................................................................#......#..
|
||||
........#...........#.......................................................................#.............................#.................
|
||||
.................................................................................................#..........................................
|
||||
..........................................................................................................#.....#...........................
|
||||
..........................#........................#........................................................................................
|
||||
.#................#.......................#.......................................#..................................#......................
|
||||
.........#.....................#.....#.................................................................................................#....
|
||||
............................................................................................#...............................................
|
||||
.....................................................................#.......................................#..............................
|
||||
..............................................#............................#............................#.....................#.............
|
||||
.........................................#................#......................................#.....................#....................
|
||||
................................#...........................................................................................................
|
||||
#.....#.........#...............................................#.............#.............................................................
|
||||
...........................#.......................................................#......................#.................#.......#......#
|
||||
...........................................................................................#........#.......................................
|
||||
....................#...................#................#..............#...................................................................
|
||||
..............................................................#.............................................................................
|
||||
..........#.......................#..................................................#...............................#......................
|
||||
...............#..............................................................................#........#.............................#......
|
||||
.........................#...................#.......#.............#...........................................#...........#................
|
||||
.....................................#....................................................#.................................................
|
||||
....................#.............................................................#.....................................................#...
|
||||
.......#....................................................................#...............................................................
|
||||
...............................................................#....................................#...........................#...........
|
||||
...............#...........................#..........................................................................#.....................
|
||||
.................................#......................................................#...........................................#.......
|
||||
#........#.........................................#......#.................................................................................
|
||||
..............................................................................#..........................#..................................
|
||||
.....#..................#...................................................................................................................
|
||||
.......................................................#.......#.....#...........................................#.............#............
|
||||
....................#...............#............#..........................................................................................
|
||||
.................................................................................#......#..............................................#....
|
201
Day 11/main.cpp
Normal file
201
Day 11/main.cpp
Normal file
@ -0,0 +1,201 @@
|
||||
#pragma region Hidden Setup Stuff
|
||||
#define OLC_PGE_APPLICATION
|
||||
#include "olcPixelGameEngine.h"
|
||||
|
||||
using namespace olc;
|
||||
|
||||
enum Run{
|
||||
FILE1,
|
||||
FILE2
|
||||
};
|
||||
|
||||
// Override base class with your custom functionality
|
||||
class AoC2023 : public olc::PixelGameEngine
|
||||
{
|
||||
std::vector<std::string>lines;
|
||||
bool waitForRender=false;
|
||||
|
||||
void wait(int pauseMs=0){
|
||||
waitForRender=true;
|
||||
while(waitForRender);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(pauseMs));
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
const int DAY = 11;
|
||||
Run runInput=FILE2;
|
||||
|
||||
std::vector<std::string>space;
|
||||
|
||||
std::vector<vi2d>galaxies;
|
||||
|
||||
std::vector<vi2d>walkPath;
|
||||
|
||||
void doStuff(){
|
||||
while(true){ //lines is accessible as a global.
|
||||
for(std::string&line:lines){
|
||||
space.push_back(line);
|
||||
bool allDots=true;
|
||||
for(int i=0;i<line.length();i++){
|
||||
if(line[i]!='.'){
|
||||
allDots=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(allDots){
|
||||
space.push_back(std::string(line.size(),'M'));
|
||||
}
|
||||
}
|
||||
for(int col=0;col<space[0].length();col++){
|
||||
bool allDots=true;
|
||||
for(int row=0;row<space.size();row++){
|
||||
if(space[row][col]!='.'&&space[row][col]!='M'){
|
||||
allDots=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(allDots){
|
||||
for(int row=0;row<space.size();row++){
|
||||
std::string&r=space[row];
|
||||
r.insert(r.begin()+col,'M');
|
||||
}
|
||||
col++;
|
||||
}
|
||||
}
|
||||
|
||||
for(int y=0;std::string&row:space){
|
||||
for(int x=0;char c:row){
|
||||
if(c=='#'){
|
||||
galaxies.push_back({x,y});
|
||||
}
|
||||
x++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
|
||||
long long sum=0;
|
||||
|
||||
for(int index=0;vi2d&galaxy:galaxies){
|
||||
walkPath.clear();
|
||||
for(int index2=index+1;index2<galaxies.size();index2++){
|
||||
vi2d&galaxy2=galaxies[index2];
|
||||
//int distance=abs(galaxy.x-galaxy2.x)+abs(galaxy.y-galaxy2.y);
|
||||
vi2d startingPos=galaxy;
|
||||
while(startingPos!=galaxy2){
|
||||
if(startingPos.x!=galaxy2.x){
|
||||
if(galaxy2.x>startingPos.x){
|
||||
startingPos.x++;
|
||||
}else{
|
||||
startingPos.x--;
|
||||
}
|
||||
if(space[startingPos.y][startingPos.x]=='.'||space[startingPos.y][startingPos.x]=='#'){
|
||||
sum++;
|
||||
}else{
|
||||
sum+=999999;
|
||||
}
|
||||
}else{
|
||||
if(galaxy2.y>startingPos.y){
|
||||
startingPos.y++;
|
||||
}else{
|
||||
startingPos.y--;
|
||||
}
|
||||
if(space[startingPos.y][startingPos.x]=='.'||space[startingPos.y][startingPos.x]=='#'){
|
||||
sum++;
|
||||
}else{
|
||||
sum+=999999;
|
||||
}
|
||||
}
|
||||
walkPath.push_back(startingPos);
|
||||
}
|
||||
wait(1);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
std::cout<<sum<<std::endl;
|
||||
|
||||
wait(0); //Wait for 0ms and render the screen (calls draw())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void draw(){ //Only use Sprites! If using decals, you must reference global variables!
|
||||
if(GetScreenSize()!=vi2d{int(space[0].size()*8),int(space.size()*8)})SetScreenSize(space[0].size()*8,space.size()*8);
|
||||
Clear(BLACK);
|
||||
for(int count=0;std::string&row:space){
|
||||
DrawString({0,count*8},row,WHITE,1);
|
||||
count++;
|
||||
}
|
||||
for(vi2d&galaxy:galaxies){
|
||||
DrawString(galaxy*8,std::string(1,'#'),CYAN,1);
|
||||
}
|
||||
SetPixelMode(Pixel::ALPHA);
|
||||
srand(48910);
|
||||
for(vi2d&path:walkPath){
|
||||
switch(rand()%6){
|
||||
case 0:{
|
||||
FillRect(path*8,{8,8},{uint8_t(rand()%255),uint8_t(rand()%255),0,64});
|
||||
}break;
|
||||
case 1:{
|
||||
FillRect(path*8,{8,8},{uint8_t(rand()%255),0,uint8_t(rand()%255),64});
|
||||
}break;
|
||||
case 2:{
|
||||
FillRect(path*8,{8,8},{uint8_t(rand()%255),0,uint8_t(rand()%255),64});
|
||||
}break;
|
||||
case 3:{
|
||||
FillRect(path*8,{8,8},{0,0,uint8_t(rand()%255),64});
|
||||
}break;
|
||||
case 4:{
|
||||
FillRect(path*8,{8,8},{0,uint8_t(rand()%255),0,64});
|
||||
}break;
|
||||
case 5:{
|
||||
FillRect(path*8,{8,8},{uint8_t(rand()%255),0,0,64});
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma region Hidden Engine Stuff
|
||||
public:
|
||||
AoC2023()
|
||||
{
|
||||
// Name your application
|
||||
std::string fileName="day"+std::to_string(DAY)+"_1.txt";
|
||||
if(runInput==FILE2){fileName="day"+std::to_string(DAY)+"_2.txt";}
|
||||
std::ifstream file(fileName);
|
||||
while(file.good()){
|
||||
std::string line;
|
||||
std::getline(file,line);
|
||||
lines.push_back(line);
|
||||
}
|
||||
|
||||
sAppName = "Advent of Code 2023 - Day "+std::to_string(DAY);
|
||||
}
|
||||
|
||||
public:
|
||||
bool OnUserCreate() override
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnUserUpdate(float fElapsedTime) override
|
||||
{
|
||||
static std::thread aocSolver(&AoC2023::doStuff,this);
|
||||
|
||||
if(waitForRender){
|
||||
draw();
|
||||
waitForRender=false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
AoC2023 game;
|
||||
if (game.Construct(640, 480, 2,2))
|
||||
game.Start();
|
||||
return 0;
|
||||
}
|
||||
#pragma endregion
|
6695
Day 11/olcPixelGameEngine.h
Normal file
6695
Day 11/olcPixelGameEngine.h
Normal file
File diff suppressed because it is too large
Load Diff
10
Project3.sln
10
Project3.sln
@ -25,6 +25,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Day 9", "Day 9\Day 9.vcxpro
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Day 10", "Day 10\Day 10.vcxproj", "{D8D2679E-E8D9-4140-82BF-4F6759CEB429}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Day 11", "Day 11\Day 11.vcxproj", "{520A82A0-BD04-44D6-B361-07F095A5ABA0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@ -121,6 +123,14 @@ Global
|
||||
{D8D2679E-E8D9-4140-82BF-4F6759CEB429}.Release|x64.Build.0 = Release|x64
|
||||
{D8D2679E-E8D9-4140-82BF-4F6759CEB429}.Release|x86.ActiveCfg = Release|Win32
|
||||
{D8D2679E-E8D9-4140-82BF-4F6759CEB429}.Release|x86.Build.0 = Release|Win32
|
||||
{520A82A0-BD04-44D6-B361-07F095A5ABA0}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{520A82A0-BD04-44D6-B361-07F095A5ABA0}.Debug|x64.Build.0 = Debug|x64
|
||||
{520A82A0-BD04-44D6-B361-07F095A5ABA0}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{520A82A0-BD04-44D6-B361-07F095A5ABA0}.Debug|x86.Build.0 = Debug|Win32
|
||||
{520A82A0-BD04-44D6-B361-07F095A5ABA0}.Release|x64.ActiveCfg = Release|x64
|
||||
{520A82A0-BD04-44D6-B361-07F095A5ABA0}.Release|x64.Build.0 = Release|x64
|
||||
{520A82A0-BD04-44D6-B361-07F095A5ABA0}.Release|x86.ActiveCfg = Release|Win32
|
||||
{520A82A0-BD04-44D6-B361-07F095A5ABA0}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
Loading…
x
Reference in New Issue
Block a user