Skip to content
Snippets Groups Projects
Commit e7120a3d authored by tuhe's avatar tuhe
Browse files

Updates for presentation

parent 3500606a
Branches
Tags
No related merge requests found
Showing
with 1182 additions and 10 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
import os
if __name__ == "__main__":
from unitgrade_private.pipelines.process_65 import process_by_zip_file
from unitgrade_private.pipelines.dummy_handins import make_dummies
cdir = os.path.dirname(__file__)
make_dummies(zip_file_path=cdir + "/handin/project1.zip", n_handins=3, screwups=4, student_base_dir=cdir+"/students", student_grade_file=cdir+"/students/intro_python/exam_grade.py")
# student base directory.
pass
\ No newline at end of file
make_dummies(zip_file_path=cdir + "/student_handins/intro_python_exam.zip", n_handins=10, screwups=4, student_base_dir=cdir+"/students",
instructor_base_dir=cdir + "/instructor",
student_grade_file=cdir+"/students/intro_python/exam_grade.py")
# syntax=docker/dockerfile:1
FROM python:3.8-slim-buster
MAINTAINER Autolab Team <autolab-dev@andrew.cmu.edu>
RUN apt-get update && apt-get install -y \
build-essential \
gcc \
git \
make \
sudo \
python \
procps \
&& rm -rf /var/lib/apt/lists/*
# Install autodriver
WORKDIR /home
RUN useradd autolab
RUN useradd autograde
RUN mkdir autolab autograde output
RUN chown autolab:autolab autolab
RUN chown autolab:autolab output
RUN chown autograde:autograde autograde
RUN git clone --depth 1 https://github.com/autolab/Tango.git
WORKDIR Tango/autodriver
RUN make clean && make
RUN cp autodriver /usr/bin/autodriver
RUN chmod +s /usr/bin/autodriver
# Do the python stuff.
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
# Clean up
WORKDIR /home
RUN apt-get remove -y git && apt-get -y autoremove && rm -rf Tango/
# Check installation
RUN ls -l /home
RUN which autodriver
numpy
tqdm
jinja2
tabulate
pyfiglet
colorama
unitgrade>=0.1.23
unitgrade-devel>=0.1.37 # Required to run automatic evaluation (load tokens etc.)
requests # For unitgrade, may remove later.
File added
<html>
<head>
<title>Moss Results</title>
</head>
<body>
Moss Results<p>
Wed Oct 12 07:50:30 PDT 2022
</p><p>
Options -l python -m 10
</p><hr/>
[ <a href="http://moss.stanford.edu/general/format.html" target="_top"> How to Read the Results</a> | <a href="http://moss.stanford.edu/general/tips.html" target="_top"> Tips</a> | <a href="http://moss.stanford.edu/general/faq.html"> FAQ</a> | <a href="mailto:moss-request@cs.stanford.edu">Contact</a> | <a href="http://moss.stanford.edu/general/scripts.html">Submission Scripts</a> | <a href="http://moss.stanford.edu/general/credits.html" target="_top"> Credits</a> ]
<hr/>
<table>
<tr><th>File 1</th><th>File 2</th><th>Lines Matched
</th></tr><tr><td><a href="match0.html">/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221001/0_problems.py (98%)</a>
</td><td><a href="match0.html">/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221002/0_problems.py (97%)</a>
</td><td align="right">86
</td></tr><tr><td><a href="match1.html">/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221001/0_problems.py (93%)</a>
</td><td><a href="match1.html">/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221000/0_problems.py (92%)</a>
</td><td align="right">81
</td></tr><tr><td><a href="match2.html">/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221002/0_problems.py (87%)</a>
</td><td><a href="match2.html">/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221000/0_problems.py (87%)</a>
</td><td align="right">78
</td></tr><tr><td><a href="match3.html">/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221001/2_exam.py (91%)</a>
</td><td><a href="match3.html">/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221002/2_exam.py (91%)</a>
</td><td align="right">60
</td></tr><tr><td><a href="match4.html">/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221002/2_exam.py (80%)</a>
</td><td><a href="match4.html">/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221000/2_exam.py (79%)</a>
</td><td align="right">44
</td></tr><tr><td><a href="match5.html">/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221001/2_exam.py (79%)</a>
</td><td><a href="match5.html">/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221000/2_exam.py (79%)</a>
</td><td align="right">50
</td></tr></table>
<hr/>
Any errors encountered during this query are listed below.<p></p></body>
</html>
<html>
<head>
<title>/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221001/0_problems.py</title>
</head>
<body bgcolor="white">
<hr/>
/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221001/0_problems.py<p></p><pre>
<a name="0"></a><font color="#FF0000"><a href="match0-1.html#0" target="1"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_0_33.gif"/></a>
import numpy as np
def astronomical_season(date):
""" Problem 1. Given a date (as a string) return the season (as a string)
Hints:
* The date is a string in the format &lt;dd&gt; &lt;mm&gt;, for instance '18 04' is the 18th of March.
* The season must be a string which can be either 'winter', 'spring', 'summer' or 'autumn'.
"""
dd = int(date[0:2]) #!b
mm = int(date[3:5])
if mm&lt;3 or (mm==3 and dd&lt;20):
season = 'winter'
elif mm&lt;6 or (mm==6 and dd&lt;21):
season = 'spring'
elif mm&lt;9 or (mm==9 and dd&lt;23):
season = 'summer'
elif mm&lt;12 or (mm==12 and dd&lt;21):
season = 'autumn'
else:
season = 'winter' #!b Compute the season here.
return season
def standardize_address(address):
""" Given an address, return a standardized version (see question text)
Hints:
* The function s.isnumeric() may be of help to check if a string s is a number.
"""
s = address.replace('_', ' ') #!b
</font> assert(False)
<a name="1"></a><font color="#00FF00"><a href="match0-1.html#1" target="1"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_1_31.gif"/></a>
if not s[0].isnumeric():
i = s[-1::-1].find(' ')
i = len(s) - 1 - i
s = s[i+1:] + s[i] + s[:i] #!b Compute the address here
return s
def tictactoe(board):
""" Given a tic-tac-toc board configuration, return whether it is valid or not.
Hints:
* Remember that 'board' is a numpy array. Check what the function np.all(A, axis) does.
* You can 'flatten' an array using A.ravel().
"""
def wins(b): #!b
return np.all(b, axis=0).sum() + np.all(b, axis=1).sum() + np.all(b.ravel()[[0, 4, 8]]) + np.all(b.ravel()[[2, 4, 6]])
ones_wins = wins(board == 1)
twos_wins = wins(board == 2)
d = np.sum(board == 1) - np.sum(board == 2) # 0 or 1 for a valid board
</font><a name="2"></a><font color="#0000FF"><a href="match0-1.html#2" target="1"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_2_22.gif"/></a>
if d &lt; 0 or d &gt; 1 or (ones_wins + twos_wins) &gt; 1:
score = -1
elif ones_wins:
score = 1
elif twos_wins:
score = 2
else:
score = 0 #!b compute the board score (an integer, either 0, 1 or 2)
return score
def time_angle(hour, minute):
""" Given hours and minutes (integers), return the angle of the small hand.
Hints:
* The angle is between 0 and 360.
* Noon and midnight, 12:00 and 24:00, is both 0
* Use % for remainder. For instance 8 % 5 is 2 and 24 % 10 = 4 (see lecture notes)
"""
hour = hour % 12 #!b
hour_hand = 360 * (hour + minute / 60) / 12
minute_hand = 360 * minute / 60
a = hour_hand - minute_hand
</font><a name="3"></a><font color="#00FFFF"><a href="match0-1.html#3" target="1"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_3_10.gif"/></a>
if a &lt; 0:
a = a + 360 #!b Compute the angle of the small hand here
return a
def water_height(h0, r):
""" Problem 1: Compute the water height.
Hints:
* Remember the height must be a non-negative number.
"""
h = h0 #!b
for ri in r:
h = max(h + ri - 2, 0) #!b Compute the water height h here.
return h
</font></pre>
</body>
</html>
<html>
<head>
<title>/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221001/0_problems.py</title>
</head>
<body bgcolor="white">
<hr/>
/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221002/0_problems.py<p></p><pre>
<a name="0"></a><font color="#FF0000"><a href="match0-0.html#0" target="0"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_0_33.gif"/></a>
import numpy as np
def astronomical_season(date):
""" Problem 1. Given a date (as a string) return the season (as a string)
Hints:
* The date is a string in the format &lt;dd&gt; &lt;mm&gt;, for instance '18 04' is the 18th of March.
* The season must be a string which can be either 'winter', 'spring', 'summer' or 'autumn'.
"""
dd = int(date[0:2]) #!b
mm = int(date[3:5])
if mm&lt;3 or (mm==3 and dd&lt;20):
season = 'winter'
elif mm&lt;6 or (mm==6 and dd&lt;21):
season = 'spring'
elif mm&lt;9 or (mm==9 and dd&lt;23):
season = 'summer'
elif mm&lt;12 or (mm==12 and dd&lt;21):
season = 'autumn'
else:
season = 'winter' #!b Compute the season here.
return season
def standardize_address(address):
""" Given an address, return a standardized version (see question text)
Hints:
* The function s.isnumeric() may be of help to check if a string s is a number.
"""
s = address.replace('_', ' ') #!b
</font><a name="1"></a><font color="#00FF00"><a href="match0-0.html#1" target="0"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_1_31.gif"/></a>
if not s[0].isnumeric():
i = s[-1::-1].find(' ')
i = len(s) - 1 - i
s = s[i+1:] + s[i] + s[:i] #!b Compute the address here
return s
def tictactoe(board):
""" Given a tic-tac-toc board configuration, return whether it is valid or not.
Hints:
* Remember that 'board' is a numpy array. Check what the function np.all(A, axis) does.
* You can 'flatten' an array using A.ravel().
"""
def wins(b): #!b
return np.all(b, axis=0).sum() + np.all(b, axis=1).sum() + np.all(b.ravel()[[0, 4, 8]]) + np.all(b.ravel()[[2, 4, 6]])
ones_wins = wins(board == 1)
twos_wins = wins(board == 2)
d = np.sum(board == 1) - np.sum(board == 2) # 0 or 1 for a valid board
</font> assert(False)
<a name="2"></a><font color="#0000FF"><a href="match0-0.html#2" target="0"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_2_22.gif"/></a>
if d &lt; 0 or d &gt; 1 or (ones_wins + twos_wins) &gt; 1:
score = -1
elif ones_wins:
score = 1
elif twos_wins:
score = 2
else:
score = 0 #!b compute the board score (an integer, either 0, 1 or 2)
return score
def time_angle(hour, minute):
""" Given hours and minutes (integers), return the angle of the small hand.
Hints:
* The angle is between 0 and 360.
* Noon and midnight, 12:00 and 24:00, is both 0
* Use % for remainder. For instance 8 % 5 is 2 and 24 % 10 = 4 (see lecture notes)
"""
hour = hour % 12 #!b
hour_hand = 360 * (hour + minute / 60) / 12
minute_hand = 360 * minute / 60
a = hour_hand - minute_hand
</font><a name="3"></a><font color="#00FFFF"><a href="match0-0.html#3" target="0"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_3_10.gif"/></a>
assert(False)
if a &lt; 0:
a = a + 360 #!b Compute the angle of the small hand here
return a
def water_height(h0, r):
""" Problem 1: Compute the water height.
Hints:
* Remember the height must be a non-negative number.
"""
h = h0 #!b
for ri in r:
h = max(h + ri - 2, 0) #!b Compute the water height h here.
return h
</font></pre>
</body>
</html>
<html>
<head>
<title>Top</title>
</head><body bgcolor="white"><center><table bgcolor="#d0d0d0" border="1" cellspacing="0"><tr><th>/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221001/0_problems.py (98%)</th><th><img align="left" border="0" src="http://moss.stanford.edu/bitmaps/tm_0_98.gif"/></th><th>/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221002/0_problems.py (97%)</th><th><img align="left" border="0" src="http://moss.stanford.edu/bitmaps/tm_0_97.gif"/></th><th>
</th></tr><tr><td><a href="match0-0.html#0" name="0" target="0">1-30</a>
</td><td><a href="match0-0.html#0" name="0" target="0"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_0_33.gif"/></a>
</td><td><a href="match0-1.html#0" name="0" target="1">1-30</a>
</td><td><a href="match0-1.html#0" name="0" target="1"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_0_33.gif"/></a>
</td></tr><tr><td><a href="match0-0.html#1" name="1" target="0">32-50</a>
</td><td><a href="match0-0.html#1" name="1" target="0"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_1_31.gif"/></a>
</td><td><a href="match0-1.html#1" name="1" target="1">31-49</a>
</td><td><a href="match0-1.html#1" name="1" target="1"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_1_31.gif"/></a>
</td></tr><tr><td><a href="match0-0.html#2" name="2" target="0">51-72</a>
</td><td><a href="match0-0.html#2" name="2" target="0"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_2_22.gif"/></a>
</td><td><a href="match0-1.html#2" name="2" target="1">51-72</a>
</td><td><a href="match0-1.html#2" name="2" target="1"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_2_22.gif"/></a>
</td></tr><tr><td><a href="match0-0.html#3" name="3" target="0">72-86</a>
</td><td><a href="match0-0.html#3" name="3" target="0"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_3_10.gif"/></a>
</td><td><a href="match0-1.html#3" name="3" target="1">73-87</a>
</td><td><a href="match0-1.html#3" name="3" target="1"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_3_10.gif"/></a>
</td></tr></table></center></body></html>
\ No newline at end of file
<html>
<head><title>Matches for /home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221001/0_problems.py and /home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221002/0_problems.py</title>
</head><frameset rows="150,*"><frameset cols="1000,*"><frame frameborder="0" name="top" src="match0-top.html"/></frameset><frameset cols="50%,50%"><frame name="0" src="match0-0.html"/><frame name="1" src="match0-1.html"/></frameset></frameset></html>
\ No newline at end of file
<html>
<head>
<title>/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221001/0_problems.py</title>
</head>
<body bgcolor="white">
<hr/>
/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221001/0_problems.py<p></p><pre>
<a name="0"></a><font color="#FF0000"><a href="match1-1.html#0" target="1"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_0_33.gif"/></a>
import numpy as np
def astronomical_season(date):
""" Problem 1. Given a date (as a string) return the season (as a string)
Hints:
* The date is a string in the format &lt;dd&gt; &lt;mm&gt;, for instance '18 04' is the 18th of March.
* The season must be a string which can be either 'winter', 'spring', 'summer' or 'autumn'.
"""
dd = int(date[0:2]) #!b
mm = int(date[3:5])
if mm&lt;3 or (mm==3 and dd&lt;20):
season = 'winter'
elif mm&lt;6 or (mm==6 and dd&lt;21):
season = 'spring'
elif mm&lt;9 or (mm==9 and dd&lt;23):
season = 'summer'
elif mm&lt;12 or (mm==12 and dd&lt;21):
season = 'autumn'
else:
season = 'winter' #!b Compute the season here.
return season
def standardize_address(address):
""" Given an address, return a standardized version (see question text)
Hints:
* The function s.isnumeric() may be of help to check if a string s is a number.
"""
s = address.replace('_', ' ') #!b
</font> assert(False)
<a name="2"></a><font color="#0000FF"><a href="match1-1.html#2" target="1"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_2_15.gif"/></a>
if not s[0].isnumeric():
i = s[-1::-1].find(' ')
i = len(s) - 1 - i
s = s[i+1:] + s[i] + s[:i] #!b Compute the address here
return s
def tictactoe(board):
""" Given a tic-tac-toc board configuration, return whether it is valid or not.
Hints:
* Remember that 'board' is a numpy array. Check what the function np.all(A, axis) does.
</font><a name="3"></a><font color="#00FFFF"><a href="match1-1.html#3" target="1"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_3_12.gif"/></a>
* You can 'flatten' an array using A.ravel().
"""
def wins(b): #!b
return np.all(b, axis=0).sum() + np.all(b, axis=1).sum() + np.all(b.ravel()[[0, 4, 8]]) + np.all(b.ravel()[[2, 4, 6]])
ones_wins = wins(board == 1)
twos_wins = wins(board == 2)
</font><a name="1"></a><font color="#00FF00"><a href="match1-1.html#1" target="1"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_1_20.gif"/></a>
d = np.sum(board == 1) - np.sum(board == 2) # 0 or 1 for a valid board
if d &lt; 0 or d &gt; 1 or (ones_wins + twos_wins) &gt; 1:
score = -1
elif ones_wins:
score = 1
elif twos_wins:
score = 2
else:
score = 0 #!b compute the board score (an integer, either 0, 1 or 2)
return score
def time_angle(hour, minute):
""" Given hours and minutes (integers), return the angle of the small hand.
Hints:
* The angle is between 0 and 360.
* Noon and midnight, 12:00 and 24:00, is both 0
* Use % for remainder. For instance 8 % 5 is 2 and 24 % 10 = 4 (see lecture notes)
"""
hour = hour % 12 #!b
</font><a name="4"></a><font color="#FF00FF"><a href="match1-1.html#4" target="1"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_4_10.gif"/></a>
hour_hand = 360 * (hour + minute / 60) / 12
minute_hand = 360 * minute / 60
a = hour_hand - minute_hand
if a &lt; 0:
a = a + 360 #!b Compute the angle of the small hand here
return a
def water_height(h0, r):
""" Problem 1: Compute the water height.
Hints:
* Remember the height must be a non-negative number.
"""
</font> h = h0 #!b
for ri in r:
h = max(h + ri - 2, 0) #!b Compute the water height h here.
return h
</pre>
</body>
</html>
<html>
<head>
<title>/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221001/0_problems.py</title>
</head>
<body bgcolor="white">
<hr/>
/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221000/0_problems.py<p></p><pre>
<a name="0"></a><font color="#FF0000"><a href="match1-0.html#0" target="0"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_0_33.gif"/></a>
import numpy as np
def astronomical_season(date):
""" Problem 1. Given a date (as a string) return the season (as a string)
Hints:
* The date is a string in the format &lt;dd&gt; &lt;mm&gt;, for instance '18 04' is the 18th of March.
* The season must be a string which can be either 'winter', 'spring', 'summer' or 'autumn'.
"""
dd = int(date[0:2]) #!b
mm = int(date[3:5])
if mm&lt;3 or (mm==3 and dd&lt;20):
season = 'winter'
elif mm&lt;6 or (mm==6 and dd&lt;21):
season = 'spring'
elif mm&lt;9 or (mm==9 and dd&lt;23):
season = 'summer'
elif mm&lt;12 or (mm==12 and dd&lt;21):
season = 'autumn'
else:
season = 'winter' #!b Compute the season here.
return season
def standardize_address(address):
""" Given an address, return a standardized version (see question text)
Hints:
* The function s.isnumeric() may be of help to check if a string s is a number.
"""
s = address.replace('_', ' ') #!b
</font><a name="2"></a><font color="#0000FF"><a href="match1-0.html#2" target="0"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_2_15.gif"/></a>
if not s[0].isnumeric():
i = s[-1::-1].find(' ')
i = len(s) - 1 - i
s = s[i+1:] + s[i] + s[:i] #!b Compute the address here
return s
def tictactoe(board):
""" Given a tic-tac-toc board configuration, return whether it is valid or not.
Hints:
* Remember that 'board' is a numpy array. Check what the function np.all(A, axis) does.
</font> assert(False)
<a name="3"></a><font color="#00FFFF"><a href="match1-0.html#3" target="0"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_3_12.gif"/></a>
* You can 'flatten' an array using A.ravel().
"""
def wins(b): #!b
return np.all(b, axis=0).sum() + np.all(b, axis=1).sum() + np.all(b.ravel()[[0, 4, 8]]) + np.all(b.ravel()[[2, 4, 6]])
ones_wins = wins(board == 1)
twos_wins = wins(board == 2)
</font> assert(False)
<a name="1"></a><font color="#00FF00"><a href="match1-0.html#1" target="0"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_1_20.gif"/></a>
d = np.sum(board == 1) - np.sum(board == 2) # 0 or 1 for a valid board
if d &lt; 0 or d &gt; 1 or (ones_wins + twos_wins) &gt; 1:
score = -1
elif ones_wins:
score = 1
elif twos_wins:
score = 2
else:
score = 0 #!b compute the board score (an integer, either 0, 1 or 2)
return score
def time_angle(hour, minute):
""" Given hours and minutes (integers), return the angle of the small hand.
Hints:
* The angle is between 0 and 360.
* Noon and midnight, 12:00 and 24:00, is both 0
* Use % for remainder. For instance 8 % 5 is 2 and 24 % 10 = 4 (see lecture notes)
"""
hour = hour % 12 #!b
</font> assert(False)
<a name="4"></a><font color="#FF00FF"><a href="match1-0.html#4" target="0"><img align="left" alt="other" border="0" src="http://moss.stanford.edu/bitmaps/tm_4_10.gif"/></a>
hour_hand = 360 * (hour + minute / 60) / 12
minute_hand = 360 * minute / 60
a = hour_hand - minute_hand
if a &lt; 0:
a = a + 360 #!b Compute the angle of the small hand here
return a
def water_height(h0, r):
""" Problem 1: Compute the water height.
Hints:
* Remember the height must be a non-negative number.
"""
</font> h = h0 #!b
assert(False)
for ri in r:
h = max(h + ri - 2, 0) #!b Compute the water height h here.
return h
</pre>
</body>
</html>
<html>
<head>
<title>Top</title>
</head><body bgcolor="white"><center><table bgcolor="#d0d0d0" border="1" cellspacing="0"><tr><th>/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221001/0_problems.py (93%)</th><th><img align="left" border="0" src="http://moss.stanford.edu/bitmaps/tm_0_93.gif"/></th><th>/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221000/0_problems.py (92%)</th><th><img align="left" border="0" src="http://moss.stanford.edu/bitmaps/tm_0_92.gif"/></th><th>
</th></tr><tr><td><a href="match1-0.html#0" name="0" target="0">1-30</a>
</td><td><a href="match1-0.html#0" name="0" target="0"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_0_33.gif"/></a>
</td><td><a href="match1-1.html#0" name="0" target="1">1-30</a>
</td><td><a href="match1-1.html#0" name="0" target="1"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_0_33.gif"/></a>
</td></tr><tr><td><a href="match1-0.html#1" name="1" target="0">50-69</a>
</td><td><a href="match1-0.html#1" name="1" target="0"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_1_20.gif"/></a>
</td><td><a href="match1-1.html#1" name="1" target="1">51-70</a>
</td><td><a href="match1-1.html#1" name="1" target="1"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_1_20.gif"/></a>
</td></tr><tr><td><a href="match1-0.html#2" name="2" target="0">32-42</a>
</td><td><a href="match1-0.html#2" name="2" target="0"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_2_15.gif"/></a>
</td><td><a href="match1-1.html#2" name="2" target="1">31-41</a>
</td><td><a href="match1-1.html#2" name="2" target="1"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_2_15.gif"/></a>
</td></tr><tr><td><a href="match1-0.html#3" name="3" target="0">43-49</a>
</td><td><a href="match1-0.html#3" name="3" target="0"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_3_12.gif"/></a>
</td><td><a href="match1-1.html#3" name="3" target="1">43-49</a>
</td><td><a href="match1-1.html#3" name="3" target="1"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_3_12.gif"/></a>
</td></tr><tr><td><a href="match1-0.html#4" name="4" target="0">70-82</a>
</td><td><a href="match1-0.html#4" name="4" target="0"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_4_10.gif"/></a>
</td><td><a href="match1-1.html#4" name="4" target="1">72-84</a>
</td><td><a href="match1-1.html#4" name="4" target="1"><img align="left" alt="link" border="0" src="http://moss.stanford.edu/bitmaps/tm_4_10.gif"/></a>
</td></tr></table></center></body></html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment