# DataWeave programming challenge #2: Rock Paper Scissors game score system

**In this post:**

This challenge is based onAdvent of Code 2022 day 2

Try to solve this challenge on your own to maximize learning. We recommend you refer to the __DataWeave documentation__ __ only__. Try to avoid using Google or asking others so you can learn on your own and become a DataWeave expert!

## Input

Consider the following input payload (can be of **txt** format):

```
R R
R P
R S
P R
P P
P S
S R
S P
S S
R R
```

## Explanation of the problem

Create a DataWeave script to keep your score on a series of Rock Paper Scissors games. The first column is what your **opponent** chose and the second column is what **you** chose. Each letter is a representation of the decision made:

R = Rock

P = Paper

S = Scissors

The rules of the game are simple:

Rock defeats Scissors

Paper defeats Rock

Scissors defeat Paper

As per the scoring system, you will have to keep track of whether you won, lost, or if it was a draw. Remember the second column is your choice. Here's how you will be counting the points:

0 points if you lost the round

3 points if the round was a draw

6 points if you won the round

For example,

The first round was

**R R**, which means both your opponent and you chose Rock. This round results in a**draw**, so**3**points are added.The second round was

**R P**, which means your opponent chose Rock and you chose Paper. Paper defeats Rock, which means you win this round.**6**points are added.The third round was

**R S**, which means your opponent chose Rock and you chose Scissors. Rock defeats Scissors, which means you lose this round.**0**points are added.

The final result will be the number of total points you earned in the 10 rounds.

## Expected output

In this case, the expected output would be:

`30`

The result for each of the 10 rounds should be:

3

6

0

0

3

6

6

0

3

3