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

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

Към профила на Никола Монов

Резултати

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

Код

SIGNS = [
"capricorn",
"aquarius",
"pisces",
"aries",
"taurus",
"gemini",
"cancer",
"leo",
"virgo",
"libra",
"scorpio",
"sagittarius"
]
END_DAYS = [20, 19, 20, 20, 20, 20, 22, 22, 22, 22, 21, 21]
CHINESE_SIGNS = [
"rat",
"ox",
"tiger",
"rabbit",
"dragon",
"snake",
"horse",
"sheep",
"monkey",
"rooster",
"dog",
"pig"
]
def interpret_western_sign(day, month):
if day <= END_DAYS[month-1]:
return SIGNS[month-1]
else:
if month == 12:
return SIGNS[0]
else:
return SIGNS[month]
def interpret_chinese_sign(year):
if year >= 1900 and year <= 1911:
return CHINESE_SIGNS[year % 100]
elif year < 1900:
while year < 1900:
year += 12
return CHINESE_SIGNS[year % 100]
else:
while year > 1911:
year -= 12
return CHINESE_SIGNS[year % 100]
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 версии и 1 коментар)

Никола обнови решението на 06.03.2015 11:58 (преди около 9 години)

+
+SIGNS = [
+ "capricorn",
+ "aquarius",
+ "pisces",
+ "aries",
+ "taurus",
+ "gemini",
+ "cancer",
+ "leo",
+ "virgo",
+ "libra",
+ "scorpio",
+ "sagittarius"
+]
+
+END_DAYS = [
+ 20, 19, 20, 20, 20, 20, 22, 22, 22, 22, 21, 21
+]
+
+def interpret_western_sign(day, month):
+ if day <= END_DAYS[month-1]:
+ return SIGNS[month-1]
+ else:
+ if month == 12:
+ return SIGNS[0]
+ else:
+ return SIGNS[month]
+
+
+
+CHINESE_SIGNS = [
+ "rat",
+ "ox",
+ "tiger",
+ "rabbit",
+ "dragon",
+ "snake",
+ "horse",
+ "sheep",
+ "monkey",
+ "rooster",
+ "dog",
+ "pig"
+]
+
+def interpret_chinese_sign(year):
+ if year >= 1900 and year <= 1911:
+ return CHINESE_SIGNS[year%100]
+ elif year < 1900:
+ while year < 1900:
+ year += 12
+ return CHINESE_SIGNS[year%100]
+ else: # year > 1911
+ while year > 1911:
+ year -= 12
+ return CHINESE_SIGNS[year%100]
+
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Никола обнови решението на 06.03.2015 16:02 (преди около 9 години)

-
SIGNS = [
- "capricorn",
- "aquarius",
- "pisces",
- "aries",
- "taurus",
- "gemini",
- "cancer",
- "leo",
- "virgo",
- "libra",
- "scorpio",
- "sagittarius"
+ "capricorn",
+ "aquarius",
+ "pisces",
+ "aries",
+ "taurus",
+ "gemini",
+ "cancer",
+ "leo",
+ "virgo",
+ "libra",
+ "scorpio",
+ "sagittarius"
]
-END_DAYS = [
- 20, 19, 20, 20, 20, 20, 22, 22, 22, 22, 21, 21
-]
+END_DAYS = [20, 19, 20, 20, 20, 20, 22, 22, 22, 22, 21, 21]
-def interpret_western_sign(day, month):
- if day <= END_DAYS[month-1]:
- return SIGNS[month-1]
- else:
- if month == 12:
- return SIGNS[0]
- else:
- return SIGNS[month]
-
-
-
CHINESE_SIGNS = [
- "rat",
- "ox",
- "tiger",
- "rabbit",
- "dragon",
- "snake",
- "horse",
- "sheep",
- "monkey",
- "rooster",
- "dog",
- "pig"
+ "rat",
+ "ox",
+ "tiger",
+ "rabbit",
+ "dragon",
+ "snake",
+ "horse",
+ "sheep",
+ "monkey",
+ "rooster",
+ "dog",
+ "pig"
]
-def interpret_chinese_sign(year):
- if year >= 1900 and year <= 1911:
- return CHINESE_SIGNS[year%100]
- elif year < 1900:
- while year < 1900:
- year += 12
- return CHINESE_SIGNS[year%100]
- else: # year > 1911
- while year > 1911:
- year -= 12
- return CHINESE_SIGNS[year%100]
+def interpret_western_sign(day, month):
+ if day <= END_DAYS[month-1]:
+ return SIGNS[month-1]
+ else:
+ if month == 12:
+ return SIGNS[0]
+ else:
+ return SIGNS[month]
+def interpret_chinese_sign(year):
+ if year >= 1900 and year <= 1911:
+ return CHINESE_SIGNS[year%100]
+ elif year < 1900:
+ while year < 1900:
+ year += 12
+ return CHINESE_SIGNS[year%100]
+ else:
+ while year > 1911:
+ year -= 12
+ return CHINESE_SIGNS[year%100]
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))

Никола обнови решението на 09.03.2015 23:11 (преди около 9 години)

SIGNS = [
"capricorn",
"aquarius",
"pisces",
"aries",
"taurus",
"gemini",
"cancer",
"leo",
"virgo",
"libra",
"scorpio",
"sagittarius"
]
END_DAYS = [20, 19, 20, 20, 20, 20, 22, 22, 22, 22, 21, 21]
-CHINESE_SIGNS = [
+CHINESE_SIGNS = [
"rat",
"ox",
"tiger",
"rabbit",
"dragon",
"snake",
"horse",
"sheep",
"monkey",
"rooster",
"dog",
"pig"
]
def interpret_western_sign(day, month):
if day <= END_DAYS[month-1]:
return SIGNS[month-1]
else:
if month == 12:
return SIGNS[0]
else:
return SIGNS[month]
+
def interpret_chinese_sign(year):
if year >= 1900 and year <= 1911:
- return CHINESE_SIGNS[year%100]
+ return CHINESE_SIGNS[year % 100]
elif year < 1900:
while year < 1900:
year += 12
- return CHINESE_SIGNS[year%100]
+ return CHINESE_SIGNS[year % 100]
else:
while year > 1911:
year -= 12
- return CHINESE_SIGNS[year%100]
+ return CHINESE_SIGNS[year % 100]
+
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))