From ff9c2dc64f984f4e5be20ce7b492f02966cd2439 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Sun, 29 Jan 2023 13:57:29 +0000 Subject: - Added solutions by Mark Anderson. - Added solutions by Bob Lied. - Added solutions by Mariano Spadaccini. - Added solutions by Peter Campbell Smith. - Added solutions by Luca Ferrari. - Added solutions by W. Luis Mochan. - Added solutions by Carlos Oliveira. - Added solutions by Dave Jacoby. - Added solutions by E. Choroba. - Added solutions by David Ferrone. - Added solutions by Roger Bell_West. - Added solutions by Simon Green. - Added solutions by Thomas Kohler. - Added solutions by Arpad Toth. - Added solutions by Robbie Hatley. - Added solutions by Jorg Sommrey. - Added solutions by PokGoPun. - Added solutions by Pip Stuart. - Added solutions by Ali Moradi. - Added solutions by Robert Ransbottom. - Added solutions by Ulrich Rieke. - Added solutions by Robert DiCicco. - Added solutions by Cheok-Yin Fung. --- challenge-201/eric-cheung/python/ch-1.py | 8 ++++++++ challenge-201/eric-cheung/python/ch-2.py | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 challenge-201/eric-cheung/python/ch-1.py create mode 100755 challenge-201/eric-cheung/python/ch-2.py (limited to 'challenge-201/eric-cheung/python') diff --git a/challenge-201/eric-cheung/python/ch-1.py b/challenge-201/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..da9bdec3ed --- /dev/null +++ b/challenge-201/eric-cheung/python/ch-1.py @@ -0,0 +1,8 @@ + +## nInputArr = [0, 1, 3] ## Example 1 +nInputArr = [0, 1] ## Example 2 + +nFullArr = range(0, len(nInputArr) + 1) +nComplementArr = [nElemLoop for nElemLoop in nFullArr if nElemLoop not in nInputArr] + +print (nComplementArr) diff --git a/challenge-201/eric-cheung/python/ch-2.py b/challenge-201/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..8aaeccba36 --- /dev/null +++ b/challenge-201/eric-cheung/python/ch-2.py @@ -0,0 +1,22 @@ + +## Remarks +## https://theweeklychallenge.org/blog/perl-weekly-challenge-201/ +## https://www.geeksforgeeks.org/count-ways-reach-nth-stair/ + +## Python Program to Count Ways to Reach Nth stair + +## Recursive Function to Find Nth Fibonacci Number +def GetFibNum(nInput): + + if nInput <= 1: + return nInput + + return GetFibNum(nInput - 1) + GetFibNum(nInput - 2) + + +## Driver Program +nInputNum = 5 + +print ("Number of Ways: " + str(GetFibNum(nInputNum + 1))) + +## Contributed by Harshit Agrawal -- cgit