title: Check Number Power K Using Base Changing Method
signature: class Solution {
  
      public Boolean checkNumberPowerKUsingBaseChangingMethod(Integer n, Integer k) {
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;
  }
question_info.extension: java
question_info.entry_fn_name: checkNumberPowerKUsingBaseChangingMethod
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": true, "inputs": {"n": 64, "k": 4}}, {"idx": 1, "outputs": true, "inputs": {"n": 16, "k": 2}}, {"idx": 2, "outputs": true, "inputs": {"n": 27, "k": 3}}, {"idx": 3, "outputs": false, "inputs": {"n": 81, "k": 72}}, {"idx": 4, "outputs": true, "inputs": {"n": 1, "k": 9}}, {"idx": 5, "outputs": false, "inputs": {"n": 69, "k": 17}}, {"idx": 6, "outputs": false, "inputs": {"n": 8, "k": 20}}, {"idx": 7, "outputs": false, "inputs": {"n": 31, "k": 79}}, {"idx": 8, "outputs": false, "inputs": {"n": 43, "k": 81}}, {"idx": 9, "outputs": false, "inputs": {"n": 54, "k": 89}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer n, Integer k, Boolean expected){
          try{
              Driver driver = new Driver();
              if (driver.run(n, k,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(64, 4, true);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(16, 2, true);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(27, 3, true);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(81, 72, false);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(1, 9, true);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(69, 17, false);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(8, 20, false);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(31, 79, false);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(43, 81, false);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(54, 89, false);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer n, Integer k, Boolean expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(n, k),expected);
      }
      
      public boolean validateSolution(Boolean actual, Boolean expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: java __FILENAME__