Решение на Астрологични забави от Людмил Делчев

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

Към профила на Людмил Делчев

Резултати

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

Код

WESTERN_SIGNS = [
'aquarius', 'pisces', 'aries', 'taurus', 'gemini', 'cancer',
'leo', 'virgo', 'libra', 'scorpio', 'sagittarius', 'capricorn'
]
WESTERN_SIGNS_RANGES_FLOORS = {
(1, 20), (2, 18), (3, 20), (4, 20), (5, 20), (6, 20),
(7, 22), (8, 22), (9, 22), (10, 22), (11, 21), (12, 21)
}
CHINESE_SIGNS = [
'monkey', 'rooster', 'dog', 'pig', 'rat', 'ox',
'tiger', 'rabbit', 'dragon', 'snake', 'horse', 'sheep'
]
def interpret_western_sign(day, month):
for sign_range_floor in WESTERN_SIGNS_RANGES_FLOORS:
if month == sign_range_floor[0]:
if day <= sign_range_floor[1]:
return WESTERN_SIGNS[sign_range_floor[0] - 2]
return WESTERN_SIGNS[sign_range_floor[0] - 1]
def interpret_chinese_sign(year):
return CHINESE_SIGNS[year % 12]
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 версии и 3 коментара)

Людмил обнови решението на 10.03.2015 23:02 (преди над 9 години)

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

Людмил обнови решението на 11.03.2015 15:01 (преди над 9 години)

western_signs = [
- 'aries', 'taurus', 'gemini', 'cancer', 'leo', 'virgo', 'libra',
- 'scorpio', 'sagittarius', 'capricorn', 'aquarius', 'pisces'
+ 'aquarius', 'pisces', 'aries', 'taurus', 'gemini', 'cancer',
+ 'leo', 'virgo', 'libra', 'scorpio', 'sagittarius', 'capricorn'
]
+western_signs_ranges_floors = {
+ (1, 20), (2, 18), (3, 20), (4, 20), (5, 20), (6, 20),
+ (7, 22), (8, 22), (9, 22), (10, 22), (11, 21), (12, 21)
+}
chinese_signs = [
- 'monkey', 'rooster', 'dog', 'pig', 'rat', 'ox', 'tiger', 'rabbit',
- 'dragon', 'snake', 'horse', 'sheep'
+ 'monkey', 'rooster', 'dog', 'pig', 'rat', 'ox',
+ 'tiger', 'rabbit', 'dragon', 'snake', 'horse', 'sheep'
]
def interpret_western_sign(day, month):
- if month == 1:
- if day < 21:
- return western_signs[9]
- return western_signs[10]
- if month == 2:
- if day < 19:
- return western_signs[10]
- return western_signs[11]
- if month == 3:
- if day < 21:
- return western_signs[11]
- return western_signs[0]
- if month == 4:
- if day < 21:
- return western_signs[0]
- return western_signs[1]
- if month == 5:
- if day < 21:
- return western_signs[1]
- return western_signs[2]
- if month == 6:
- if day < 21:
- return western_signs[2]
- return western_signs[3]
- if month == 7:
- if day < 23:
- return western_signs[3]
- return western_signs[4]
- if month == 8:
- if day < 23:
- return western_signs[4]
- return western_signs[5]
- if month == 9:
- if day < 23:
- return western_signs[5]
- return western_signs[6]
- if month == 10:
- if day < 23:
- return western_signs[6]
- return western_signs[7]
- if month == 11:
- if day < 22:
- return western_signs[7]
- return western_signs[8]
- if month == 12:
- if day < 22:
- return western_signs[8]
- return western_signs[9]
+ for sign_range_floor in western_signs_ranges_floors:
+ if month == sign_range_floor[0]:
+ if day <= sign_range_floor[1]:
+ return western_signs[sign_range_floor[0] - 2]
+ return western_signs[sign_range_floor[0] - 1]
def interpret_chinese_sign(year):
- return chinese_signs[abs(year % 12)]
+ return chinese_signs[year % 12]
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)

Людмил обнови решението на 11.03.2015 16:27 (преди над 9 години)

-western_signs = [
+WESTERN_SIGNS = [
'aquarius', 'pisces', 'aries', 'taurus', 'gemini', 'cancer',
'leo', 'virgo', 'libra', 'scorpio', 'sagittarius', 'capricorn'
]
-western_signs_ranges_floors = {
+WESTERN_SIGNS_RANGES_FLOORS = {
(1, 20), (2, 18), (3, 20), (4, 20), (5, 20), (6, 20),
(7, 22), (8, 22), (9, 22), (10, 22), (11, 21), (12, 21)
}
-chinese_signs = [
+CHINESE_SIGNS = [
'monkey', 'rooster', 'dog', 'pig', 'rat', 'ox',
'tiger', 'rabbit', 'dragon', 'snake', 'horse', 'sheep'
]
def interpret_western_sign(day, month):
- for sign_range_floor in western_signs_ranges_floors:
+ for sign_range_floor in WESTERN_SIGNS_RANGES_FLOORS:
if month == sign_range_floor[0]:
if day <= sign_range_floor[1]:
- return western_signs[sign_range_floor[0] - 2]
- return western_signs[sign_range_floor[0] - 1]
+ return WESTERN_SIGNS[sign_range_floor[0] - 2]
+ return WESTERN_SIGNS[sign_range_floor[0] - 1]
def interpret_chinese_sign(year):
- return chinese_signs[year % 12]
+ return CHINESE_SIGNS[year % 12]
def interpret_both_signs(day, month, year):
return interpret_western_sign(day, month), interpret_chinese_sign(year)