let a2=`A Y
B X
C Z`;
let max=0;
let b1 = a2.split('\n')
b1.forEach((elem)=>{
let first = elem.split(' ')[0];
let second = elem.split(' ')[1];
if(second == 'Y') // make it draw
{
let nn = first=='A'? 1: first == 'B' ? 2 :3;
max += 3 + nn;
}
else if(second == 'X') // make it loose
{
let nn = first=='A'? 3: first == 'B' ? 1 :2;
max+= 0+nn;
}
else{ // make it win
let nn = first=='A'? 2: first == 'B' ? 3 :1;
max += 6 +nn;
}
})
console.log(max)
Comments
Post a Comment