Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*******************************************************************************************************
- Name: Emmanuel Obi
- Description:
- Pokemon Go Go is a program that enables users to access pokestop locations close to the user's current
- location, and also pokemons that could be found at each pokestop. The unique quality of this program is it's capability
- of computing the shortest route a user could take to catch all pokemons, and return to the starting location.
- Firstly, the program requires an input. The first input is a single integer n , which represents the number of pokestation to be
- considered such that 0 < n < 11. The next set of input(s) will be two integers (x, y) separated by a space, which represents
- the location of the pokestation(s) on a map represented with a 2D vector .e.g vector<vector<int> ;
- followed by a single space and the name of the pokemon (x), such that x is a string.
- Secondly, the program has an output at the end of it's computation, which is a single line of integers(each integers are
- spaced out). This integers represents the order of pokestop to be visited in an optimized way, such that the distance
- traveled is the shortest/optimize distance route. The last integer in the line represents the total distance traveled in
- blocks. If there are two pokestations with the same total distance, the numerically first pokestation is outputed.
- *********************************************************************************************************/
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <string>
- #include <queue>
- using namespace std;
- struct Pokemon
- {
- Pokemon(string name, int order, int x = 0, int y = 0)
- {
- pokemonName = name;
- postionOrder = order;
- xCordinate = x;
- yCordinate = y;
- }
- int postionOrder;
- string pokemonName;
- int xCordinate;
- int yCordinate;
- };
- class PokemonGoGo
- {
- public:
- PokemonGoGo()
- {
- //Matrix Vector //Initialize Vector as Empty Map
- }
- void addPokemon(Pokemon* pokemon)
- {
- unvisitedPokemon.push_back(*pokemon); //Get item of the pointer parameter
- }
- void extractUniquePokemon(string nameOfPokemon)
- {
- if (!pokemonReptitionCheck(nameOfPokemon))
- uniquePokemonNames.push_back(nameOfPokemon);
- }
- void pokemonGrouping()
- {
- vector<Pokemon> temp;
- for (int i = 0; i < uniquePokemonNames.size(); i++)
- {
- temp.swap(vector<Pokemon>()); //Clear Temp
- for (int j = 0; j < unvisitedPokemon.size(); j++)
- {
- if (uniquePokemonNames[i] == unvisitedPokemon[j].pokemonName)
- temp.push_back(unvisitedPokemon[j]);
- }
- groupedPokemon.push_back(temp);
- }
- }
- void pokemonGroupingOrder()
- {
- vector<int> temp;
- for (int i = 0; i < uniquePokemonNames.size(); i++)
- {
- temp.swap(vector<int>()); //Clear Temp
- for (int j = 0; j < unvisitedPokemon.size(); j++)
- {
- if (uniquePokemonNames[i] == unvisitedPokemon[j].pokemonName)
- temp.push_back(unvisitedPokemon[j].postionOrder);
- }
- groupedPokemonOrder.push_back(temp);
- }
- }
- bool pokemonReptitionCheck(string pokemon)
- {
- bool repetitonFound = false;
- for (int i = 0; i < uniquePokemonNames.size(); i++)
- {
- if (uniquePokemonNames[i] == pokemon)
- repetitonFound = true;
- }
- return repetitonFound;
- }
- /*void combinations(vector<vector<int>> groupOfPokemon, int index, vector<int> set)
- {
- vector<int> row; vector<int> temp;
- if (index == groupOfPokemon.size())
- {
- visitedPokemon.push_back(set);
- }
- else
- {
- row = groupOfPokemon[index];
- for (int j = 0; j < row.size(); j++)
- {
- temp.swap(set);
- temp.push_back(row[j]);
- combinations(groupOfPokemon, index + 1, temp);
- }
- }
- }*/
- /*bool oneFromEach(vector<int> generatedSet)
- {
- for (int i = 0; i < groupedPokemon.size(); i++)
- {
- if (generatedSet[i] == groupedPokemon[i].size() - 1)
- generatedSet[i] = groupedPokemon[i][i].postionOrder;
- else
- {
- generatedSet[i] = groupedPokemon[i][i+1].postionOrder;
- return true;
- }
- }
- return false;
- }*/
- /*void printUniquePokemons()
- {
- vector <int> set;
- do
- {
- for (int i = 0; i < groupedPokemon.size(); i++)
- {
- for (int j = 0; j < groupedPokemon[i].size(); j++)
- {
- set.push_back(groupedPokemon[i][j].postionOrder);
- cout << groupedPokemon[i][j].postionOrder;
- }
- }
- } while (oneFromEach(set));
- }*/
- void print()
- {
- //combinations(groupedPokemonOrder, 0, vector<int>());
- /*for (int i = 0; i < visitedPokemon.size(); i++)
- {
- for (int j = 0; j < visitedPokemon[i].size(); j++)
- {
- cout << visitedPokemon[i][j];
- }
- }*/
- }
- private:
- vector<string> uniquePokemonNames;
- vector<vector<Pokemon>> groupedPokemon;
- vector<vector<int>> visitedPokemon;
- vector<vector<int>> groupedPokemonOrder;
- vector<Pokemon> unvisitedPokemon;
- /*string pokemons;
- int locationID;*/
- };
- ostream& operator<<(ostream& out, const vector<int>& vec)
- {
- for (auto x : vec)
- out << x;
- return out;
- }
- int main()
- {
- PokemonGoGo pokemonGame; //Container
- int numberOfPokestations;
- int xLoc; int yLoc; string pokemonName;
- cin >> numberOfPokestations;
- for (int i = 1; i <= numberOfPokestations; i++)
- {
- cin >> xLoc >> yLoc >> pokemonName;
- pokemonGame.addPokemon(new Pokemon(pokemonName, i, xLoc, yLoc));
- pokemonGame.extractUniquePokemon(pokemonName);
- }
- pokemonGame.pokemonGroupingOrder();
- pokemonGame.print();
- //pokemonGame.printUniquePokemons();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement