From b7b89632947bf2c7f64b981a96a7e23b36d7f9bd Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 14 May 2024 14:25:40 +0100 Subject: - Added solutions by Eric Cheung. - Added solutions by Ulrich Rieke. - Added solutions by Laurent Rosenfeld. - Added solutions by E. Choroba. - Added solutions by Mark Anderson. - Added solutions by Feng Chang. - Added solutions by PokGoPun. - Added solutions by Peter Campbell Smith. - Added solutions by Peter Meszaros. - Added solutions by W. Luis Mochan. - Added solutions by David Ferrone. - Added solutions by Niels van Dijke. - Added solutions by Arne Sommer. - Added solutions by Dave Jacoby. - Added solutions by Robbie Hatley. - Added solutions by Lubos Kolouch. - Added solutions by Asher Harvey-Smith. --- challenge-269/eric-cheung/python/ch-2.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 challenge-269/eric-cheung/python/ch-2.py (limited to 'challenge-269/eric-cheung/python/ch-2.py') diff --git a/challenge-269/eric-cheung/python/ch-2.py b/challenge-269/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..bb95583826 --- /dev/null +++ b/challenge-269/eric-cheung/python/ch-2.py @@ -0,0 +1,15 @@ + +## arrInt = [2, 1, 3, 4, 5] ## Example 1 +## arrInt = [3, 2, 4] ## Example 2 +arrInt = [5, 4, 3 ,8] ## Example 3 + +arrOut_01 = [arrInt[0]] +arrOut_02 = [arrInt[1]] + +for nLoop in arrInt[2:]: + if arrOut_01[-1] > arrOut_02[-1]: + arrOut_01.append(nLoop) + else: + arrOut_02.append(nLoop) + +print (arrOut_01 + arrOut_02) -- cgit