From 65cf1411344711377714c7247e612a2e92b06861 Mon Sep 17 00:00:00 2001 From: ealvar3z <55966724+ealvar3z@users.noreply.github.com> Date: Fri, 2 Dec 2022 17:53:18 -0800 Subject: go & python solutions --- challenge-193/ealvar3z/python/ch-2.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 challenge-193/ealvar3z/python/ch-2.py (limited to 'challenge-193/ealvar3z/python/ch-2.py') diff --git a/challenge-193/ealvar3z/python/ch-2.py b/challenge-193/ealvar3z/python/ch-2.py new file mode 100644 index 0000000000..e94157c528 --- /dev/null +++ b/challenge-193/ealvar3z/python/ch-2.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + + +def odd_str(_list): + def diff(x): return [ord(x[i]) - ord(x[i - 1]) for i in range(1, len(x))] + _list.sort(key=diff) + + fst = _list[0] + snd = _list[1] + last = _list[-1] + + return fst if diff(fst) != diff(snd) else last + + +def main(): + words = ["adc", "wzy", "abc"] + print(odd_str(words)) + + +if __name__ == "__main__": + exit(main()) -- cgit