wheelsmanx

AOC DAY 2 PART 1 Source.cpp

May 14th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. #include "Header.h"
  2. // this header file is the same cleanUp.h
  3. #include <vector>
  4. #include <string>
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. class matrix {
  10. public:
  11. vector <int> matrixB;
  12. vector <int> code;
  13. int selector = 5;
  14. void parse(char userInput) {
  15. int returnObject = 0;
  16. switch (userInput) {
  17. case 'D': {
  18. if ((this->selector + 3) < 10 && (this->selector + 3) > 0) {
  19. returnObject = this->selector + 3;
  20. }
  21. else {
  22. returnObject = this->selector;
  23. }
  24. break;
  25. }
  26. case 'U': {
  27. if ((this->selector - 3) < 10 && (this->selector - 3) > 0) {
  28. returnObject = this->selector - 3;
  29. }
  30. else {
  31. returnObject = this->selector;
  32. }
  33. break;
  34. }
  35. case 'L': {
  36. if (this->selector == 1 || this->selector == 4 || this->selector == 7) {
  37. returnObject = this->selector;
  38. }
  39. else {
  40. returnObject = this->selector;
  41. returnObject = (this->selector - 1);
  42. }
  43. break; }
  44. case 'R': {
  45. if (this->selector == 3 || this->selector == 6 || this->selector == 9) {
  46. returnObject = this->selector;
  47. }
  48. else {
  49. returnObject = this->selector;
  50. returnObject = (this->selector + 1);
  51. }
  52. break;
  53. }
  54. }
  55. this->selector = returnObject;
  56. }
  57.  
  58. matrix() {
  59. for (int i = 0; i < 10; i++) {
  60. this->matrixB.push_back(i);
  61. }
  62. }
  63. };
  64. matrix classHandle(vector <string> userInput, matrix matrixObject) {
  65. for (int i = 0; i < userInput.size(); i++) {
  66. string stringPtr = userInput.at(i);
  67. for (int b = 0; b < stringPtr.length(); b++) {
  68. matrixObject.parse(stringPtr[b]);
  69. }
  70. matrixObject.code.push_back(matrixObject.selector);
  71. }
  72. return matrixObject;
  73. }
  74.  
  75. vector <string> input;
  76. void main() {
  77. matrix A;
  78. input = getInputFile("C:\\temp\\New Text Document.txt");
  79. A = classHandle(input, A);
  80. vout(A.code);
  81. system("pause");
  82. }
Advertisement
Add Comment
Please, Sign In to add comment