title: Count Numbers That Dont Contain 3
signature: double countNumbersThatDontContain3(int n) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(double actual, double expected){
      return abs(actual - expected) < 1e-09;
  }
  
  string driver(int n, double expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver(85, 71.5); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver(86, 73.39999999999999); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver(3, 2.0); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver(35, 26.5); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver(59, 52.1); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver(38, 32.2); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver(33, 22.7); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver(15, 17.5); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver(75, 62.5); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver(74, 60.6); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
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 );
  }