Решение на Астрологични забави от Милка Ферезлийска

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

Към профила на Милка Ферезлийска

Резултати

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

Код

def interpret_chinese_sign(year):
chinese_signs = [
"rat", "ox", "tiger", "rabbit", "dragon", "snake", "horse",
"sheep", "monkey", "rooster", "dog", "pig"]
key = abs(year - 1900) % 12
if year < 1900 and key != 0:
key = 12 - key
return chinese_signs[key]
def interpret_western_sign(day, month):
western_signs = [
(21, "capricorn", "aquarius"),
(19, "aquarius", "pisces"),
(21, "pisces", "aries"),
(21, "aries", "taurus"),
(21, "taurus", "gemini"),
(21, "gemini", "cancer"),
(23, "cancer", "leo"),
(23, "leo", "virgo"),
(23, "virgo", "libra"),
(23, "libra", "scorpio"),
(22, "scorpio", "sagittarius"),
(22, "sagittarius", "capricorn")
]
sign = western_signs[month - 1]
border_date = sign[0]
return sign[1] if day < border_date else sign[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

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

Милка обнови решението на 07.03.2015 10:26 (преди над 9 години)

+def interpret_chinese_sign(year):
+ chinese_signs = {
+ 0: "rat",
+ 1: "ox",
+ 2: "tiger",
+ 3: "rabbit",
+ 4: "dragon",
+ 5: "snake",
+ 6: "horse",
+ 7: "sheep",
+ 8: "monkey",
+ 9: "rooster",
+ 10: "dog",
+ 11: "pig"
+ }
+ key = abs(year - 1900) % 12
+ return chinese_signs[key]
+
+
+def interpret_western_sign(day, month):
+ western_signs = {
+ 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")
+ }
+ sign = western_signs[month]
+ border_date = sign[0]
+ return sign[1] if day < border_date else sign[2]
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Милка обнови решението на 07.03.2015 17:00 (преди над 9 години)

def interpret_chinese_sign(year):
chinese_signs = {
0: "rat",
1: "ox",
2: "tiger",
3: "rabbit",
4: "dragon",
5: "snake",
6: "horse",
7: "sheep",
8: "monkey",
9: "rooster",
10: "dog",
11: "pig"
}
key = abs(year - 1900) % 12
+ if year < 1900 and key != 0:
+ key = 12 - key
return chinese_signs[key]
def interpret_western_sign(day, month):
western_signs = {
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")
}
sign = western_signs[month]
border_date = sign[0]
return sign[1] if day < border_date else sign[2]
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Милка обнови решението на 08.03.2015 11:45 (преди над 9 години)

def interpret_chinese_sign(year):
- chinese_signs = {
- 0: "rat",
- 1: "ox",
- 2: "tiger",
- 3: "rabbit",
- 4: "dragon",
- 5: "snake",
- 6: "horse",
- 7: "sheep",
- 8: "monkey",
- 9: "rooster",
- 10: "dog",
- 11: "pig"
- }
+ chinese_signs = [
+ "rat", "ox", "tiger", "rabbit", "dragon", "snake", "horse",
+ "sheep", "monkey", "rooster", "dog", "pig"]
key = abs(year - 1900) % 12
if year < 1900 and key != 0:
key = 12 - key
return chinese_signs[key]
def interpret_western_sign(day, month):
western_signs = {
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")
}
sign = western_signs[month]
border_date = sign[0]
return sign[1] if day < border_date else sign[2]
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Милка обнови решението на 09.03.2015 22:18 (преди над 9 години)

def interpret_chinese_sign(year):
chinese_signs = [
"rat", "ox", "tiger", "rabbit", "dragon", "snake", "horse",
"sheep", "monkey", "rooster", "dog", "pig"]
key = abs(year - 1900) % 12
if year < 1900 and key != 0:
key = 12 - key
return chinese_signs[key]
def interpret_western_sign(day, month):
- western_signs = {
- 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")
- }
- sign = western_signs[month]
+ western_signs = [
+ (21, "capricorn", "aquarius"),
+ (19, "aquarius", "pisces"),
+ (21, "pisces", "aries"),
+ (21, "aries", "taurus"),
+ (21, "taurus", "gemini"),
+ (21, "gemini", "cancer"),
+ (23, "cancer", "leo"),
+ (23, "leo", "virgo"),
+ (23, "virgo", "libra"),
+ (23, "libra", "scorpio"),
+ (22, "scorpio", "sagittarius"),
+ (22, "sagittarius", "capricorn")
+ ]
+ sign = western_signs[month - 1]
border_date = sign[0]
return sign[1] if day < border_date else sign[2]
def interpret_both_signs(day, month, year):
- return (interpret_western_sign(day, month), interpret_chinese_sign(year))
+ return interpret_western_sign(day, month), interpret_chinese_sign(year)