title: Decimal Representation Given Binary String Divisible 10 Not
signature: class Solution {
  
      public bool DecimalRepresentationGivenBinaryStringDivisible10Not(string bin) {
test_code: using System;
  using System.Numerics;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Cryptography;
  using System.Web.UI;
  using System.Web.Script.Serialization;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  namespace EvaluatePrediction {
      class TestRunner {
          public bool ValidateSolution(bool actual, bool expected){
              return new JavaScriptSerializer().Serialize(actual) == new JavaScriptSerializer().Serialize(expected);
          }
  
          public string driver(string bin, bool expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                bool pred_result = solution_cls.PLACEHOLDER_FN_NAME(bin); 
                if (ValidateSolution(
                      pred_result,
                      expected)){
                  return "PASSED";
                }
                return "FAILED";
              } 
              catch (Exception exception_obj)
              {
                return exception_obj.GetType().FullName;
              }
          }
          static void Main(string[] args) {
              TestRunner runner = new TestRunner();
              String result;
              result = runner.driver(
                  "101000", 
                  true
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );result = runner.driver(
                  "39613456759141", 
                  false
              );
              Console.WriteLine(string.Format(
                  "TEST-1...{0}",
                  result)
              );result = runner.driver(
                  "11", 
                  false
              );
              Console.WriteLine(string.Format(
                  "TEST-2...{0}",
                  result)
              );result = runner.driver(
                  "PoiHjo", 
                  true
              );
              Console.WriteLine(string.Format(
                  "TEST-3...{0}",
                  result)
              );result = runner.driver(
                  "2", 
                  true
              );
              Console.WriteLine(string.Format(
                  "TEST-4...{0}",
                  result)
              );result = runner.driver(
                  "0000101", 
                  false
              );
              Console.WriteLine(string.Format(
                  "TEST-5...{0}",
                  result)
              );result = runner.driver(
                  "T  s dZKeDX gK", 
                  true
              );
              Console.WriteLine(string.Format(
                  "TEST-6...{0}",
                  result)
              );result = runner.driver(
                  "3944713969", 
                  false
              );
              Console.WriteLine(string.Format(
                  "TEST-7...{0}",
                  result)
              );result = runner.driver(
                  "1000", 
                  false
              );
              Console.WriteLine(string.Format(
                  "TEST-8...{0}",
                  result)
              );result = runner.driver(
                  "ifYUgdpmt", 
                  true
              );
              Console.WriteLine(string.Format(
                  "TEST-9...{0}",
                  result)
              );
          }
      }
  }
  
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;
  }