DEV Community

Discussion on: Daily Challenge #129 - Clay Pigeon Shooting

Collapse
 
hiddewie profile image
Hidde Wieringa

A try using JavaScript:

const playerScore = (player) => player.split('').filter(it => it === 'O').length
const calculateScore = (data) => data.reduce((score, [{P1, P2}, double]) => score + (double ? 2 : 1) * playerScore(P1) - playerScore(P2), 0)
const printScore = s => (s === 0 ? "Draw!" : (s > 0 ? "Pete Wins!" : "Phil Wins!"))
const shoot = s => printScore(calculateScore(s))
Collapse
 
chandrakumarreddy profile image
Chandra

working code for clay pigeon shooting

Collapse
 
hiddewie profile image
Hidde Wieringa

Oh it seems I took a hit for a miss and the other way around 😉