From bfa8b8a3dda2ac37c22c7f4fc2867211f92f65e0 Mon Sep 17 00:00:00 2001 From: Paulo Custodio Date: Tue, 9 Mar 2021 19:51:39 +0000 Subject: Add Perl, Lua and Python solutions to challenge 103 --- challenge-103/paulo-custodio/python/ch-1.py | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 challenge-103/paulo-custodio/python/ch-1.py (limited to 'challenge-103/paulo-custodio/python/ch-1.py') diff --git a/challenge-103/paulo-custodio/python/ch-1.py b/challenge-103/paulo-custodio/python/ch-1.py new file mode 100644 index 0000000000..4231b5f109 --- /dev/null +++ b/challenge-103/paulo-custodio/python/ch-1.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +# Challenge 103 +# +# TASK #1 > Chinese Zodiac +# Submitted by: Mohammad S Anwar +# You are given a year $year. +# +# Write a script to determine the Chinese Zodiac for the given year $year. +# Please check out wikipage for more information about it. +# +# The animal cycle: Rat, Ox, Tiger, Rabbit, Dragon, Snake, Horse, Goat, Monkey, +# Rooster, Dog, Pig. +# The element cycle: Wood, Fire, Earth, Metal, Water. +# +# Example 1: +# Input: 2017 +# Output: Fire Rooster +# Example 2: +# Input: 1938 +# Output: Earth Tiger + +import sys; + +animals = ['Rat','Ox','Tiger','Rabbit','Dragon','Snake','Horse','Goat', + 'Monkey','Rooster','Dog','Pig'] +elements = ['Wood','Wood','Fire','Fire','Earth','Earth','Metal','Metal', + 'Water','Water']; + +year = int(sys.argv[1]) +num_years = year-1924; +element = num_years % len(elements); +animal = num_years % len(animals); + +print(elements[element]," ",animals[animal]); -- cgit From c51f9bd979dbd79f20cb0abd543dc9b4df9f4e84 Mon Sep 17 00:00:00 2001 From: Paulo Custodio Date: Tue, 9 Mar 2021 20:01:18 +0000 Subject: Remove tabs --- challenge-103/paulo-custodio/python/ch-1.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'challenge-103/paulo-custodio/python/ch-1.py') diff --git a/challenge-103/paulo-custodio/python/ch-1.py b/challenge-103/paulo-custodio/python/ch-1.py index 4231b5f109..4eed2f269d 100644 --- a/challenge-103/paulo-custodio/python/ch-1.py +++ b/challenge-103/paulo-custodio/python/ch-1.py @@ -1,18 +1,18 @@ #!/usr/bin/env python # Challenge 103 -# +# # TASK #1 > Chinese Zodiac # Submitted by: Mohammad S Anwar # You are given a year $year. -# -# Write a script to determine the Chinese Zodiac for the given year $year. +# +# Write a script to determine the Chinese Zodiac for the given year $year. # Please check out wikipage for more information about it. -# +# # The animal cycle: Rat, Ox, Tiger, Rabbit, Dragon, Snake, Horse, Goat, Monkey, # Rooster, Dog, Pig. # The element cycle: Wood, Fire, Earth, Metal, Water. -# +# # Example 1: # Input: 2017 # Output: Fire Rooster @@ -23,9 +23,9 @@ import sys; animals = ['Rat','Ox','Tiger','Rabbit','Dragon','Snake','Horse','Goat', - 'Monkey','Rooster','Dog','Pig'] + 'Monkey','Rooster','Dog','Pig'] elements = ['Wood','Wood','Fire','Fire','Earth','Earth','Metal','Metal', - 'Water','Water']; + 'Water','Water']; year = int(sys.argv[1]) num_years = year-1924; -- cgit