title: Check Number Power K Using Base Changing Method
signature: checkNumberPowerKUsingBaseChangingMethod(n, k) {
test_code: import 'dart:convert';
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(bool actual, bool expected){
      return actual.toString() == expected.toString();
  }
  
  String driver(n, k, bool expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(n, k), expected)){
              return "PASSED";
          }
          return "FAILED";
      }catch(exception_object){
          return exception_object.runtimeType.toString();
      }
  }
  
  int main() {
  
      print("TEST-0...${driver(
          64, 4, 
          true)
      }");
  
      print("TEST-1...${driver(
          16, 2, 
          true)
      }");
  
      print("TEST-2...${driver(
          27, 3, 
          true)
      }");
  
      print("TEST-3...${driver(
          81, 72, 
          false)
      }");
  
      print("TEST-4...${driver(
          1, 9, 
          true)
      }");
  
      print("TEST-5...${driver(
          69, 17, 
          false)
      }");
  
      print("TEST-6...${driver(
          8, 20, 
          false)
      }");
  
      print("TEST-7...${driver(
          31, 79, 
          false)
      }");
  
      print("TEST-8...${driver(
          43, 81, 
          false)
      }");
  
      print("TEST-9...${driver(
          54, 89, 
          false)
      }");
  
      return 0;
  }
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;
  }