title: Find Position Given Number Among Numbers Made 4 7
signature: find_position_given_number_among_numbers_made_4_7 <- function(n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          "7", 
          2L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          "305745689", 
          5L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          "444", 
          7L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          "4", 
          1L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          "2074", 
          5L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          "27", 
          2L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          "447", 
          8L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          "255", 
          0L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          "10000111111011", 
          0L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          "fAKcSDRTNz", 
          0L
      )))
  
  }
  
  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;
  }