Skip to content

Instantly share code, notes, and snippets.

@kdankov
Created November 12, 2024 11:57
Show Gist options
  • Save kdankov/8a43227c5693db531236f62acd9addde to your computer and use it in GitHub Desktop.
Save kdankov/8a43227c5693db531236f62acd9addde to your computer and use it in GitHub Desktop.
Fun with JS
function solve(s, o) {
Object
.entries([...s, ...o].reduce((s, p, i, a) => ( i % 2 === 0 ? { ...s, [p]: (s[p] || 0) + Number(a[i + 1]) } : s), {}))
.forEach(([p, q]) => console.log(`${p} -> ${q}`));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment