From efb3278cc6f9f0964d14fb1ec4b3e0fb5d7e49c6 Mon Sep 17 00:00:00 2001 From: Sigmanificient Date: Wed, 13 Nov 2024 09:41:34 +0100 Subject: [PATCH] Add solution for simple fun coord helper --- .../katas/py6kyu/simple_fun_coordinate_helper.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/python/katas/py6kyu/simple_fun_coordinate_helper.py diff --git a/src/python/katas/py6kyu/simple_fun_coordinate_helper.py b/src/python/katas/py6kyu/simple_fun_coordinate_helper.py new file mode 100644 index 0000000..10c42e5 --- /dev/null +++ b/src/python/katas/py6kyu/simple_fun_coordinate_helper.py @@ -0,0 +1,12 @@ +"""Kata url: https://www.codewars.com/kata/5936107d40ed69ea1e00003d.""" + +"""Kata url: https://www.codewars.com/kata/5936107d40ed69ea1e00003d.""" + +def coordinate_helper(cmd): + x=y=0 + getd=lambda d,s:(d==s[0])-(d==s[1]) + for d, n in cmd: + if d and (n:=d[1:]).isdigit(): + x += getd(d,"DA") * int(n) + y += getd(d,"WS") * int(n) + return x, y \ No newline at end of file