title: Count Numbers That Dont Contain 3
signature: class Solution {
  
      public Double countNumbersThatDontContain3(Integer n) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer n, Double expected){
          try{
              Driver driver = new Driver();
              if (driver.run(n,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(85, 71.5);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(86, 73.39999999999999);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(3, 2.0);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(35, 26.5);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(59, 52.1);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(38, 32.2);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(33, 22.7);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(15, 17.5);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(75, 62.5);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(74, 60.6);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer n, Double expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(n),expected);
      }
      
      public boolean validateSolution(Double actual, Double expected){
          return Math.abs(actual - expected) < 1e-09;
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
source_py: def count_numbers_that_dont_contain_3(n):
      if (n < 3):
          return n
      elif ((n >= 3) and (n < 10)):
          return (n - 1)
      po = 1
      while ((n / po) > 9):
          po = (po * 10)
      msd = (n / po)
      if (msd != 3):
          return (((count_numbers_that_dont_contain_3(msd) * count_numbers_that_dont_contain_3((po - 1))) + count_numbers_that_dont_contain_3(msd)) + count_numbers_that_dont_contain_3((n % po)))
      else:
          return count_numbers_that_dont_contain_3(((msd * po) - 1))
source_cpp: int count_numbers_that_dont_contain_3(int n) {
    if ( n < 3 ) return n;
    if ( n >= 3 && n < 10 ) return n - 1;
    int po = 1;
    while ( n / po > 9 ) po = po * 10;
    int msd = n / po;
    if ( msd != 3 ) return count_numbers_that_dont_contain_3 ( msd ) * count_numbers_that_dont_contain_3 ( po - 1 ) + count_numbers_that_dont_contain_3 ( msd ) + count_numbers_that_dont_contain_3 ( n % po );
    else return count_numbers_that_dont_contain_3 ( msd * po - 1 );
  }