Решение на Астрологични забави от Любослава Димитрова

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

Към профила на Любослава Димитрова

Резултати

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

Код

def interpret_western_sign(day, month):
months = {
1: (range(1, 21), "capricorn", "aquarius"),
2: (range(1, 19), "aquarius", "pisces"),
3: (range(1, 21), "pisces", "aries"),
4: (range(1, 21), "aries", "taurus"),
5: (range(1, 21), "taurus", "gemini"),
6: (range(1, 21), "gemini", "cancer"),
7: (range(1, 23), "cancer", "leo"),
8: (range(1, 23), "leo", "virgo"),
9: (range(1, 23), "virgo", "libra"),
10: (range(1, 23), "libra", "scorpio"),
11: (range(1, 22), "scorpio", "sagittarius"),
12: (range(1, 22), "sagittarius", "capricorn")
}
if day in months[month][0]:
return months[month][1]
else:
return months[month][2]
def interpret_chinese_sign(year):
chinese = [(1900, "rat"), (1901, "ox"), (1902, "tiger"), (1903, "rabbit"),
(1904, "dragon"), (1905, "snake"), (1906, "horse"),
(1907, "sheep"), (1908, "monkey"), (1909, "rooster"),
(1910, "dog"), (1911, "pig")]
index = (year - chinese[0][0]) % 12
return chinese[index][1]
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

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

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

OK

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

Любослава обнови решението на 08.03.2015 14:55 (преди над 9 години)

+def interpret_western_sign(day, month):
+ months = {
+ 1: [range(1, 21), "capricorn", "aquarius"],
+ 2: [range(1, 19), "aquarius", "pisces"],
+ 3: [range(1, 21), "pisces", "aries"],
+ 4: [range(1, 21), "aries", "taurus"],
+ 5: [range(1, 21), "taurus", "gemini"],
+ 6: [range(1, 21), "gemini", "cancer"],
+ 7: [range(1, 23), "cancer", "leo"],
+ 8: [range(1, 23), "leo", "virgo"],
+ 9: [range(1, 23), "virgo", "libra"],
+ 10: [range(1, 23), "libra", "scorpio"],
+ 11: [range(1, 22), "scorpio", "sagittarius"],
+ 12: [range(1, 22), "sagittarius", "capricorn"]
+ }
+
+ if day in months[month][0]:
+ return months[month][1]
+ else:
+ return months[month][2]
+
+
+def interpret_chinese_sign(year):
+ chinese = [(1900, "rat"), (1901, "ox"), (1902, "tiger"), (1903, "rabbit"),
+ (1904, "dragon"), (1905, "snake"), (1906, "horse"),
+ (1907, "sheep"), (1908, "monkey"), (1909, "rooster"),
+ (1910, "dog"), (1911, "pig")]
+ index = (year - chinese[0][0]) % 12
+ return chinese[index][1]
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Любослава обнови решението на 08.03.2015 18:21 (преди над 9 години)

def interpret_western_sign(day, month):
months = {
- 1: [range(1, 21), "capricorn", "aquarius"],
- 2: [range(1, 19), "aquarius", "pisces"],
- 3: [range(1, 21), "pisces", "aries"],
- 4: [range(1, 21), "aries", "taurus"],
- 5: [range(1, 21), "taurus", "gemini"],
- 6: [range(1, 21), "gemini", "cancer"],
- 7: [range(1, 23), "cancer", "leo"],
- 8: [range(1, 23), "leo", "virgo"],
- 9: [range(1, 23), "virgo", "libra"],
- 10: [range(1, 23), "libra", "scorpio"],
- 11: [range(1, 22), "scorpio", "sagittarius"],
- 12: [range(1, 22), "sagittarius", "capricorn"]
+ 1: [range(1, 21), "capricorn", "aquarius"],
+ 2: [range(1, 19), "aquarius", "pisces"],
+ 3: [range(1, 21), "pisces", "aries"],
+ 4: [range(1, 21), "aries", "taurus"],
+ 5: [range(1, 21), "taurus", "gemini"],
+ 6: [range(1, 21), "gemini", "cancer"],
+ 7: [range(1, 23), "cancer", "leo"],
+ 8: [range(1, 23), "leo", "virgo"],
+ 9: [range(1, 23), "virgo", "libra"],
+ 10: [range(1, 23), "libra", "scorpio"],
+ 11: [range(1, 22), "scorpio", "sagittarius"],
+ 12: [range(1, 22), "sagittarius", "capricorn"]
}
if day in months[month][0]:
return months[month][1]
else:
return months[month][2]
def interpret_chinese_sign(year):
chinese = [(1900, "rat"), (1901, "ox"), (1902, "tiger"), (1903, "rabbit"),
(1904, "dragon"), (1905, "snake"), (1906, "horse"),
(1907, "sheep"), (1908, "monkey"), (1909, "rooster"),
(1910, "dog"), (1911, "pig")]
index = (year - chinese[0][0]) % 12
return chinese[index][1]
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Добре. Но не разбира защо използваш списъци.

[range(1, 21), "capricorn", "aquarius"]

със същия успех може да е

(range(1, 21), "capricorn", "aquarius")

Не се заяждам. Просто не се сещам по какъв друг начин да ти помгна да го подобриш :)

Любослава обнови решението на 09.03.2015 00:11 (преди над 9 години)

def interpret_western_sign(day, month):
months = {
- 1: [range(1, 21), "capricorn", "aquarius"],
- 2: [range(1, 19), "aquarius", "pisces"],
- 3: [range(1, 21), "pisces", "aries"],
- 4: [range(1, 21), "aries", "taurus"],
- 5: [range(1, 21), "taurus", "gemini"],
- 6: [range(1, 21), "gemini", "cancer"],
- 7: [range(1, 23), "cancer", "leo"],
- 8: [range(1, 23), "leo", "virgo"],
- 9: [range(1, 23), "virgo", "libra"],
- 10: [range(1, 23), "libra", "scorpio"],
- 11: [range(1, 22), "scorpio", "sagittarius"],
- 12: [range(1, 22), "sagittarius", "capricorn"]
+ 1: (range(1, 21), "capricorn", "aquarius"),
+ 2: (range(1, 19), "aquarius", "pisces"),
+ 3: (range(1, 21), "pisces", "aries"),
+ 4: (range(1, 21), "aries", "taurus"),
+ 5: (range(1, 21), "taurus", "gemini"),
+ 6: (range(1, 21), "gemini", "cancer"),
+ 7: (range(1, 23), "cancer", "leo"),
+ 8: (range(1, 23), "leo", "virgo"),
+ 9: (range(1, 23), "virgo", "libra"),
+ 10: (range(1, 23), "libra", "scorpio"),
+ 11: (range(1, 22), "scorpio", "sagittarius"),
+ 12: (range(1, 22), "sagittarius", "capricorn")
}
if day in months[month][0]:
return months[month][1]
else:
return months[month][2]
def interpret_chinese_sign(year):
chinese = [(1900, "rat"), (1901, "ox"), (1902, "tiger"), (1903, "rabbit"),
(1904, "dragon"), (1905, "snake"), (1906, "horse"),
(1907, "sheep"), (1908, "monkey"), (1909, "rooster"),
(1910, "dog"), (1911, "pig")]
index = (year - chinese[0][0]) % 12
return chinese[index][1]
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Любослава обнови решението на 10.03.2015 19:14 (преди над 9 години)

def interpret_western_sign(day, month):
months = {
1: (range(1, 21), "capricorn", "aquarius"),
2: (range(1, 19), "aquarius", "pisces"),
3: (range(1, 21), "pisces", "aries"),
4: (range(1, 21), "aries", "taurus"),
5: (range(1, 21), "taurus", "gemini"),
6: (range(1, 21), "gemini", "cancer"),
7: (range(1, 23), "cancer", "leo"),
8: (range(1, 23), "leo", "virgo"),
9: (range(1, 23), "virgo", "libra"),
10: (range(1, 23), "libra", "scorpio"),
11: (range(1, 22), "scorpio", "sagittarius"),
12: (range(1, 22), "sagittarius", "capricorn")
}
if day in months[month][0]:
return months[month][1]
else:
return months[month][2]
def interpret_chinese_sign(year):
chinese = [(1900, "rat"), (1901, "ox"), (1902, "tiger"), (1903, "rabbit"),
(1904, "dragon"), (1905, "snake"), (1906, "horse"),
(1907, "sheep"), (1908, "monkey"), (1909, "rooster"),
(1910, "dog"), (1911, "pig")]
index = (year - chinese[0][0]) % 12
return chinese[index][1]
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))