@@ -1,6 +1,7 @@
import json
from datetime import datetime

from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext, TemplateDoesNotExist
from django.template.loader import get_template
@@ -50,13 +51,6 @@ def euler_problem(request, problem_number):

def problem_one(request):
"""
Simple view that expects a request in the format:
http://localhost:8000/difference?number=10 , where 10 is any natural number
Takes the given number and tries to find it in the db.
If the number is not found, the value is calculated and
the corresponding db entry is saved.
"""

number = request.GET.get('number', None)
@@ -79,3 +73,37 @@ def problem_one(request):
'last_requested': str(datetime.now())
}
return HttpResponse(json.dumps(content))


# problem 19

weekdays = (
(0, 'Sunday'),
(1, 'Monday'),
(2, 'Tuesday'),
(3, 'Wednesday'),
(4, 'Thursday'),
(5, 'Friday'),
(6, 'Saturday'),
)

@csrf_exempt
def calculate_days(request):
body = json.loads(request.body)
try:
weekday = int(body.get('weekday'))
day_of_month = int(body.get('day_of_month'))
start_year = int(body.get('start_year'))
end_year = int(body.get('end_year'))

except KeyError:
return HttpResponse('form error')

d = {
'weekday': weekdays[weekday][1],
'day_of_month': day_of_month,
'start_year': start_year,
'end_year': end_year
}
d['num_days'] = utils.how_many(weekday, day_of_month, start_year, end_year)
return HttpResponse(json.dumps(d))
@@ -1,5 +1,6 @@
body {
font-family: "Lucida Sans Unicode";
background: #E1E3E4;
}

table {
@@ -24,45 +25,81 @@ td.solved {
top: 0;
left: 0;
width: 225px;
margin-bottom: 20px;
margin: -8px 0 19px -8px;
padding: 5px;
background: pink;
background: #65A7A1;
text-align: center;
}

#site-header a, a:hover, a:visited {
color:blue;
color:white;
text-decoration: none;
}

.pagination {
text-align: left;
width: 100%;
background: #444444;
margin: -19px 0 20px -8px;
padding: 15px;
}
.pagination a {
margin: 0 10px;
color: #FFF;
text-decoration: none;
}
.pagination a:hover {
color: #65A7A1;
}

.table-of-contents {
margin: 30px;
}
.table-of-contents a {
color: #444444;
text-decoration: none;
}

.table-of-contents a:hover {
color: #65A7A1;
}


#current-page {
margin: 0 10px;
}

.problem-header {
margin: 20px 0 30px 20px;
margin: -19px 0 30px -8px;
background: #444444;
padding: 1px 0px 1px 25px;
width: 100%;
}

.problem-header a {
margin-top: 10px;
color: #fff;
text-decoration: none;
}

.problem-header a:hover {
color: #65A7A1;
}

.prev-problem {
float: left;
margin-left: 20px;
color: #000!important;
}

.next-problem {
float: right;
margin-right: 20px;
margin-right: 40px;
color: #000!important;
}

.problem-description {
margin:60px 40px;
border: 1em black;
}

#input-area {
@@ -72,16 +109,38 @@ td.solved {
}
#output-area {
float: left;
margin: 10px 0 0 30px;
margin: 10px 0 30px 30px;
}

#solution {
display:none;
margin: 50px;
}
#solution-button {
margin: 20px 10px;
position: absolute;
top: 180px;
left: 20px;
margin: 25px 0px;
float: right;
padding: 15px;
}

.bottom-pagination a {
color: #444444;
text-decoration: none;
}
.bottom-pagination a:hover {
color: #65a7a1;
}

#footer {
text-align:center;
margin: 0px 0 0px -8px;
width: 100%;
background-color: #444444;
padding: 15px;
}
#footer a {
color: #FFFFFF;
text-decoration: none;
}
#footer a:hover {
color: #65A7A1;
}