title: Count Numbers That Dont Contain 3
signature: func countNumbersThatDontContain3(n int) float64 {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual float64, expected float64) bool {
      return math.Abs(actual - expected) < 1e-09
  }
  
  func driver(n int, expected float64) string {
      if validateSolution(PLACEHOLDER_FN_NAME(n),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(85, 71.5)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(86, 73.39999999999999)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(3, 2.0)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(35, 26.5)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(59, 52.1)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(38, 32.2)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(33, 22.7)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(15, 17.5)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(75, 62.5)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(74, 60.6)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
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 );
  }