generated from sigonasr2/CPlusPlusProjectTemplate
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.1 KiB
77 lines
2.1 KiB
#define OLC_PGE_APPLICATION
|
|
#include "pixelGameEngine.h"
|
|
#include "olcutils.h"
|
|
|
|
using namespace olc;
|
|
|
|
enum Direction{
|
|
NORTH,
|
|
EAST,
|
|
SOUTH,
|
|
WEST,
|
|
INVALID
|
|
};
|
|
|
|
struct Blizzard{
|
|
vi2d pos;
|
|
Direction dir;
|
|
};
|
|
int maxWidth=0;
|
|
|
|
int main()
|
|
{
|
|
std::ifstream file("input");
|
|
std::vector<std::vector<std::vector<Blizzard>>>boardState;
|
|
while (file.good()){
|
|
std::string line;
|
|
std::vector<std::vector<Blizzard>>board;
|
|
std::getline(file,line);
|
|
if (line.length()>0){
|
|
std::cout<<line<<std::endl;
|
|
std::vector<Blizzard>boardRow;
|
|
for (int i=0;i<line.length();i++){
|
|
if (line[i]!='#'&&line[i]!='.'){
|
|
boardRow.push_back({{i,(int)board.size()},line[i]=='^'?Direction::NORTH:line[i]=='>'?Direction::EAST:line[i]=='v'?Direction::SOUTH:line[i]=='<'?Direction::WEST:Direction::INVALID});
|
|
}
|
|
}
|
|
maxWidth=line.length();
|
|
board.push_back(boardRow);
|
|
}
|
|
boardState.push_back(board);
|
|
}
|
|
for (int d=0;d<boardState.size();d++){
|
|
for (int y=0;y<boardState[d].size();y++){
|
|
int prevBlizzard=-1;
|
|
for (int x=0;x<boardState[d][y].size();x++){
|
|
Blizzard&b=boardState[d][y][x];
|
|
for (int k=prevBlizzard;k<b.pos.x-1;k++){
|
|
std::cout<<'.';
|
|
}
|
|
switch (b.dir){
|
|
case NORTH:{
|
|
std::cout<<'^';
|
|
}break;
|
|
case EAST:{
|
|
std::cout<<'>';
|
|
}break;
|
|
case SOUTH:{
|
|
std::cout<<'v';
|
|
}break;
|
|
case WEST:{
|
|
std::cout<<'<';
|
|
}break;
|
|
case INVALID:{
|
|
std::cout<<'?';
|
|
}break;
|
|
}
|
|
prevBlizzard=b.pos.x;
|
|
}
|
|
for (int k=prevBlizzard;k<maxWidth-1;k++){
|
|
std::cout<<'.';
|
|
}
|
|
std::cout<<std::endl;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|