From baa3a7798f21d45a7838fda486f49df63de56c08 Mon Sep 17 00:00:00 2001 From: Michael Manring Date: Sat, 8 Jun 2024 22:44:07 +1000 Subject: pw272 solution in python - simplify ch-2 --- challenge-272/pokgopun/python/ch-2.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/challenge-272/pokgopun/python/ch-2.py b/challenge-272/pokgopun/python/ch-2.py index 065e0b1609..e2414e4b16 100644 --- a/challenge-272/pokgopun/python/ch-2.py +++ b/challenge-272/pokgopun/python/ch-2.py @@ -67,10 +67,11 @@ SO WHAT DO YOU THINK ? """ ### solution by pokgopun@gmail.com -def ss(string: str): +def ss(s: str): return sum( - abs(ord(p[0])-ord(p[1])) for p in - (string[i:i+2] for i in range(len(string)-1)) + abs( + ord(s[i]) - ord(s[i+1]) + ) for i in range(len(s) - 1) ) import unittest -- cgit