Homework means the question is requesting help with school homework. This lets potential answerers know that they SHOULD guide the student in solving the problem, and SHOULD NOT simply show the complete answer.

learn more… | top users | synonyms

4
votes
1answer
47 views

Unit testing a CharGrid

I wrote NUnit tests for class CharGrid from this homework assignment. My goal here is DRY: I want to keep the testing code as short and simple as possible. In addition, want to run every test ...
1
vote
1answer
102 views

Insect combinatorics challenge

Below is the problem taken from Berkeley's Cs61A page here Question 9: Insect Combinatorics* Consider an insect in an M by N grid. The insect starts at the bottom left corner, (0, 0), and ...
5
votes
2answers
80 views

Minimum number of coins to make change

I am new to programming and I am taking CS50 2014 online through iTunes University. This is the change-making problem in Problem Set 1: Write a program that first asks the user how much change is ...
6
votes
2answers
76 views

FizzBuzz-like Assignment

I have an assignment for my Java programming class that is kind of an expanded FizzBuzz-like question: Write a program that iterates through numbers from 0 to 113 using a loop. Print the ...
8
votes
3answers
249 views

Sums of some array elements

I'm doing an archived MOOC at the moment which introduces Ruby programming. There are some assingments, yet no solutions and since the MOOC is over no one will correct those (+ the forum is down) I'm ...
8
votes
1answer
184 views

First assignment for Stanford iOS8 Course: enhancing a calculator

I recently started learning Swift through Stanford iOS8 Course. The first assignment is to add some features to simple Calculator which was presented during lectures. List of tasks: add button for ...
5
votes
4answers
378 views

Word Guessing Game

I'm trying to learn Java (albeit rather slowly). I'm in a computer science class at my highschool and I've written this little bit of code for a project. Basically it is a word guessing game where if ...
5
votes
1answer
88 views

Enter values, generate a list, and search

My assignment in school: Read in names to sort until the user types the “enter” key After sorting and displaying the array of strings Do a binary search to find if the string is in the array If the ...
2
votes
1answer
152 views

Priority Queue Linked List Implementation

I am new to Python and wanted to make sure my code answers the question for my assignment due. My Task: A priority queue is a queue in which each item is assigned a priority and items with a ...
0
votes
1answer
99 views

Cartesian product of two tuples - python

I'm solving exercise 4 from Discussion 3 of Berkley's CS 61A (2012) (see page 4): Fill in the definition of cartesian_product. ...
2
votes
2answers
152 views

War card game simulator

My teacher wants us to create a program that runs n games of war and calculates the average number of battles, wars and double wars that occurred. He has very specific rules (not necessarily the ...
2
votes
2answers
167 views

Simple Binary Adder

The program adds two binary numbers in two' s complement ignoring the overflow for a constant size of bits. I am trying to generalize the program by taking input from the user in a single line without ...
8
votes
4answers
1k views

Printing an Alternating Pattern to the Console

For this assignment, you will create the pattern of a chess board that is 8 x 8. Use X and O to represent the squares. Create the appropriate nested looping structure to output the ...
5
votes
1answer
115 views

SICP Exercise 1.3: Sum of squares of two largest numbers out of three, Haskell Version

The exercise 1.3 of the book Structure and Interpretation of Computer Programs asks the following: Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of ...
5
votes
3answers
234 views

SICP Exercise 1.3: Sum of squares of two largest numbers out of three

The exercise 1.3 of the book Structure and Interpretation of Computer Programs asks the following: Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of ...
3
votes
1answer
58 views

Payroll Program using 3 types of pass-by

This program is a payroll using calculate two types of employee. Two overloaded functions for two type of employee (hourly and salaried). There must be one pass-by-value, one pass-by-reference, and ...
6
votes
5answers
512 views

Simple technology quiz

This is my first program that uses more than just boring ol' if/else statements - I made a whole 246 line game that's still a ...
4
votes
2answers
232 views

Hex Editor in C

I had a homework assignment to create a simple hex editor that reads binary files as well as write integers to it. However I enhanced it a bit. Homework is already submitted, but that doesn't mean ...
3
votes
3answers
123 views

Multiple for loops in Sudoku solver

I have an assignment for writing a Sudoku solver and have achieved the functionality required but a lot of the code is "ugly" and I'm wanting to simplify it but unsure how to. ...
8
votes
2answers
259 views

Unit Tests for a Fraction Class

As my first Java homework, I wrote a class to handle fractions. This Fraction class implements basic operations for the fractions (addition, subtraction, ...
2
votes
2answers
109 views

Building Data abstraction for line segments using “type abstraction”

Below is the given exercise: Exercise 5: Segments Consider the problem of representing line segments in a plane. Each segment is represented as a pair of points: a starting point and an ...
1
vote
1answer
68 views

Building Data abstraction for line segments using “objects”

I follow this definition of "object":...
12
votes
1answer
148 views

Chack miy spellang pleez

For my CS2 project, I am supposed to implement a spell-checker. It is supposed to follow the following: Prompt the user for the name of the file containing the dictionary of correctly ...
4
votes
1answer
86 views

HDD Based AVL Tree

For class I have to write a program that reads (plaintext) numbers from a file, and inserts them into an AVL tree stored in another (binary) file. I cannot have more than about 10 nodes in memory at ...
4
votes
1answer
123 views

Building an efficient bubble sort function

I've been asked to create a bubble sort function that checks whether the array has been filled sorted before all passes are complete, thereby avoiding unnecessary passes. This is to involve ...
5
votes
3answers
241 views

“Set” your expectations low for this ADT

For my third assignment in CS2, I was given the following: A set is a special bag that does not allow duplicates. Specify each operation for a set of objects by stating its purpose, by ...
3
votes
1answer
65 views

Perceptron algorithm

This is the Perceptron algorithm, I wrote this implementation with my friend. It gets the job done, but it's quite dirty, perhaps one of you stylish hackers might help me beautify this beast. This ...
14
votes
4answers
1k views

Smart as a bag of rocks

For my second project in CS2, I was given the following assignment: Implement a new ADT called a bag with receipts. The specification for the class of bag with receipts differs from a ...
2
votes
0answers
63 views

Search/sort/create functionality, implements bubblesort and sequential search

I've moved my main() to the bottom of the code block in order to fit it all in one class for this submission. If there is a better way to do it? ...
8
votes
2answers
262 views

Symmetric Square

I was given an assignment to ensure that a list was symmetric. I built it in a way that worked and it passed the tests. But I wanted to see if it could've been written more efficiently and still ...
3
votes
4answers
136 views

Concatenate two arrays generated randomly

I have written the code to concatenate two arrays . Please let me know of any loopholes in the written code. ...
6
votes
3answers
410 views

Optimizing this Knight's Tour

My assignment in CS was to make a knight's tour application that could solve the problem from any starting position. I had just finished the code so excuse the lack of deeply descriptive comments. My ...
3
votes
2answers
411 views

Shuffle the elements of the array randomly

I have written the code to shuffle the elements of the array. Please let me know of any loopholes in the written code. ...
11
votes
4answers
2k views

To understand what recursion is, you must first understand recursion

This is the second assignment for my CS2 course: Write a recursive C++ function writeLine() that writes a character repeatedly to form a line of n ...
7
votes
3answers
1k views

RPN calculator in C

I had to write a RPN calculator in C as one of my homework problems, but if someone could critique my code and suggest any improvements, that would be fantastic! I haven't added any overflow errors or ...
6
votes
3answers
2k views

Harvard CS50 Problem Set 1: greedy change-making algorithm

The goal of this code is to take dollar or cents input from the user and give out minimum number of coins needed to pay that between quarters, dimes, nickels and pennies. If this code can be ...
10
votes
4answers
748 views

Knowledge is power

Resurrecting my C++ saga, I was given this project for my CS2 class: This problem considers several ways to compute \$ x^n \$ for some \$ n \ge 0 \$. Write an iterative function ...
-1
votes
2answers
90 views

Cycles of pointers

I'm really inexperienced with cycles, so I want to make this code shorter. As far as I know, I've made a recursive cycle. ...
2
votes
1answer
157 views

Calculating Payroll

I have written the code as best that I know how but I am unsure that the questions asked are being fulfilled. Any advice to improve this code would really help me. Question asked: Create a ...
10
votes
2answers
1k views

It's almost Friday, right?

This is my final post for my CS1 saga. Mostly all I had to do was just "class-ify" my past project in this post. Here are the requirements: Make all data members private and use constructors, ...
11
votes
3answers
534 views

Predicting the next pseudorandom value

The archived material for the Stanford University course on cryptography at coursera.org includes a problem where you have to predict the next output of a weak PRG. It can be briefly restated as ...
7
votes
4answers
160 views

Test a number for primality and return smallest divisor different from 1 if it’s is composite

In this exercise we were asked to test a number for primality and print the results. Additionally – in the case the number is composite – the smallest divisor different from 1 should be printed out. ...
7
votes
2answers
368 views

Counting Fermat witnesses and liars

We were asked to implement a program that calculates the number of Fermat witnesses and liars for odd numbers greater 1. This involves Fermat’s little theorem. Fermat’s little is used to identify ...
4
votes
3answers
1k views

Rounding and formatting hours, minutes, seconds as HH:MM AM/PM

I have a program which is supposed to convert standard time to traditional time. (e.g: 15:24:31 = 3:25PM [rounded seconds]) I would like for someone to error check my code for me as well as give me ...
10
votes
5answers
908 views

Entering two integers and returning a decimal fraction

After a couple of small programs in Python we are now asked to do some basic stuff in Java. I don't really know where to start to improve this and whether it's even necessary. This is an exercise, so ...
5
votes
3answers
5k views

Count occurrence of words in a .txt file

I'm taking an intro to programming class and although I've learned some things I didn't know before (I've been using Python for about 1.5 years) I feel like I've not progressed much in writing ...
6
votes
2answers
405 views

Converting fractions to mixed numbers

I've been making a program for an assignment that converts fractions to mixed numbers, and I'm done, but I was wondering if I could simplify it in any way, since it seems quite complicated right now. ...
10
votes
1answer
646 views

Counting Words in Files - MATLAB style

For my Matlab class I'm taking, I was given the task to write a function ReadAndCountWords that takes in the name of a text file (specifically from this zip file) ...
2
votes
2answers
124 views

Make a dict class from scratch in Python

Here's the API my teacher assigned: and here is what I came up with: ...