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

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

Към профила на Светлин Славов

Резултати

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

Код

months = {1: 20, 2: 19, 3: 20, 4: 20, 5: 20, 6: 20, 7: 22,
8: 22, 9: 22, 10: 22, 11: 21, 12: 21}
signs = {1: ['capricorn', 'aquarius'], 2: ['aquarius', 'pisces'],
3: ['pisces', 'aries'], 4: ['aries', 'taurus'], 5: ['taurus', 'gemini'],
6: ['gemini', 'cancer'], 7: ['cancer', 'leo'], 8: ['leo', 'virgo'],
9: ['virgo', 'libra'], 10: ['libra', 'scorpio'],
11: ['scorpio', 'saggitarius'], 12: ['saggitarius', 'capricorn']}
animals = {4: 'rat', 5: 'ox', 6: 'tiger', 7: 'rabbit',
8: 'dragon', 9: 'snake', 10: 'horse', 11: 'sheep',
0: 'monkey', 1: 'rooster', 2: 'dog', 3: 'pig'}
def interpret_western_sign(day, month):
if day < months[month]:
return signs[month][0]
else:
return signs[month][1]
def interpret_chinese_sign(year):
return animals[year%12]
def interpret_both_signs(day, month, year):
western = interpret_western_sign(day, month)
chinese = interpret_chinese_sign(year)
return (western, chinese)

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

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

OK

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

Светлин обнови решението на 05.03.2015 13:08 (преди над 9 години)

+def interpret_western_sign(day, month):
+ months = {1:20, 2:19, 3:20, 4:20, 5:20,
+ 6:20, 7:22, 8:22, 9:22, 10:22, 11:21, 12:21}
+
+ signs = {1:['capricorn', 'aquarius'], 2:['aquarius', 'pisces'],
+ 3:['pisces', 'aries'], 4:['aries', 'taurus'], 5:['taurus', 'gemini'],
+ 6:['gemini', 'cancer'], 7:['cancer', 'leo'], 8:['leo', 'virgo'],
+ 9:['virgo', 'libra'], 10:['libra', 'scorpio'],
+ 11:['scorpio', 'saggitarius'], 12:['saggitarius', 'capricorn']}
+
+ if day < months[month]:
+ return signs[month][0]
+ else:
+ return signs[month][1]
+
+
+def interpret_chinese_sign(year):
+ animals={4:'rat', 5:'ox', 6:'tiger', 7:'rabbit',
+ 8:'dragon', 9:'snake', 10:'horse', 11:'sheep',
+ 0:'monkey', 1:'rooster', 2:'dog', 3:'pig'}
+
+ return animals[year%12]
+
+
+def interpret_both_signs(day, month, year):
+ western = interpret_western_sign(day, month)
+ chinese = interpret_chinese_sign(year)
+
+ return (western, chinese)

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

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