-
-
Save robhol/1569861058818f97bb2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lambda inp: sum( [v - 2 * sv for (sv, v) in [ | |
(pv if pv < v else 0, v) for (pv, v) in [ | |
(values[pc] if pc else 0, values[c]) for (pc, c) in | |
zip([None] + list(inp), inp) ]]] ) | |
# "values" dict omitted because it'd be a bit of a giveaway |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment