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

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

Към профила на Йордан Канчелов

Резултати

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

Код

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

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

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

+def interpret_western_sign(day, month):
+ if month == 1:
+ if day < 21:
+ return 'capricorn'
+ else:
+ return 'aquarius'
+
+ if month == 2:
+ if day < 20:
+ return 'aquarius'
+ else:
+ return 'pisces'
+
+ if month == 3:
+ if day < 20:
+ return 'pisces'
+ else:
+ return 'aries'
+
+ if month == 4:
+ if day < 21:
+ return 'aries'
+ else:
+ return 'taurus'
+
+ if month == 5:
+ if day < 21:
+ return 'taurus'
+ else:
+ return 'gemini'
+
+ if month == 6:
+ if day < 21:
+ return 'gemini'
+ else:
+ return 'cancer'
+
+ if month == 7:
+ if day < 23:
+ return 'cancer'
+ else:
+ return 'leo'
+
+ if month == 8:
+ if day < 23:
+ return 'leo'
+ else:
+ return 'virgo'
+
+ if month == 9:
+ if day < 23:
+ return 'virgo'
+ else:
+ return 'libra'
+
+ if month == 10:
+ if day < 23:
+ return 'libra'
+ else:
+ return 'scorpio'
+
+ if month == 11:
+ if day < 22:
+ return 'scorpio'
+ else:
+ return 'sagittarius'
+
+ if month == 12:
+ if day < 22:
+ return 'sagittarius'
+ else:
+ return 'capricorn'
+
+
+def interpret_chinese_sign(year):
+ counter = 0
+ initialYear = 1900
+
+ while year != initialYear:
+ if year > initialYear:
+ initialYear += 12
+
+ if initialYear == year:
+ break
+ elif initialYear > year:
+ counter += 1
+ initialYear = 1900 + counter
+
+ elif year < initialYear:
+ initialYear -= 12
+
+ if initialYear == year:
+ break
+ elif initialYear < year:
+ counter += 1
+ initialYear = 1900 + counter
+
+ if counter == 0:
+ return "rat"
+ elif counter == 1:
+ return "ox"
+ elif counter == 2:
+ return "tiger"
+ elif counter == 3:
+ return "rabit"
+ elif counter == 4:
+ return "dragon"
+ elif counter == 5:
+ return "snake"
+ elif counter == 6:
+ return "horse"
+ elif counter == 7:
+ return "sheep"
+ elif counter == 8:
+ return "monkey"
+ elif counter == 9:
+ return "rooster"
+ elif counter == 10:
+ return "dog"
+ elif counter == 11:
+ return "pig"
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))
+
+print(interpret_both_signs(14, 4, 1900))

Йордан обнови решението на 10.03.2015 04:05 (преди над 9 години)

def interpret_western_sign(day, month):
if month == 1:
if day < 21:
return 'capricorn'
else:
return 'aquarius'
if month == 2:
if day < 20:
return 'aquarius'
else:
return 'pisces'
if month == 3:
if day < 20:
return 'pisces'
else:
return 'aries'
if month == 4:
if day < 21:
return 'aries'
else:
return 'taurus'
if month == 5:
if day < 21:
return 'taurus'
else:
return 'gemini'
if month == 6:
if day < 21:
return 'gemini'
else:
return 'cancer'
if month == 7:
if day < 23:
return 'cancer'
else:
return 'leo'
if month == 8:
if day < 23:
return 'leo'
else:
return 'virgo'
if month == 9:
if day < 23:
return 'virgo'
else:
return 'libra'
if month == 10:
if day < 23:
return 'libra'
else:
return 'scorpio'
if month == 11:
if day < 22:
return 'scorpio'
else:
return 'sagittarius'
if month == 12:
if day < 22:
return 'sagittarius'
else:
return 'capricorn'
def interpret_chinese_sign(year):
- counter = 0
- initialYear = 1900
+ sign = {
+ 0: 'monkey',
+ 1: 'rooster',
+ 2: 'dog',
+ 3: 'pig',
+ 4: 'rat',
+ 5: 'ox',
+ 6: 'tiger',
+ 7: 'rabbit',
+ 8: 'dragon',
+ 9: 'snake',
+ 10: 'horse',
+ 11: 'sheep'}
+ return sign[year % 12]
- while year != initialYear:
- if year > initialYear:
- initialYear += 12
- if initialYear == year:
- break
- elif initialYear > year:
- counter += 1
- initialYear = 1900 + counter
-
- elif year < initialYear:
- initialYear -= 12
-
- if initialYear == year:
- break
- elif initialYear < year:
- counter += 1
- initialYear = 1900 + counter
-
- if counter == 0:
- return "rat"
- elif counter == 1:
- return "ox"
- elif counter == 2:
- return "tiger"
- elif counter == 3:
- return "rabit"
- elif counter == 4:
- return "dragon"
- elif counter == 5:
- return "snake"
- elif counter == 6:
- return "horse"
- elif counter == 7:
- return "sheep"
- elif counter == 8:
- return "monkey"
- elif counter == 9:
- return "rooster"
- elif counter == 10:
- return "dog"
- elif counter == 11:
- return "pig"
-
-
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))
-
-print(interpret_both_signs(14, 4, 1900))