Решение на Хороскоп от Мартина Величкова

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

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

Резултати

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

Код

def what_is_my_sign(day, month):
signs = {(3, 21, 4, 20): 'Овен',
(4, 21, 5, 20): 'Телец',
(5, 21, 6, 20): 'Близнаци',
(6, 21, 7, 21): 'Рак',
(7, 22, 8, 22): 'Лъв',
(8, 23, 9, 22): 'Дева',
(9, 23, 10, 22): 'Везни',
(10, 23, 11, 21): 'Скорпион',
(11, 22, 12, 21): 'Стрелец',
(12, 22, 1, 19): 'Козирог',
(1, 20, 2, 18): 'Водолей',
(2, 19, 3, 20): 'Риби'}
for key in signs:
if (month == key[0] and day >= key[1]) or (month == key[2] and day <= key[3]):
return signs[key]

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

...............
----------------------------------------------------------------------
Ran 15 tests in 0.001s

OK

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

Мартина обнови решението на 04.03.2013 01:10 (преди над 11 години)

+def what_is_my_sign(day, month):
+ if (month == 3 and day >= 21) or (month == 4 and day <= 20):
+ return 'Овен'
+ elif (month == 4 and day >= 21) or (month == 5 and day <= 20):
+ return 'Телец'
+ elif (month == 5 and day >= 21) or (month == 6 and day <= 20):
+ return 'Близнаци'
+ elif (month == 6 and day >= 21) or (month == 7 and day <= 21):
+ return 'Рак'
+ elif (month == 7 and day >= 22) or (month == 8 and day <= 22):
+ return 'Лъв'
+ elif (month == 8 and day >= 23) or (month == 9 and day <= 22):
+ return 'Дева'
+ elif (month == 9 and day >= 23) or (month == 10 and day <= 22):
+ return 'Везни'
+ elif (month == 10 and day >= 23) or (month == 11 and day <= 21):
+ return 'Скорпион'
+ elif (month == 11 and day >= 22) or (month == 12 and day <= 21):
+ return 'Стрелец'
+ elif (month == 12 and day >= 22) or (month == 1 and day <= 19):
+ return 'Козирог'
+ elif (month == 1 and day >= 20) or (month == 2 and day <= 18):
+ return 'Водолей'
+ elif (month == 2 and day >= 19) or (month == 3 and day <= 20):
+ return 'Риби'
+

Мартина обнови решението на 04.03.2013 13:21 (преди над 11 години)

def what_is_my_sign(day, month):
- if (month == 3 and day >= 21) or (month == 4 and day <= 20):
- return 'Овен'
+ signs = {(3, 21, 4, 20): 'Овен',
- elif (month == 4 and day >= 21) or (month == 5 and day <= 20):
+ (4, 21, 5, 20): 'Телец',
- return 'Телец'
+ (5, 21, 6, 20): 'Близнаци',
- elif (month == 5 and day >= 21) or (month == 6 and day <= 20):
+ (6, 21, 7, 21): 'Рак',
- return 'Близнаци'
+ (7, 22, 8, 22): 'Лъв',
- elif (month == 6 and day >= 21) or (month == 7 and day <= 21):
+ (8, 23, 9, 22): 'Дева',
- return 'Рак'
+ (9, 23, 10, 22): 'Везни',
- elif (month == 7 and day >= 22) or (month == 8 and day <= 22):
+ (10, 23, 11, 21): 'Скорпион',
- return 'Лъв'
+ (11, 22, 12, 21): 'Стрелец',
- elif (month == 8 and day >= 23) or (month == 9 and day <= 22):
+ (12, 22, 1, 19): 'Козирог',
- return 'Дева'
+ (1, 20, 2, 18): 'Водолей',
- elif (month == 9 and day >= 23) or (month == 10 and day <= 22):
+ (2, 19, 3, 20): 'Риби'}
- return 'Везни'
+ for key in signs:
- elif (month == 10 and day >= 23) or (month == 11 and day <= 21):
+ if (month == key[0] and day >= key[1]) or (month == key[2] and day <= key[3]):
- return 'Скорпион'
+ return signs[key]
- elif (month == 11 and day >= 22) or (month == 12 and day <= 21):
- return 'Стрелец'
- elif (month == 12 and day >= 22) or (month == 1 and day <= 19):
- return 'Козирог'
- elif (month == 1 and day >= 20) or (month == 2 and day <= 18):
- return 'Водолей'
- elif (month == 2 and day >= 19) or (month == 3 and day <= 20):
- return 'Риби'
-