Questions requesting help with school homework. This tag lets potential answerers know that they should GUIDE the student in solving the problem, rather than showing a complete solution. CAUTION: Before posting, consider that classmates may be tempted to reuse code from your post. (Read the tag wiki....
3
votes
2answers
37 views
Read in file, and then compute class mean, median, max, min, class averages & update file
The application is designed to read in class results of individual students from a single text file, and then manipulate the data to give information such as class mean, median, max, min, individual ...
3
votes
2answers
58 views
Information about a nightclub in semantic HTML
Could anybody have a look at my HTML code and tell if it's build upon the correct semantic way using the right tags, and not using unnecessary divs?
I'm still not sure if there any divs in my code ...
4
votes
2answers
61 views
Red light, green light… kinda
For an assignment I had to create a client and a server that communicate over a well known FIFO. The server is required to use three threads to serve the client, managed by a semaphore.
The code was ...
4
votes
3answers
128 views
Guess three random numbers in order
We were given a homework assignment to create a C++ program that generates 3 different random numbers each time and the user is supposed to guess the three of them AND in order. I already achieved ...
2
votes
1answer
40 views
Swapping the diagonals of a matrix [closed]
I am required to write a simple matrix program and swap the diagonal.
Given the input
1 2 3
4 5 6
7 8 9
After swapping the diagonal it should be
...
4
votes
1answer
119 views
Console Ultimate Tic Tac Toe game
Last week I wrote a C++ program on Ultimate Tic Tac Toe. The issue was that the program was a bit lengthy (~230 lines) and it is needed to be around 150 lines.
I absolutely am not asking you to go ...
1
vote
1answer
132 views
7
votes
3answers
293 views
Generating Pythagorean triples below an upper bound
I've got an assigment where I have to print all the Pythagorean triples smaller than a given n. Even though I could print them directly in ...
3
votes
2answers
138 views
Using C++ to check if string s is subsequence of string t
The problem I want to solve is very simple:
Given a string s and a string t, check if s is subsequence of t. there is only lower case English letters in both s and t. t is potentially a very long (...
1
vote
1answer
102 views
Integer sum program
This is a little assignment I am working on. I am a beginner Java programmer and would love some advice on how to improve this code.
For more context, here are the assignment details:
Create a ...
4
votes
3answers
52 views
Burning logs - really simple text game
What I have
I am a bit advanced PHP developer, but now I'm going to college where we are learning Ruby. We got the first homework and I did it. But I wanna make great code - so I looked for standards ...
3
votes
1answer
28 views
Filetype backup script
This was one of my assignments in which I had to create a backup script that will individually compress all files (of an arbitrary number) of file-types (indicated by their .extension).
Example: <...
10
votes
2answers
159 views
mini-(Docker)-shell
I was given an assignment to write a mini-shell:
To write your own shell, you will need to start with a C program that
will prompt the user for input and accept in a number of arguments
from a ...
8
votes
2answers
1k views
What's the optimal 'pythonic' way to make dot product of two lists of numbers?
I just filled in the first assignment on course which involves learning Python. The assignment was to make vector class which supports scalar multiplication through operator overloading.
The ...
2
votes
3answers
170 views
Java Brute-Force Algorithms Homework
I'm taking an algorithms class this semester and this homework seemed pretty easy. Easy usually means something is wrong. Not always, though. Through testing, this application successfully answered ...
6
votes
0answers
76 views
Harry Potter's Family Tree Database
As an assignment for a class, I have made a small Harry Potter family tree in Prolog. It compiles into a self-contained executable that can be run straight from the command line on Linux machines. ...
1
vote
1answer
54 views
Logical contradiction type definitions
(Homework alert)
Working my way through "The Haskell Road...", not sure about my solution to exercise 2.15 on page 48 of the second edition:
A propositional contradiction is a formula that yields ...
6
votes
3answers
762 views
Using a greedy algorithm to find the best path in a 2D array
I'm a student and this is one of my assignments. My professor basically confirmed that my code is correct but all he grades on is if I finished the assignment correctly but not the coding style. I ...
3
votes
0answers
33 views
Movie Knowledgebase
I have had an assignment to construct a movie knowledgebase and ten specified queries in Prolog. This is my first ever Prolog program, so I would appreciate any pointers toward how I could improve.
...
5
votes
1answer
72 views
Snake game school project using Pygame
I am making a snake game and I'm almost done but I want to make my code more organized so people can understand so how to do it.
...
5
votes
1answer
106 views
Drink machine using structs homework assignment
Here's the school assignment I did:
Problem 1. Write a program that simulates a soft drink machine.
The program should use a structure Beverage that stores the following
data:
Drink ...
1
vote
3answers
113 views
Writing numbers into a file [closed]
I'm taking my first ever CS class and I have an assignment due Friday. I just wanted someone to check my code.
Instructions:
Write a program that:
gets the name of a text file of numbers ...
7
votes
2answers
817 views
Homework to display a square and calculate tips
Here's a simple school assignment I did:
Problem 1: Write a program that asks the user for a positive integer
no greater than 15. The program should then display a square on the
screen using ...
6
votes
2answers
55 views
Reading a line ending with a newline character from a file descriptor
I'm implementing a function that behaves like getline() which reads a line from file descriptor and returns the results without ...
1
vote
4answers
150 views
Program to display array elements in the ascending order of number of factors each element has
Input:
1000 23 100 26 32
Output:
23 26 32 100 1000
Since 23 has '2' factors and 26 has '4' factors and 32 has '6' ...
5
votes
2answers
379 views
itoa base function in C
This is a function that converts an integer value to a null-terminated string using the specified base and stores the result in a char array that I must allocate (...
4
votes
2answers
75 views
Processing trip route table in C
In fact, this is a group assignment for our C programming lesson, but seeking help from others is not considered cheating.
The goal of the following code is to:
Sort the data in ...
7
votes
2answers
161 views
Formatting seconds as hours:minutes:seconds
This is basically my school homework and I want to know what to improve, and what not to do.
The homework basically is this:
You will get a input in seconds, which is supposed to be shown as H:MM:SS ...
12
votes
5answers
903 views
Validating integer or string input
I'm at uni and working on an assignment in c# that takes some user input (from they keyboard via console).
The input validation required:
numbers must be within range (range will vary depending on ...
3
votes
1answer
110 views
Finding the prime factors of a positive number
I have an assignment to write on the standard output the prime factors of a positive number displayed in ascending order and separated by '*'. My code works, but I need help reviewing it before I ...
2
votes
1answer
383 views
Find shortest paths in a matrix using Dijkstra's algorithm
The problem is as follows:
I have a matrix with impassable fields those are marked by the input. There is also a castle which reaches up the right side of the matrix. I have to find how many paths ...
3
votes
1answer
136 views
Maxflow for baseball elimination game
I have a problem similar to the baseball elimination. Given some teams, the number of wins they have and the number of games they have left between each other I have to find for which team it is still ...
-2
votes
3answers
69 views
Calculating the max difference between any 2 numbers from an array
How can I make this little program work a little faster?
The task is to calculate the max difference between any 2 numbers from an array of numbers. Target time is 1 sec, now it works in 1.1 sec.
I'...
3
votes
1answer
334 views
Java Connect Four “Four in a row” detection algorithms
I am making a connect four type game for my end of the year project in my programming class. I am about to start building off of the console based version I have made and add a GUI, but I feel sort ...
7
votes
1answer
981 views
Drawing the flag of Liberia
I am working on this assignment to draw the flag of Liberia for my essentials of computer programming class.
I finished it but had extra time to kill and noticed that a couple similar blocks of code ...
3
votes
1answer
60 views
Anagram counter
Homework prompt was:
You are given two strings, a ‘parent’ string and a ‘query’ string respectively. Your task is to determine how many times the query string – or an anagram of the query string ...
1
vote
0answers
101 views
Pac-Man-ish maze game
I am a freshman in university. This Pac-Man-ish Game is my final Computer science homework. I know my code is not perfect and has so many to be improved. However, Compared to corrections of this game, ...
5
votes
1answer
96 views
A “pointless” animation program
The assignment description for this code is this:
Each time the user clicks the Circles button, randomly colored circles
flow into the display and continuously change their shapes.
Here is a ...
7
votes
1answer
72 views
Producer Consumer in C
I'm doing multithreading at university and we've been asked to implement the producer consumer problem in C.
My code compiles and produces the right result. From debugging it, it seems to be waiting ...
3
votes
2answers
111 views
Booking system for shows
Kindly accept my apologies as Java is something my mind cannot digest no matter what I do. At the moment I have an assignment and have written a piece of code and have used Constructor (I think so) ...
3
votes
2answers
113 views
TCP client and server supporting six simple commands
For a class, I was given an assignment to code a simple TCP connection between a server and a client. Once the TCP handshake is done, the client sends inquiries to the server. It's a 2 second ...
5
votes
1answer
300 views
8086/DOS assembly keyboard I=input, data loss in registers
I am working on a project for class, and it works as required by the rubric, though I am wondering if there is a slightly better way to implement a few things. I was docked a few points for an ...
1
vote
1answer
354 views
7
votes
3answers
165 views
Prolog parser written in Haskell
I am writing a very simple Prolog intepreter in Haskell. It's a class assignment and I really want to do it right.
I was able to (quite quickly) write a parser for the language. Today I borrowed a ...
3
votes
1answer
137 views
“Destroy the Asteroid” Game
I made this game for my computer science class.
Here is my professor's requirements:
Write a Processing program that draws a triangle in the middle of the window.
Rotate the triangle when ...
2
votes
0answers
248 views
Roman numeral converter project
I have a project that is due for my Intro to Java course which requires me to translate the number range of 1 - 3999 into Roman numeral form. If the number I pick is 0 it will end my program, anything ...
1
vote
3answers
652 views
Morse code translator in C#
I'm writing a Morse code translator for homework in C#. It takes an input from the user and returns the Morse code version of their input. I understand that this code may look horrible, so how could I ...
2
votes
2answers
107 views
My spaceship is slow to explode after being hit by the asteroid
I am making a game for my computer science class. My professor's requirements are:
Write a Processing program that draws a triangle in the middle of the window.
Rotate the triangle when the left and ...
3
votes
3answers
112 views
Mortgage calculator for homework
I needed to create a mortgage calculator for an intro to CS class. As part of the assignment, with an interest rate of 6% needs to change to 7% after 3 years hence that ...
7
votes
3answers
266 views
Creating a chess board
One of my assignments was to create a chessboard. In this assignment I could not use an array, or a form of list or what not. Below is my code for the creation of the chessboard:
...