title: Count Numbers That Dont Contain 3
signature: countNumbersThatDontContain3(n) {
test_code: import 'dart:convert';
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(double actual, double expected){
      return (actual - expected).abs() < 1e-09;
  }
  
  String driver(n, double expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }catch(exception_object){
          return exception_object.runtimeType.toString();
      }
  }
  
  int main() {
  
      print("TEST-0...${driver(
          85, 
          71.5)
      }");
  
      print("TEST-1...${driver(
          86, 
          73.39999999999999)
      }");
  
      print("TEST-2...${driver(
          3, 
          2.0)
      }");
  
      print("TEST-3...${driver(
          35, 
          26.5)
      }");
  
      print("TEST-4...${driver(
          59, 
          52.1)
      }");
  
      print("TEST-5...${driver(
          38, 
          32.2)
      }");
  
      print("TEST-6...${driver(
          33, 
          22.7)
      }");
  
      print("TEST-7...${driver(
          15, 
          17.5)
      }");
  
      print("TEST-8...${driver(
          75, 
          62.5)
      }");
  
      print("TEST-9...${driver(
          74, 
          60.6)
      }");
  
      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 );
  }