Contains the source code from the course work throughout my undergraduate Computer Engineering degree at Brigham Young University. There is a mixture of Go, Python, C, C++, Java, VHDL, Verilog, Matlab, Bash, Assembly, etc..
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JosephusInterface.h 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //YOU MAY NOT MODIFY THIS DOCUMENT
  2. #pragma once
  3. #include <iostream>
  4. #include <string>
  5. #include <vector>
  6. using namespace std;
  7. class JosephusInterface
  8. {
  9. public:
  10. JosephusInterface(void){}
  11. virtual ~JosephusInterface(void){}
  12. /*
  13. getNames
  14. Returns a list of names in the order in which the people will be standing for the "game".
  15. Although fewer people may be playing, you must return 20 names here. Do not provide
  16. duplicate names.
  17. For the sake of the test driver, this method must return the list of 20 names in the
  18. same order every time it is called, and this list of 20 names in this order must be used
  19. to play the "game".
  20. This method will be called repeatedly.
  21. */
  22. virtual vector<string> getNames() = 0;
  23. /*
  24. playGame
  25. Plays a "game" with the first n people from the list (above) counting forward every m. An
  26. explanation for how the "game" works can be found in the exam specs.
  27. This method should return a list of names in the order in which the lot fell upon them (including
  28. the survivor, who should be last). If n is not between 10 and 20 or if m is non-positive,
  29. return an empty vector.
  30. This method will be called repeatedly.
  31. */
  32. virtual vector<string> playGame(int n, int m) = 0;
  33. /*
  34. reportSafeIndex
  35. Returns the "safe index", the last index/location in the circle that will be chosen when
  36. the "game" is played. The point of this method is to permit someone to cheat the system
  37. by finding the safe location ahead of time.
  38. If n is not between 10 and 20 or if m is non-positive, return -1.
  39. This method may be called repeatedly.
  40. */
  41. virtual int reportSafeIndex(int n, int m) = 0;
  42. };