Решение на Астрологични забави от Петър Гетов

Обратно към всички решения

Към профила на Петър Гетов

Резултати

  • 10 точки от тестове
  • 0 бонус точки
  • 10 точки общо
  • 6 успешни тест(а)
  • 0 неуспешни тест(а)

Код

CHINESE_SIGNS_MAP = ["monkey",
"rooster",
"dog",
"pig",
"rat",
"ox",
"tiger",
"rabbit",
"dragon",
"snake",
"horse",
"sheep"]
RANGES =[0,
[(1, 20, "capricorn"), (21, 31, "aquarius")],
[(1, 18, "aquarius"), (19, 29, "pisces")],
[(1, 20, "pisces"), (21, 31, "aries")],
[(1, 20, "aries"), (21, 30, "taurus")],
[(1, 20, "taurus"), (21, 31, "gemini")],
[(1, 20, "gemini"), (21, 30, "cancer")],
[(1, 22, "cancer"), (23, 31, "leo")],
[(1, 22, "leo"), (23, 31, "virgo")],
[(1, 22, "virgo"), (23, 30, "libra")],
[(1, 22, "libra"), (23, 31, "scorpio")],
[(1, 21, "scorpio"), (22, 30, "sagittarius")],
[(1, 21, "sagittarius"), (22, 31, "capricorn")]]
def interpret_western_sign(day, month):
ranges = RANGES[month]
for date in ranges:
if day >= date[0] and day <= date[1]:
return date[2]
def interpret_chinese_sign(year):
return CHINESE_SIGNS_MAP[year%12]
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), CHINESE_SIGNS_MAP[year%12])

Лог от изпълнението

......
----------------------------------------------------------------------
Ran 6 tests in 0.006s

OK

История (3 версии и 3 коментара)

Петър обнови решението на 08.03.2015 12:43 (преди над 9 години)

+
+CHINESE_SIGNS_MAP = { 0: "monkey", 1: "rooster", 2: "dog", 3: "pig", 4: "rat", 5: "ox",
+ 6: "tiger", 7: "rabbit", 8: "dragon", 9: "snake", 10: "horse", 11: "sheep" }
+
+RANGES = [ 0,
+ [(1, 20, "capricorn"), (21, 31, "aquarius")],
+ [(1, 18, "aquarius"), (19, 29, "pisces")],
+ [(1, 20, "pisces"), (21, 31, "aries")],
+ [(1, 20, "aries"), (21, 30, "taurus")],
+ [(1, 20, "taurus"), (21, 31, "gemini")],
+ [(1, 20, "gemini"), (21, 30, "cancer")],
+ [(1, 22, "cancer"), (23, 31, "leo")],
+ [(1, 22, "leo"), (23, 31, "virgo")],
+ [(1, 22, "virgo"), (23, 30, "libra")],
+ [(1, 22, "libra"), (23, 31, "scorpio")],
+ [(1, 21, "scorpio"), (22, 30, "sagittarius")],
+ [(1, 21, "sagittarius"), (22, 31, "capricorn")]
+ ]
+
+def interpret_western_sign(day, month):
+ ranges = RANGES[month]
+ for date in ranges:
+ if day >= date[0] and day <= date[1]:
+ return date[2]
+
+def interpret_chinese_sign(year):
+ return CHINESE_SIGNS_MAP[year%12]
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), CHINESE_SIGNS_MAP[year%12])

Петър обнови решението на 08.03.2015 15:47 (преди над 9 години)

+CHINESE_SIGNS_MAP = ["monkey",
+ "rooster",
+ "dog",
+ "pig",
+ "rat",
+ "ox",
+ "tiger",
+ "rabbit",
+ "dragon",
+ "snake",
+ "horse",
+ "sheep"]
-CHINESE_SIGNS_MAP = { 0: "monkey", 1: "rooster", 2: "dog", 3: "pig", 4: "rat", 5: "ox",
- 6: "tiger", 7: "rabbit", 8: "dragon", 9: "snake", 10: "horse", 11: "sheep" }
+RANGES =[0,
+ [(1, 20, "capricorn"), (21, 31, "aquarius")],
+ [(1, 18, "aquarius"), (19, 29, "pisces")],
+ [(1, 20, "pisces"), (21, 31, "aries")],
+ [(1, 20, "aries"), (21, 30, "taurus")],
+ [(1, 20, "taurus"), (21, 31, "gemini")],
+ [(1, 20, "gemini"), (21, 30, "cancer")],
+ [(1, 22, "cancer"), (23, 31, "leo")],
+ [(1, 22, "leo"), (23, 31, "virgo")],
+ [(1, 22, "virgo"), (23, 30, "libra")],
+ [(1, 22, "libra"), (23, 31, "scorpio")],
+ [(1, 21, "scorpio"), (22, 30, "sagittarius")],
+ [(1, 21, "sagittarius"), (22, 31, "capricorn")]]
-RANGES = [ 0,
- [(1, 20, "capricorn"), (21, 31, "aquarius")],
- [(1, 18, "aquarius"), (19, 29, "pisces")],
- [(1, 20, "pisces"), (21, 31, "aries")],
- [(1, 20, "aries"), (21, 30, "taurus")],
- [(1, 20, "taurus"), (21, 31, "gemini")],
- [(1, 20, "gemini"), (21, 30, "cancer")],
- [(1, 22, "cancer"), (23, 31, "leo")],
- [(1, 22, "leo"), (23, 31, "virgo")],
- [(1, 22, "virgo"), (23, 30, "libra")],
- [(1, 22, "libra"), (23, 31, "scorpio")],
- [(1, 21, "scorpio"), (22, 30, "sagittarius")],
- [(1, 21, "sagittarius"), (22, 31, "capricorn")]
- ]
def interpret_western_sign(day, month):
ranges = RANGES[month]
for date in ranges:
if day >= date[0] and day <= date[1]:
return date[2]
-def interpret_chinese_sign(year):
- return CHINESE_SIGNS_MAP[year%12]
-def interpret_both_signs(day, month, year):
- return (interpret_western_sign(day, month), CHINESE_SIGNS_MAP[year%12])
+def interpret_chinese_sign(year):
+ return CHINESE_SIGNS_MAP[year%12]

Петър обнови решението на 08.03.2015 15:50 (преди над 9 години)

CHINESE_SIGNS_MAP = ["monkey",
"rooster",
"dog",
"pig",
"rat",
"ox",
"tiger",
"rabbit",
"dragon",
"snake",
"horse",
"sheep"]
RANGES =[0,
[(1, 20, "capricorn"), (21, 31, "aquarius")],
[(1, 18, "aquarius"), (19, 29, "pisces")],
[(1, 20, "pisces"), (21, 31, "aries")],
[(1, 20, "aries"), (21, 30, "taurus")],
[(1, 20, "taurus"), (21, 31, "gemini")],
[(1, 20, "gemini"), (21, 30, "cancer")],
[(1, 22, "cancer"), (23, 31, "leo")],
[(1, 22, "leo"), (23, 31, "virgo")],
[(1, 22, "virgo"), (23, 30, "libra")],
[(1, 22, "libra"), (23, 31, "scorpio")],
[(1, 21, "scorpio"), (22, 30, "sagittarius")],
[(1, 21, "sagittarius"), (22, 31, "capricorn")]]
def interpret_western_sign(day, month):
ranges = RANGES[month]
for date in ranges:
if day >= date[0] and day <= date[1]:
return date[2]
def interpret_chinese_sign(year):
- return CHINESE_SIGNS_MAP[year%12]
+ return CHINESE_SIGNS_MAP[year%12]
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), CHINESE_SIGNS_MAP[year%12])