Turn in all solutions (including those requiring code) neatly typeset on 8.5" × 11" paper, with a staple in the upper left corner.
Store your files in a private GitHub repository
named <yourgithubname>/cmsi282. At the top level of this repository
create a folder called homework1 in which your files will be placed.
During grading, I may clone your repository and run my own test suite on your code,
so don’t forget to give me access to your repo. My github name is rtoal.
I will be looking for your code in the branch master
, of course.
Problems that do not involve code should be answered in the file README.md;
problems involving code should be placed in properly named files according
to the convention of your chosen implementation language (which may be JavaScript,
CoffeeScript, Java, or Python).
I encourage you to work in pairs. Please submit only one solution set for your team.
This is due at the beginning of class on Tuesday, February 9, 2016.
Just read, watch, and do. You do not have to take notes or write reports on them; however, don’t cheat yourself by skipping them. These independent learning units must be done individually, but please feel free to discuss these items with your partner, your friends, or even with the rest of the class on the Discussion Boards.
Please note that this is an unusual assignment because I will sometimes (but not always) be prescribing an approach for a problem, rather than letting you solve it any way you want to.
{5:3,3:-2,1:5,0:-3
}. Use the following
templates:
# Python, in poly.py class Polynomial: def __init__(self, coefficients): self.coefficients = coefficients def evaluate(self, x): # your code here
// JavaScript, in poly.js class Polynomial { constructor(coefficients) { this.coefficients = coefficients; } evaluate(x) { // your code here } }
// CoffeeScript, in poly.coffee class Polynomial constructor: (@coefficients) -> evaluate: (x) -> # your code here }
// Java, in Polynomial.java class Polynomial { public Polynomial(Map<Integer,Integer> coefficients) { this.coefficients = coefficients; } public double evaluate(double x) { // your code here } }
[2,4,8,12,15,2,0,6,3,2,9,1]
the answer is true
because you can partition this list as follows:
[(4,3,9),(15,0,1),(8,2,6),(2,2,12)]
while the answer would be false
for:
[6, -1, 8, 3455, 11, 7]
The answer is also false if the length of the input list is not a multiple of 3. Make sure to correctly handle the empty list and the list with exactly three elements! Use the following templates:
# Python, in three.py def three_partition(numbers): # your code here
// JavaScript, in three.js function threePartition(numbers) { // your code here }
// CoffeeScript, in three.coffee threePartition = (numbers) -> # your code here }
// Java, in ThreePartitionSolver.java class ThreePartitionSolver { public static boolean threePartition(List<Integer> numbers) { // your code here } }