 # Accenture Coding Question | Electrostatic Field | CodeWindow

#### Solution in Python 3:

``````#https://codewindow.in

c=list(map(int, input().split()))
e=input()
l=int(input())
e=list(e)
#print(c)
#print(e)
count=0
for i in range(l):
if e[i]=='P':
count=count+c[i]
else:
count=count-c[i]

print(abs(count*100))

# Telegram @codewindow``````

#### Solution in C :

``````//https://codewindow.in

#include <stdio.h>
#include <string.h>

int main()
{
char a;
gets(a);
char s;
gets(s);
int n;
scanf("%d",&n);
int charge[n];
int count = 0;
for(int i=0;i<strlen(a);i++){
if(a[i] != ' ') {
charge[count] = a[i]-48;
count++;
}
}
int sum = 0;
for(int i=0;i<n;i++) {
if(s[i] == 'P')
sum += charge[i];
else
sum -= charge[i];
}
if(sum > 0) {
printf("%d",sum*100);
}
else {
printf("%d",-sum*100);
}
}`````` #### Solution in C++ :

``````//https://codewindow.in
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
char a;
cin.getline(a,100);
char s;
cin.getline(s,100);
int n;
cin >> n;
int charge[n];
int count = 0;
for(int i=0;i<strlen(a);i++){
if(a[i] != ' ') {
charge[count] = a[i]-48;
count++;
}
}
int sum = 0;
for(int i=0;i<n;i++) {
if(s[i] == 'P')
sum += charge[i];
else
sum -= charge[i];
}
if(sum > 0) {
cout << sum*100;
}
else {
cout << -sum*100;
}
}
``````

#### Solution in JAVA :

``````//https://codewindow.in

import java.util.*;

class CodeWindow {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
String s = sc.nextLine();
int n = sc.nextInt();
int charge[] = new int[n];
int count = 0;
for(int i=0;i<str.length();i++)
if(str.charAt(i) != ' ') {
charge[count] = str.charAt(i)-48;
count++;
}
int sum = 0;
for(int i=0;i<n;i++) {
if(s.charAt(i) == 'P')
sum += charge[i];
else
sum -= charge[i];
}
if(sum > 0) {
System.out.println(sum*100);
}
else {
System.out.println(-sum*100);
}
}
}``````

#### Output:

``````4 3 5
PNP
3
600``````