diff --git a/headers/mee/stringAlgorithms.hpp b/headers/mee/stringAlgorithms.hpp
index fa17ee3..e5a3bc0 100644
--- a/headers/mee/stringAlgorithms.hpp
+++ b/headers/mee/stringAlgorithms.hpp
@@ -19,8 +19,7 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see .
*/
-#ifndef MEE_STRING_ALGORITHMS_HPP
-#define MEE_STRING_ALGORITHMS_HPP
+#pragma once
#include
@@ -111,7 +110,26 @@ bool isPalindrome(std::string str){
}
+//This function returns true if the string passed to it is a pandigital
+bool isPandigital(std::string str, char bottom, char top){
+ //Return false if the wrong number of characters are in the string
+ if(str.size() != (top - bottom + 1)){
+ return false;
+ }
+
+ //Make sure that all of the needed characters are in the string exactly one time
+ for(char cnt = bottom;cnt <= top;++cnt){
+ //If a single character is found more than once then the string is not pandigital
+ if(findNumOccurrence(str, cnt) != 1){
+ return false;
+ }
+ }
+
+ //If the function has reached this part it has passed all of the falsifying tests
+ return true;
+}
+bool isPandigital(std::string str){
+ return isPandigital(str, '1', '9');
}
-
-#endif //MEE_STRING_ALGORITHMS_HPP
+}