Skip to content

Instantly share code, notes, and snippets.

@SilverEzhik
Created January 31, 2015 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SilverEzhik/b8bd1fce8af89c11df13 to your computer and use it in GitHub Desktop.
Save SilverEzhik/b8bd1fce8af89c11df13 to your computer and use it in GitHub Desktop.
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int LEFT = 4;
const int UP = 2;
const int RIGHT = 6;
const int DOWN = 8;
const char WALL = '#';
const char FREE = '-';
const char EXIT = 'e';
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
char maze[13];
//cout << "WTF";
//cin >> maze;
//cout << maze[LEFT];
for(int i = 0; i < 13; i++)
{
cin >> maze[i];
//if (maze[i] == '#') cout << '#';
//cout << "this is maze[" << i << "]: " << maze[i] << '\n';
//cout << maze[i];
}
if(maze[UP] == EXIT)
{
cout << "UP";
return 0;
}
else if (maze[LEFT]== EXIT)
{
cout << "LEFT";
return 0;
}
else if (maze[DOWN]== EXIT)
{
cout << "DOWN";
return 0;
}
else if (maze[RIGHT]== EXIT)
{
cout << "RIGHT";
return 0;
}
// Move
if(maze[UP] == FREE)
{
cout << "UP";
return 0;
}
else if (maze[RIGHT]== FREE)
{
cout << "RIGHT";
return 0;
}
else if (maze[LEFT]== FREE)
{
cout << "LEFT";
return 0;
}
else if (maze[DOWN]== FREE)
{
cout << "DOWN";
return 0;
}
//cout << "\nThe end.";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment