title: Check Number Power K Using Base Changing Method
signature: checkNumberPowerKUsingBaseChangingMethod :: Integer -> Integer -> Bool
  checkNumberPowerKUsingBaseChangingMethod n k = 
test_code: import Text.Printf
  import Control.Exception (catch, SomeException)
  import Data.Typeable
  import qualified Data.List as List
  import qualified Data.Map as Map
  import qualified Data.Set as Set
  
  -- SOLUTION CODE
  -- ============================================
  
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  validateSolution :: Bool -> Bool -> Bool
  validateSolution actual expected = do
      actual == expected
  
  
  driver :: Integer -> Integer -> Bool -> String
  driver n k expected = do
      if (validateSolution (PLACEHOLDER_FN_NAME n k) expected)
          then "PASSED"
      else "FAILED"
  
  main = do
      printf "TEST-0...%s\n" (driver (64) (4) (True) )
  
      printf "TEST-1...%s\n" (driver (16) (2) (True) )
  
      printf "TEST-2...%s\n" (driver (27) (3) (True) )
  
      printf "TEST-3...%s\n" (driver (81) (72) (False) )
  
      printf "TEST-4...%s\n" (driver (1) (9) (True) )
  
      printf "TEST-5...%s\n" (driver (69) (17) (False) )
  
      printf "TEST-6...%s\n" (driver (8) (20) (False) )
  
      printf "TEST-7...%s\n" (driver (31) (79) (False) )
  
      printf "TEST-8...%s\n" (driver (43) (81) (False) )
  
      printf "TEST-9...%s\n" (driver (54) (89) (False) )
  
source_py: def check_number_power_k_using_base_changing_method(n, k):
      oneSeen = False
      while (n > 0):
          digit = (n % k)
          if (digit > 1):
              return False
          if (digit == 1):
              if oneSeen:
                  return False
              oneSeen = True
          n //= k
      return True
source_cpp: bool check_number_power_k_using_base_changing_method(unsigned int n, unsigned int k) {
    bool oneSeen = false;
    while ( n > 0 ) {
      int digit = n % k;
      if ( digit > 1 ) return false;
      if ( digit == 1 ) {
        if ( oneSeen ) return false;
        oneSeen = true;
      }
      n /= k;
    }
    return true;
  }