Skip to content

Instantly share code, notes, and snippets.

@HirbodBehnam
Created March 3, 2021 17:09
Show Gist options
  • Select an option

  • Save HirbodBehnam/8e9463d296e8f8e2a7f3522905a70840 to your computer and use it in GitHub Desktop.

Select an option

Save HirbodBehnam/8e9463d296e8f8e2a7f3522905a70840 to your computer and use it in GitHub Desktop.
View mazes generated by our maze generator
/**
Maze example:
1e11111111111
1*0*0*0*0*0*1
1110111111101
1*1*0*1*0*1*1
1011111010101
1*0*0*0*1*0*1
11111111111e1
*/
#include <iostream>
#include <string>
using namespace std;
int main() {
string result; // do not print each char at time because we will fuck up the terminal
for (int row = 0;; row++) {
string line;
getline(cin, line);
if (line.empty()) // end the program by empty line
break;
if (row % 2 == 0) { // horizontal walls
for (int column = 0; column < line.size(); column++)
result += line[column] == '1' || column % 2 == 0 ? "█" : " ";
} else { // vertical walls
for (int column = 0; column < line.size(); column += 2)
result += line[column] == '1' ? "█ " : " ";
}
result += "\n";
}
cout << result;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment