title: Find Position Given Number Among Numbers Made 4 7
signature: fun findPositionGivenNumberAmongNumbersMade47(n: String): Int {
test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(n: String, expected:Int):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("7", 2)
      println("TEST-0...${result}")
      
      result = driver("305745689", 5)
      println("TEST-1...${result}")
      
      result = driver("444", 7)
      println("TEST-2...${result}")
      
      result = driver("4", 1)
      println("TEST-3...${result}")
      
      result = driver("2074", 5)
      println("TEST-4...${result}")
      
      result = driver("27", 2)
      println("TEST-5...${result}")
      
      result = driver("447", 8)
      println("TEST-6...${result}")
      
      result = driver("255", 0)
      println("TEST-7...${result}")
      
      result = driver("10000111111011", 0)
      println("TEST-8...${result}")
      
      result = driver("fAKcSDRTNz", 0)
      println("TEST-9...${result}")
      
          
  }
  
  main()
source_py: def find_position_given_number_among_numbers_made_4_7(n):
      i = 0
      j = len(n)
      pos = 0
      while (i < j):
          if (n[i] == '4'):
              pos = ((pos * 2) + 1)
          if (n[i] == '7'):
              pos = ((pos * 2) + 2)
          i = (i + 1)
      return pos
source_cpp: int find_position_given_number_among_numbers_made_4_7(string n) {
    int i = 0, pos = 0;
    while ( n [ i ] != '\0' ) {
      switch ( n [ i ] ) {
        case '4' : pos = pos * 2 + 1;
        break;
        case '7' : pos = pos * 2 + 2;
        break;
      }
      i ++;
    }
    return pos;
  }