DEV Community

Discussion on: Daily Challenge #136 - The Deaf Rats of Hamelin

Collapse
 
erezwanderman profile image
erezwanderman

JS

deaf = town => [...town].filter((x, i, a) => x === 'O' && ((a[i + 1] ==='~' && i < a.indexOf('P')) || (a[i - 1] ==='~' && i > a.indexOf('P')))).length