Решение на Астрологични забави от Божидар Григоров

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

Към профила на Божидар Григоров

Резултати

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

Код

chinese_sign = [
"monkey",
"rooster",
"dog",
"pig",
"rat",
"ox",
"tiger",
"rabbit",
"dragon",
"snake",
"horse",
"sheep"
]
western_sign = {
1: (21, "capricorn", "aquarius"),
2: (19, "aquarius", "pisces"),
3: (21, "pisces", "aries"),
4: (21, "aries", "taurus"),
5: (21, "taurus", "gemini"),
6: (21, "gemini", "cancer"),
7: (23, "cancer", "leo"),
8: (23, "leo", "virgo"),
9: (23, "virgo", "libra"),
10: (23, "libra", "scorpio"),
11: (22, "scorpio", "sagittarius"),
12: (22, "sagittarius", "capricorn"),
}
def interpret_chinese_sign(year):
return chinese_sign[year % 12]
def interpret_western_sign(day, month):
return (western_sign[month][1]
if western_sign[month][0] > day
else western_sign[month][2])
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

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

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

OK

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

Божидар обнови решението на 10.03.2015 21:42 (преди над 9 години)

+chinese_sign = {
+ str(1900 % 12): "rat",
+ str(1901 % 12): "ox",
+ str(1902 % 12): "tiger",
+ str(1903 % 12): "rabbit",
+ str(1904 % 12): "dragon",
+ str(1905 % 12): "snake",
+ str(1906 % 12): "horse",
+ str(1907 % 12): "sheep",
+ str(1908 % 12): "monkey",
+ str(1909 % 12): "rooster",
+ str(1910 % 12): "dog",
+ str(1911 % 12): "pig",
+}
+
+
+western_sign = {
+ "1": (21, "capricorn", "aquarius"),
+ "2": (19, "aquarius", "pisces"),
+ "3": (21, "pisces", "aries"),
+ "4": (21, "aries", "taurus"),
+ "5": (21, "taurus", "gemini"),
+ "6": (21, "gemini", "cancer"),
+ "7": (23, "cancer", "leo"),
+ "8": (23, "leo", "virgo"),
+ "9": (23, "virgo", "libra"),
+ "10": (23, "libra", "scorpio"),
+ "11": (22, "scorpio", "sagittarius"),
+ "12": (22, "sagittarius", "capricorn"),
+}
+
+
+def interpret_chinese_sign(year):
+ return chinese_sign[str(year % 12)]
+
+
+def interpret_western_sign(day, month):
+ return (western_sign[str(month)][1]
+ if western_sign[str(month)][0] > day
+ else western_sign[str(month)][2])
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Божидар обнови решението на 11.03.2015 10:07 (преди над 9 години)

-chinese_sign = {
- str(1900 % 12): "rat",
- str(1901 % 12): "ox",
- str(1902 % 12): "tiger",
- str(1903 % 12): "rabbit",
- str(1904 % 12): "dragon",
- str(1905 % 12): "snake",
- str(1906 % 12): "horse",
- str(1907 % 12): "sheep",
- str(1908 % 12): "monkey",
- str(1909 % 12): "rooster",
- str(1910 % 12): "dog",
- str(1911 % 12): "pig",
-}
+chinese_sign = [
+ "monkey",
+ "rooster",
+ "dog",
+ "pig",
+ "rat",
+ "ox",
+ "tiger",
+ "rabbit",
+ "dragon",
+ "snake",
+ "horse",
+ "sheep"
+]
-
western_sign = {
- "1": (21, "capricorn", "aquarius"),
- "2": (19, "aquarius", "pisces"),
- "3": (21, "pisces", "aries"),
- "4": (21, "aries", "taurus"),
- "5": (21, "taurus", "gemini"),
- "6": (21, "gemini", "cancer"),
- "7": (23, "cancer", "leo"),
- "8": (23, "leo", "virgo"),
- "9": (23, "virgo", "libra"),
- "10": (23, "libra", "scorpio"),
- "11": (22, "scorpio", "sagittarius"),
- "12": (22, "sagittarius", "capricorn"),
+ 1: (21, "capricorn", "aquarius"),
+ 2: (19, "aquarius", "pisces"),
+ 3: (21, "pisces", "aries"),
+ 4: (21, "aries", "taurus"),
+ 5: (21, "taurus", "gemini"),
+ 6: (21, "gemini", "cancer"),
+ 7: (23, "cancer", "leo"),
+ 8: (23, "leo", "virgo"),
+ 9: (23, "virgo", "libra"),
+ 10: (23, "libra", "scorpio"),
+ 11: (22, "scorpio", "sagittarius"),
+ 12: (22, "sagittarius", "capricorn"),
}
def interpret_chinese_sign(year):
- return chinese_sign[str(year % 12)]
+ return chinese_sign[year % 12]
def interpret_western_sign(day, month):
- return (western_sign[str(month)][1]
- if western_sign[str(month)][0] > day
- else western_sign[str(month)][2])
+ return (western_sign[month][1]
+ if western_sign[month][0] > day
+ else western_sign[month][2])
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))