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

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

Към профила на Йоан Динков

Резултати

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

Код

def interpret_chinese_sign(year):
chinese_type = year % 12
chinese_signs = [
'rat', 'ox', 'tiger', 'rabbit',
'dragon', 'snake', 'horse', 'sheep',
'monkey', 'rooster', 'dog', 'pig'
]
return chinese_signs[chinese_type - 4]
def interpret_western_sign(day, month):
months = [
{'current': 'capricorn', 'next': 'aquarius', 'date': 21},
{'current': 'aquarius', 'next': 'pisces', 'date': 19},
{'current': 'pisces', 'next': 'aries', 'date': 21},
{'current': 'aries', 'next': 'taurus', 'date': 21},
{'current': 'taurus', 'next': 'gemini', 'date': 21},
{'current': 'gemini', 'next': 'cancer', 'date': 21},
{'current': 'cancer', 'next': 'leo', 'date': 23},
{'current': 'leo', 'next': 'virgo', 'date': 23},
{'current': 'virgo', 'next': 'libra', 'date': 23},
{'current': 'libra', 'next': 'scorpio', 'date': 23},
{'current': 'scorpio', 'next': 'sagittarius', 'date': 22},
{'current': 'sagittarius', 'next': 'capricorn', 'date': 22}
]
current_month = months[month - 1]
if day >= current_month['date']:
return current_month['next']
return current_month['current']
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

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

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

OK

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

Йоан обнови решението на 07.03.2015 15:02 (преди над 9 години)

+def interpret_chinese_sign(year):
+ chinese_type = year % 12
+
+ chinese_signs = ('rat', 'ox', 'tiger', 'rabbit', 'dragon', 'snake', 'horse', 'sheep', 'monkey', 'rooster', 'dog', 'pig')
+
+ return chinese_signs[chinese_type - 4]
+
+def interpret_western_sign(day, month):
+ zodiac_signs = ['capricorn', 'aquaris', 'pisces', 'aries', 'taurus', 'gemini', 'cancer', 'leo', 'virgo', 'libra', 'scorpio', 'sagittarius']
+
+ if month in [1, 3, 4, 5, 6, 7]:
+ next_month_date = 21
+ elif month == 2:
+ next_month_date = 19
+ elif month in [8, 9, 10, 11]:
+ next_month_date = 23
+ else:
+ next_month_date = 22
+
+ if day >= next_month_date and month == 12:
+ month = 1
+ elif day >= next_month_date:
+ return zodiac_signs[month]
+
+ return zodiac_signs[month - 1]
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Йоан обнови решението на 07.03.2015 15:12 (преди над 9 години)

def interpret_chinese_sign(year):
- chinese_type = year % 12
+ chinese_type = year % 12
- chinese_signs = ('rat', 'ox', 'tiger', 'rabbit', 'dragon', 'snake', 'horse', 'sheep', 'monkey', 'rooster', 'dog', 'pig')
+ chinese_signs = ('rat', 'ox', 'tiger', 'rabbit', 'dragon', 'snake', 'horse', 'sheep', 'monkey', 'rooster', 'dog', 'pig')
- return chinese_signs[chinese_type - 4]
+ return chinese_signs[chinese_type - 4]
def interpret_western_sign(day, month):
- zodiac_signs = ['capricorn', 'aquaris', 'pisces', 'aries', 'taurus', 'gemini', 'cancer', 'leo', 'virgo', 'libra', 'scorpio', 'sagittarius']
+ zodiac_signs = ['capricorn', 'aquaris', 'pisces', 'aries', 'taurus', 'gemini', 'cancer', 'leo', 'virgo', 'libra', 'scorpio', 'sagittarius']
- if month in [1, 3, 4, 5, 6, 7]:
- next_month_date = 21
- elif month == 2:
- next_month_date = 19
- elif month in [8, 9, 10, 11]:
- next_month_date = 23
- else:
- next_month_date = 22
+ if month in [1, 3, 4, 5, 6, 7]:
+ next_month_date = 21
+ elif month == 2:
+ next_month_date = 19
+ elif month in [8, 9, 10, 11]:
+ next_month_date = 23
+ else:
+ next_month_date = 22
- if day >= next_month_date and month == 12:
- month = 1
- elif day >= next_month_date:
- return zodiac_signs[month]
+ if day >= next_month_date and month == 12:
+ month = 1
+ elif day >= next_month_date:
+ return zodiac_signs[month]
- return zodiac_signs[month - 1]
+ return zodiac_signs[month - 1]
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))

Йоан обнови решението на 07.03.2015 19:55 (преди над 9 години)

def interpret_chinese_sign(year):
chinese_type = year % 12
chinese_signs = ('rat', 'ox', 'tiger', 'rabbit', 'dragon', 'snake', 'horse', 'sheep', 'monkey', 'rooster', 'dog', 'pig')
return chinese_signs[chinese_type - 4]
def interpret_western_sign(day, month):
zodiac_signs = ['capricorn', 'aquaris', 'pisces', 'aries', 'taurus', 'gemini', 'cancer', 'leo', 'virgo', 'libra', 'scorpio', 'sagittarius']
if month in [1, 3, 4, 5, 6, 7]:
next_month_date = 21
elif month == 2:
next_month_date = 19
- elif month in [8, 9, 10, 11]:
+ elif month in [8, 9, 10]:
next_month_date = 23
else:
next_month_date = 22
if day >= next_month_date and month == 12:
month = 1
elif day >= next_month_date:
return zodiac_signs[month]
return zodiac_signs[month - 1]
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Йоан обнови решението на 07.03.2015 19:56 (преди над 9 години)

def interpret_chinese_sign(year):
chinese_type = year % 12
chinese_signs = ('rat', 'ox', 'tiger', 'rabbit', 'dragon', 'snake', 'horse', 'sheep', 'monkey', 'rooster', 'dog', 'pig')
return chinese_signs[chinese_type - 4]
def interpret_western_sign(day, month):
zodiac_signs = ['capricorn', 'aquaris', 'pisces', 'aries', 'taurus', 'gemini', 'cancer', 'leo', 'virgo', 'libra', 'scorpio', 'sagittarius']
- if month in [1, 3, 4, 5, 6, 7]:
+ if month in [1, 3, 4, 5, 6]:
next_month_date = 21
elif month == 2:
next_month_date = 19
- elif month in [8, 9, 10]:
+ elif month in [7, 8, 9, 10]:
next_month_date = 23
else:
next_month_date = 22
if day >= next_month_date and month == 12:
month = 1
elif day >= next_month_date:
return zodiac_signs[month]
return zodiac_signs[month - 1]
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Йоан обнови решението на 09.03.2015 23:20 (преди над 9 години)

def interpret_chinese_sign(year):
chinese_type = year % 12
- chinese_signs = ('rat', 'ox', 'tiger', 'rabbit', 'dragon', 'snake', 'horse', 'sheep', 'monkey', 'rooster', 'dog', 'pig')
+ chinese_signs = [
+ 'rat', 'ox', 'tiger', 'rabbit',
+ 'dragon', 'snake', 'horse', 'sheep',
+ 'monkey', 'rooster', 'dog', 'pig'
+ ]
return chinese_signs[chinese_type - 4]
+
def interpret_western_sign(day, month):
- zodiac_signs = ['capricorn', 'aquaris', 'pisces', 'aries', 'taurus', 'gemini', 'cancer', 'leo', 'virgo', 'libra', 'scorpio', 'sagittarius']
- if month in [1, 3, 4, 5, 6]:
- next_month_date = 21
- elif month == 2:
- next_month_date = 19
- elif month in [7, 8, 9, 10]:
- next_month_date = 23
- else:
- next_month_date = 22
+ months = [
+ {'current': 'capricorn', 'next': 'aquarius', 'date': 21},
+ {'current': 'aquarius', 'next': 'pisces', 'date': 19},
+ {'current': 'pisces', 'next': 'aries', 'date': 21},
+ {'current': 'aries', 'next': 'taurus', 'date': 21},
+ {'current': 'taurus', 'next': 'gemini', 'date': 21},
+ {'current': 'gemini', 'next': 'cancer', 'date': 21},
+ {'current': 'cancer', 'next': 'leo', 'date': 21},
+ {'current': 'leo', 'next': 'virgo', 'date': 23},
+ {'current': 'virgo', 'next': 'libra', 'date': 23},
+ {'current': 'libra', 'next': 'scorpio', 'date': 23},
+ {'current': 'scorpio', 'next': 'sagittarius', 'date': 22},
+ {'current': 'sagittarius', 'next': 'capricorn', 'date': 22}
+ ]
- if day >= next_month_date and month == 12:
- month = 1
- elif day >= next_month_date:
- return zodiac_signs[month]
+ current_month = months[month - 1]
- return zodiac_signs[month - 1]
+ if day >= current_month['date']:
+ return current_month['next']
+
+ return current_month['current']
+
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Йоан обнови решението на 09.03.2015 23:39 (преди над 9 години)

def interpret_chinese_sign(year):
chinese_type = year % 12
chinese_signs = [
'rat', 'ox', 'tiger', 'rabbit',
'dragon', 'snake', 'horse', 'sheep',
'monkey', 'rooster', 'dog', 'pig'
]
return chinese_signs[chinese_type - 4]
def interpret_western_sign(day, month):
months = [
{'current': 'capricorn', 'next': 'aquarius', 'date': 21},
{'current': 'aquarius', 'next': 'pisces', 'date': 19},
{'current': 'pisces', 'next': 'aries', 'date': 21},
{'current': 'aries', 'next': 'taurus', 'date': 21},
{'current': 'taurus', 'next': 'gemini', 'date': 21},
{'current': 'gemini', 'next': 'cancer', 'date': 21},
- {'current': 'cancer', 'next': 'leo', 'date': 21},
+ {'current': 'cancer', 'next': 'leo', 'date': 23},
{'current': 'leo', 'next': 'virgo', 'date': 23},
{'current': 'virgo', 'next': 'libra', 'date': 23},
{'current': 'libra', 'next': 'scorpio', 'date': 23},
{'current': 'scorpio', 'next': 'sagittarius', 'date': 22},
{'current': 'sagittarius', 'next': 'capricorn', 'date': 22}
]
current_month = months[month - 1]
if day >= current_month['date']:
return current_month['next']
return current_month['current']
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))