Решение на Астрологични забави от Валентина Жекова

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

Към профила на Валентина Жекова

Резултати

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

Код

def interpret_western_sign(day, month):
western_signs = (("aquarius", 21), ("pisces", 19), ("aries", 21),
("taurus", 21), ("gemini", 21), ("cancer", 21),
("leo", 23), ("virgo", 23), ("libra", 23),
("scorpio", 23), ("sagittarius", 22), ("capricorn", 22))
month_shifted = month - 1
sign_begining = western_signs[month_shifted][1]
if day >= sign_begining:
return western_signs[month_shifted][0]
else:
return western_signs[month_shifted - 1][0]
def interpret_chinese_sign(year):
chinese_signs = ('rat', 'ox', 'tiger', 'rabbit', 'dragon', 'snake',
'horse', 'sheep', 'monkey', 'rooster', 'dog', 'pig')
base_offset = 12 - 1900 % 12
sign_number = (year % 12 + base_offset) % 12
return chinese_signs[sign_number]
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

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

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

OK

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

Валентина обнови решението на 06.03.2015 01:51 (преди над 9 години)

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

Валентина обнови решението на 09.03.2015 17:58 (преди над 9 години)

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

Валентина обнови решението на 09.03.2015 23:36 (преди над 9 години)

def interpret_western_sign(day, month):
- month_dictionary = {1: ("capricorn", "aquarius", 21),
- 2: ("aquarius", "pisces", 19),
- 3: ("pisces", "aries", 21),
- 4: ("aries", "taurus", 21),
- 5: ("taurus", "gemini", 21),
- 6: ("gemini", "cancer", 21),
- 7: ("cancer", "leo", 23),
- 8: ("leo", "virgo", 23),
- 9: ("virgo", "libra", 23),
- 10: ("libra", "scorpio", 23),
- 11: ("scorpio", "sagittarius", 22),
- 12: ("sagittarius", "capricorn", 22)}
+ western_signs = (("aquarius", 21), ("pisces", 19), ("aries", 21),
+ ("taurus", 21), ("gemini", 21), ("cancer", 21),
+ ("leo", 23), ("virgo", 23), ("libra", 23),
+ ("scorpio", 23), ("sagittarius", 22), ("capricorn", 22))
- sign_edge = month_dictionary[month][2]
- if day < sign_edge:
- return month_dictionary[month][0]
+ month_shifted = month - 1
+ sign_begining = western_signs[month_shifted][1]
+ if day >= sign_begining:
+ return western_signs[month_shifted][0]
else:
- return month_dictionary[month][1]
+ return western_signs[month_shifted - 1][0]
def interpret_chinese_sign(year):
- chinese_signs_shifted = ['monkey', 'rooster', 'dog', 'pig',
- 'rat', 'ox', 'tiger', 'rabbit',
- 'dragon', 'snake', 'horse', 'sheep']
- sign_number = year % 12
- return chinese_signs_shifted[sign_number]
+ chinese_signs = ('rat', 'ox', 'tiger', 'rabbit', 'dragon', 'snake',
+ 'horse', 'sheep', 'monkey', 'rooster', 'dog', 'pig')
+ base_offset = 12 - 1900 % 12
+ sign_number = (year % 12 + base_offset) % 12
+ return chinese_signs[sign_number]
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))