title: Count Numbers That Dont Contain 3
signature: count_numbers_that_dont_contain_3 <- function(n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      abs(actual - expected) < 1e-09
  }
  
  driver <- function(n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          85L, 
          71.5
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          86L, 
          73.39999999999999
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          3L, 
          2.0
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          35L, 
          26.5
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          59L, 
          52.1
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          38L, 
          32.2
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          33L, 
          22.7
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          15L, 
          17.5
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          75L, 
          62.5
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          74L, 
          60.6
      )))
  
  }
  
  main()
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 );
  }