title: Check Number Power K Using Base Changing Method
signature: function check_number_power_k_using_base_changing_method(n, k)
test_code: using Printf
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  function validate_solution(actual, expected)
      return actual == expected
  end
  
  function driver(n, k, expected)
      try
  
          if validate_solution(PLACEHOLDER_FN_NAME(n, k), expected)
              return "PASSED";
          end
          return "FAILED";
      catch exception_obj
          return string(Base.typename(typeof(exception_obj)).wrapper);
      end
  end
  
  function main()
      
      result = driver(64, 4, true);
      @printf("TEST-0...%s\n",result);
      
      result = driver(16, 2, true);
      @printf("TEST-1...%s\n",result);
      
      result = driver(27, 3, true);
      @printf("TEST-2...%s\n",result);
      
      result = driver(81, 72, false);
      @printf("TEST-3...%s\n",result);
      
      result = driver(1, 9, true);
      @printf("TEST-4...%s\n",result);
      
      result = driver(69, 17, false);
      @printf("TEST-5...%s\n",result);
      
      result = driver(8, 20, false);
      @printf("TEST-6...%s\n",result);
      
      result = driver(31, 79, false);
      @printf("TEST-7...%s\n",result);
      
      result = driver(43, 81, false);
      @printf("TEST-8...%s\n",result);
      
      result = driver(54, 89, false);
      @printf("TEST-9...%s\n",result);
      
  end
  
  main()
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;
  }