title: Check Number Power K Using Base Changing Method
signature: def checkNumberPowerKUsingBaseChangingMethod(n: Int, k: Int) = {
test_code: import scala.collection.mutable.HashMap
  import scala.collection.immutable.HashSet
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  
  // TESTING CODE 
  // ============================================
  def validateSolution(actual: Boolean , expected: Boolean): Boolean = {
      actual.toString == expected.toString
  }
  
  def driver(n: Int, k: Int, expected: Boolean): String = {
      try {
          if (validateSolution(PLACEHOLDER_FN_NAME(n, k),expected)) {
              "PASSED"
          } else{
              "FAILED"
          }
      }catch{
          case e: Exception => {e.getClass.getName}
      }
  
  }
  object QuestionEvaluator extends App {
  
      println(s"TEST-0...${driver(
        64, 4, 
        true    
      )}")   
  
  
      println(s"TEST-1...${driver(
        16, 2, 
        true    
      )}")   
  
  
      println(s"TEST-2...${driver(
        27, 3, 
        true    
      )}")   
  
  
      println(s"TEST-3...${driver(
        81, 72, 
        false    
      )}")   
  
  
      println(s"TEST-4...${driver(
        1, 9, 
        true    
      )}")   
  
  
      println(s"TEST-5...${driver(
        69, 17, 
        false    
      )}")   
  
  
      println(s"TEST-6...${driver(
        8, 20, 
        false    
      )}")   
  
  
      println(s"TEST-7...${driver(
        31, 79, 
        false    
      )}")   
  
  
      println(s"TEST-8...${driver(
        43, 81, 
        false    
      )}")   
  
  
      println(s"TEST-9...${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;
  }