Решение на Астрологични забави от Александър Чешмеджиев

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

Към профила на Александър Чешмеджиев

Резултати

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

Код

STARSIGNS = {
'aries': ((21, 3), (20, 4)),
'taurus': ((21, 4), (20, 5)),
'gemini': ((21, 5), (20, 6)),
'cancer': ((21, 6), (22, 7)),
'leo': ((23, 7), (22, 8)),
'virgo': ((23, 8), (22, 9)),
'libra': ((23, 9), (22, 10)),
'scorpio': ((23, 10), (21, 11)),
'sagittarius': ((22, 11), (21, 12)),
'capricorn': ((22, 12), (20, 1)),
'aquarius': ((21, 1), (19, 2)),
'pisces': ((19, 2), (20, 3))
}
CHINESE_SIGNS_INITIAL_YEARS = {
'rat': 1900,
'ox': 1901,
'tiger': 1902,
'rabbit': 1903,
'dragon': 1904,
'snake': 1905,
'horse': 1906,
'sheep': 1907,
'monkey': 1908,
'rooster': 1909,
'dog': 1910,
'pig': 1911
}
def interpret_western_sign(day, month):
for sign, sign_interval in STARSIGNS.items():
if ((sign_interval[0][1] == month and sign_interval[0][0] <= day) or
(sign_interval[1][1] == month and sign_interval[1][0] >= day)):
return sign
def interpret_chinese_sign(year):
for sign, sign_initial_year in CHINESE_SIGNS_INITIAL_YEARS.items():
if (year - sign_initial_year) % 12 == 0:
return sign
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 версии и 1 коментар)

Александър обнови решението на 10.03.2015 10:17 (преди над 9 години)

+starsigns = {
+ 'aries': ((21, 3), (20, 4)),
+ 'taurus': ((21, 4), (20, 5)),
+ 'gemini': ((21, 5), (20, 6)),
+ 'cancer': ((21, 6), (22, 7)),
+ 'leo': ((23, 7), (22, 8)),
+ 'virgo': ((23, 8), (22, 9)),
+ 'libra': ((23, 9), (22, 10)),
+ 'scorpio': ((23, 10), (21, 11)),
+ 'sagittarius': ((22, 11), (21, 12)),
+ 'capricorn': ((22, 12), (20, 1)),
+ 'aquarius': ((21, 1), (19, 2)),
+ 'pisces': ((19, 2), (20, 3))
+}
+
+chinese_signs_initial_years = {
+ 'rat': 1900,
+ 'ox': 1901,
+ 'tiger': 1902,
+ 'rabbit': 1903,
+ 'dragon': 1904,
+ 'snake': 1905,
+ 'horse': 1906,
+ 'sheep': 1907,
+ 'monkey': 1908,
+ 'rooster': 1909,
+ 'dog': 1910,
+ 'pig': 1911
+}
+
+def interpret_western_sign(day, month):
+ for sign, sign_interval in starsigns.items():
+ if ((sign_interval[0][1] == month and sign_interval[0][0] <= day) or
+ (sign_interval[1][1] == month and sign_interval[1][0] >= day)):
+ return sign
+
+def interpret_chinese_sign(year):
+ for sign, sign_initial_year in chinese_signs_initial_years.items():
+ if (year - sign_initial_year) % 12 == 0:
+ return sign
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))
+

Александър обнови решението на 10.03.2015 16:35 (преди над 9 години)

-starsigns = {
+STARSIGNS = {
'aries': ((21, 3), (20, 4)),
'taurus': ((21, 4), (20, 5)),
'gemini': ((21, 5), (20, 6)),
'cancer': ((21, 6), (22, 7)),
'leo': ((23, 7), (22, 8)),
'virgo': ((23, 8), (22, 9)),
'libra': ((23, 9), (22, 10)),
'scorpio': ((23, 10), (21, 11)),
'sagittarius': ((22, 11), (21, 12)),
'capricorn': ((22, 12), (20, 1)),
'aquarius': ((21, 1), (19, 2)),
'pisces': ((19, 2), (20, 3))
}
-chinese_signs_initial_years = {
- 'rat': 1900,
+CHINESE_SIGNS_INITIAL_YEARS = {
+ 'rat': 1900,
'ox': 1901,
'tiger': 1902,
'rabbit': 1903,
'dragon': 1904,
'snake': 1905,
'horse': 1906,
'sheep': 1907,
'monkey': 1908,
'rooster': 1909,
'dog': 1910,
'pig': 1911
}
+
def interpret_western_sign(day, month):
- for sign, sign_interval in starsigns.items():
- if ((sign_interval[0][1] == month and sign_interval[0][0] <= day) or
+ for sign, sign_interval in STARSIGNS.items():
+ if ((sign_interval[0][1] == month and sign_interval[0][0] <= day) or
(sign_interval[1][1] == month and sign_interval[1][0] >= day)):
return sign
+
def interpret_chinese_sign(year):
- for sign, sign_initial_year in chinese_signs_initial_years.items():
+ for sign, sign_initial_year in CHINESE_SIGNS_INITIAL_YEARS.items():
if (year - sign_initial_year) % 12 == 0:
return sign
+
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))
-