Skip to main content

Advent of code 2022 problem 2 part 2 Javascript solution

 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

Popular posts from this blog

Find occurrence of one word into another word irrespective of their loca...

Sex in Summers - Great Tips

Having sex while it’s hot is just not fun - it’s sticky, sweaty, smelly and exhausting. But, when a heatwave strikes and we have something that closely resembles an actual summer on our hands then the hunt begins for ways to overcome our dislike of sex in the heat and power through. In the shower for both:  move operations to the bathroom and have sex while the shower is blasting out cool water. You’ll finish feeling clean, cool and close. Standing up and enjoy both:  Have sex standing up, even better if your hands are against a cool wall. This position means less body contact and allows way more breathing space than your usual missionary. Using a fan:  We hate to state the obvious but put a fan on, open the windows and keep the covers (and any pyjamas) off. Experimenting with ice:  If you haven’t already played around with ice during intercourse then now is the time. Hold a cube in your mouth as you kiss each other all over or run cubes over e...

Sex Myth 2 - Hooking up in college is bad for women

Do you think "Hooking up in college is bad for women" is a myth or truth She got the text a little after midnight: “Want to hang out?” She knew what that meant. It was from her friend (with benefits), Jim. There was only one reason that he would be texting her late on a weekday during midterms. She and Jim were both majoring in tough disciplines and took their classes seriously. The hard work was paying off because they both had good grades. Unlike a lot of their classmates, they had their plans in place and knew what it would take to get into graduate school. So, there was no way that Jim wanted to go to one of the bars or fraternity parties. He had the same test she had in about 12 hours. She looked at the text again and noticed that her eyes were blurry from studying without a break for the last three hours. She was tired and needed sleep, but she also knew that she was keyed up and anxious about the test. She liked Jim. He was smart and occasionally funny. He was ...