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

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

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

Резултати

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

Код

def interpret_western_sign(day, month):
dicts = {'aries': (3, 21, 4, 20),
'taurus': (4, 21, 5, 20),
'gemini': (5, 21, 6, 20),
'cancer': (6, 21, 7, 22),
'leo': (7, 23, 8, 22),
'virgo': (8, 23, 9, 22),
'libra': (9, 23, 10, 22),
'scorpio': (10, 23, 11, 21),
'sagittarius': (11, 22, 12, 21),
'capricorn': (12, 22, 1, 20),
'aquarius': (1, 21, 2, 18),
'pisces': (2, 19, 3, 20)}
for sign, date in dicts.items():
if (date[0] == month and date[1] <= day or
date[2] == month and date[3] >= day):
return sign
def interpret_chinese_sign(year):
dictc = {'rat': 1900, 'ox': 1901, 'tiger': 1902, 'rabbit': 1903,
'dragon': 1904, 'snake': 1905, 'horse': 1906, 'sheep': 1907,
'monkey': 1908, 'rooster': 1909, 'dog': 1910, 'pig': 1911}
for sign, date in dictc.items():
if year > 1900:
if date == year - (((year-1900)//12)*12):
return sign
else:
if date == year + ((abs(year-1911)//12)*12):
return sign
def interpret_both_signs(day, month, year):
tpl = (interpret_western_sign(day, month), interpret_chinese_sign(year))
return tpl

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

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

OK

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

Светлин обнови решението на 08.03.2015 12:09 (преди над 9 години)

+def interpret_western_sign(day, month):
+ dicts = {'aries': (3, 21, 4, 20),
+ 'taurus': (4, 21, 5, 20),
+ 'gemini': (5, 21, 6, 20),
+ 'cancer': (6, 21, 7, 22),
+ 'leo': (7, 23, 8, 22),
+ 'virgo': (8, 23, 9, 22),
+ 'libra': (9, 23, 10, 22),
+ 'scorpio': (10, 23, 11, 21),
+ 'sagittarius': (11, 22, 12, 21),
+ 'capricorn': (12, 22, 1, 20),
+ 'aquarius': (1, 21, 2, 18),
+ 'pisces': (2, 19, 3, 20)}
+ for sign, date in dicts.items():
+ if date[0] == month and date[1] <= day or date[2] == month and date[3] >= day:
+ return sign
+
+def interpret_chinese_sign(year):
+ dictc = {'rat': 1900, 'ox': 1901, 'tiger': 1902, 'rabbit':1903,
+ 'dragon': 1904, 'snake': 1905, 'horse': 1906, 'sheep': 1907,
+ 'monkey': 1908, 'rooster': 1909, 'dog': 1910, 'pig': 1911}
+ for sign, date in dictc.items():
+ if year > 1900:
+ if date == year - (((year-1900)//12)*12):
+ return sign
+ else:
+ if date == year + ((abs(year-1911)//12)*12):
+ return sign
+
+def interpret_both_signs(day, month, year):
+ a_tuple = (interpret_western_sign(day, month), interpret_chinese_sign(year))
+ return a_tuple

Светлин обнови решението на 10.03.2015 15:38 (преди над 9 години)

def interpret_western_sign(day, month):
- dicts = {'aries': (3, 21, 4, 20),
- 'taurus': (4, 21, 5, 20),
- 'gemini': (5, 21, 6, 20),
- 'cancer': (6, 21, 7, 22),
- 'leo': (7, 23, 8, 22),
- 'virgo': (8, 23, 9, 22),
- 'libra': (9, 23, 10, 22),
- 'scorpio': (10, 23, 11, 21),
- 'sagittarius': (11, 22, 12, 21),
- 'capricorn': (12, 22, 1, 20),
- 'aquarius': (1, 21, 2, 18),
- 'pisces': (2, 19, 3, 20)}
+ dicts = {'aries': (3, 21, 4, 20),
+ 'taurus': (4, 21, 5, 20),
+ 'gemini': (5, 21, 6, 20),
+ 'cancer': (6, 21, 7, 22),
+ 'leo': (7, 23, 8, 22),
+ 'virgo': (8, 23, 9, 22),
+ 'libra': (9, 23, 10, 22),
+ 'scorpio': (10, 23, 11, 21),
+ 'sagittarius': (11, 22, 12, 21),
+ 'capricorn': (12, 22, 1, 20),
+ 'aquarius': (1, 21, 2, 18),
+ 'pisces': (2, 19, 3, 20)}
for sign, date in dicts.items():
- if date[0] == month and date[1] <= day or date[2] == month and date[3] >= day:
+ if (date[0] == month and date[1] <= day or
+ date[2] == month and date[3] >= day):
return sign
+
def interpret_chinese_sign(year):
- dictc = {'rat': 1900, 'ox': 1901, 'tiger': 1902, 'rabbit':1903,
+ dictc = {'rat': 1900, 'ox': 1901, 'tiger': 1902, 'rabbit': 1903,
'dragon': 1904, 'snake': 1905, 'horse': 1906, 'sheep': 1907,
'monkey': 1908, 'rooster': 1909, 'dog': 1910, 'pig': 1911}
for sign, date in dictc.items():
if year > 1900:
if date == year - (((year-1900)//12)*12):
return sign
else:
if date == year + ((abs(year-1911)//12)*12):
return sign
+
def interpret_both_signs(day, month, year):
- a_tuple = (interpret_western_sign(day, month), interpret_chinese_sign(year))
- return a_tuple
+ tpl = (interpret_western_sign(day, month), interpret_chinese_sign(year))
+ return tpl