title: Decimal Representation Given Binary String Divisible 10 Not
signature: function decimal_representation_given_binary_string_divisible_10_not(bin)
test_code: using Printf
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  function validate_solution(actual, expected)
      return actual == expected
  end
  
  function driver(bin, expected)
      try
  
          if validate_solution(PLACEHOLDER_FN_NAME(bin), expected)
              return "PASSED";
          end
          return "FAILED";
      catch exception_obj
          return string(Base.typename(typeof(exception_obj)).wrapper);
      end
  end
  
  function main()
      
      result = driver("101000", true);
      @printf("TEST-0...%s\n",result);
      
      result = driver("39613456759141", false);
      @printf("TEST-1...%s\n",result);
      
      result = driver("11", false);
      @printf("TEST-2...%s\n",result);
      
      result = driver("PoiHjo", true);
      @printf("TEST-3...%s\n",result);
      
      result = driver("2", true);
      @printf("TEST-4...%s\n",result);
      
      result = driver("0000101", false);
      @printf("TEST-5...%s\n",result);
      
      result = driver("T  s dZKeDX gK", true);
      @printf("TEST-6...%s\n",result);
      
      result = driver("3944713969", false);
      @printf("TEST-7...%s\n",result);
      
      result = driver("1000", false);
      @printf("TEST-8...%s\n",result);
      
      result = driver("ifYUgdpmt", true);
      @printf("TEST-9...%s\n",result);
      
  end
  
  main()
source_py: def decimal_representation_given_binary_string_divisible_10_not(bin):
      n = len(bin)
      if (bin[(n - 1)] == '1'):
          return False
      sum = 0
      i = (n - 2)
      while (i >= 0):
          if (bin[i] == '1'):
              posFromRight = ((n - i) - 1)
              if ((posFromRight % 4) == 1):
                  sum = (sum + 2)
              elif ((posFromRight % 4) == 2):
                  sum = (sum + 4)
              elif ((posFromRight % 4) == 3):
                  sum = (sum + 8)
              elif ((posFromRight % 4) == 0):
                  sum = (sum + 6)
          i = (i - 1)
      if ((sum % 10) == 0):
          return True
      return False
source_cpp: bool decimal_representation_given_binary_string_divisible_10_not(string bin) {
    int n = bin . size ( );
    if ( bin [ n - 1 ] == '1' ) return false;
    int sum = 0;
    for ( int i = n - 2;
    i >= 0;
    i -- ) {
      if ( bin [ i ] == '1' ) {
        int posFromRight = n - i - 1;
        if ( posFromRight % 4 == 1 ) sum = sum + 2;
        else if ( posFromRight % 4 == 2 ) sum = sum + 4;
        else if ( posFromRight % 4 == 3 ) sum = sum + 8;
        else if ( posFromRight % 4 == 0 ) sum = sum + 6;
      }
    }
    if ( sum % 10 == 0 ) return true;
    return false;
  }