-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhanoi.h
29 lines (23 loc) · 790 Bytes
/
hanoi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <vector>
#include <stack>
#include <unordered_map>
#ifndef _HANOI_H
#define _HANOI_H
class Hanoi
{
public:
Hanoi(const unsigned int &);
void play();
private:
std::vector <std::stack<int>> stacks; // the 3 stacks
std::unordered_map <int, int> moves; // maps disks to their last position before current one
int lrud; // least recently used disk
unsigned int moveCounter; // tracks the number of moves
unsigned int disksWidth; // used to format output
void rHanoi(); // main, recursive function. Called by play
std::stack<int> & getFrom(); // rHanoi helper
std::stack<int> & getTo(std::stack<int> &); //rHanoi helper
void move(std::stack<int> &, std::stack<int> &); // called by rHanoi
void printStacks(); // called by move to output process
};
#endif