title: Count Numbers That Dont Contain 3
signature: fun countNumbersThatDontContain3(n: Int): Double {
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 );
  }
question_info.test_list: [{"idx": 0, "outputs": 71.5, "inputs": {"n": 85}}, {"idx": 1, "outputs": 73.39999999999999, "inputs": {"n": 86}}, {"idx": 2, "outputs": 2, "inputs": {"n": 3}}, {"idx": 3, "outputs": 26.5, "inputs": {"n": 35}}, {"idx": 4, "outputs": 52.1, "inputs": {"n": 59}}, {"idx": 5, "outputs": 32.2, "inputs": {"n": 38}}, {"idx": 6, "outputs": 22.7, "inputs": {"n": 33}}, {"idx": 7, "outputs": 17.5, "inputs": {"n": 15}}, {"idx": 8, "outputs": 62.5, "inputs": {"n": 75}}, {"idx": 9, "outputs": 60.6, "inputs": {"n": 74}}]
question_info.extension: kts
question_info.test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Double, expected:Double):Boolean{
    return abs(actual - expected) < 1e-09
  }
  fun driver(n: Int, expected:Double):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(85, 71.5)
      println("TEST-0...${result}")
      
      result = driver(86, 73.39999999999999)
      println("TEST-1...${result}")
      
      result = driver(3, 2.0)
      println("TEST-2...${result}")
      
      result = driver(35, 26.5)
      println("TEST-3...${result}")
      
      result = driver(59, 52.1)
      println("TEST-4...${result}")
      
      result = driver(38, 32.2)
      println("TEST-5...${result}")
      
      result = driver(33, 22.7)
      println("TEST-6...${result}")
      
      result = driver(15, 17.5)
      println("TEST-7...${result}")
      
      result = driver(75, 62.5)
      println("TEST-8...${result}")
      
      result = driver(74, 60.6)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: countNumbersThatDontContain3
question_info.entry_cls_name: Solution
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: kotlinc -script __FILENAME__ -no-reflect -nowarn