homework

The perverse hangman problem

Perverse Hangman is a game played much like regular Hangman with one important difference: The winning word is determined dynamically by the house depending on what letters have been guessed. For example, say you have the board _ A I L and 12 remaining guesses. Because there are 13 different words ending in AIL (bail, fail, hail, jail, ...

Help with basic Java concepts

A. Describe what happens the variables ‘a’ and ‘x’ during the execution of the ‘main’ and ‘add1’ methods in the class below. Clearly specify which are the formal and actual parameters when the ‘add1’ method is called. public class Variables { public static void add1(int a) { a = a + 1; System.out.println("a = " + a)...

convert integer to array, c++

I would like to convert an integer into an array, so that it looks like the following: int number = 123456 ; int array[7] ; with the result: array[0] = 1 array[1] = 2 ... array[6] = 6 ...

Trouble with Calendar homework in C

I am writing a program that get month and year from the user, and then print out the calendar. But the calendar is only correct in January (every two years). How do I make the other months correct? What am I doing wrong? #include "stdafx.h" void printMonth (int* startDay, int* days); int _tmain(int argc, _TCHAR* argv[]) { int s...

Hamiltonian circuit .

what is the Big-o complexity of finding a Hamiltonian circuit in a given order Markov chain using DFS? ...

Is it possible to define multiple classes in just one .cpp file?

I'm working on a project for school and the instructor insists that all code go into one .cpp file (for easier grading on his part). I would like to define multiple classes within this file. Will I run into any problems in doing this? ...

EDA search space

I am supposed to demonstrate that the Estimation of Distribution Algorithm's (EDA) search space shrinks exponentially fast if learning in iteration t produces P'(X) = P^(G(t)) (X) with G(t) = arg max {F(x)} Regardless of the problem or type of x. P = population n = population size = infinite Could you give me some starting point...

Error making C++ functions virtual

The error states: "error: virtual outside class definition" Cpp members in question: virtual void Account::creditBalance(double plus) { if(plus > 0) balance += plus; else cout << "Cannot credit negative."; } virtual void Account::debitBalance(double minus) { if(minus <= balance) balance -= minus; else ...

Python elevator simulation problem

I have a homework assignment that's really baking my noodle. It involves an elevator simulation that takes user inputs for the number of floors and the number of people using the elevator. the people's starting floor and destination floors are random numbers within the floors. I realize that my code is very sparse and that there's qui...

Digital Filter Design Matlab sptool/fdatool

What is the best method for selecting design properties for a digital filter in Matlab with the GUI sptool? More specifically, if I have a signal, how do I go about determining which filter values will yield the best solution. Example: For my signal A: One possible filter could have properties: Design Method: FIR, Window Window T...

Creating a Squircle

Hello there. I'm a first year programmer. I'm trying to create a squircle. (square with round corners). So far i have managed to get. I have been given the constants of a,b and r. If anyone could help i would be really thankful. I'm a total noob to this. So be nice :) package squircle; import java.awt.*; import javax.swing.*; import ...

How do I convert an array of strings to a array of unique values?

In Java, how do I convert an array of strings to a array of unique values? If I have this array of Strings: String[] test = {"1","1","1","2"} And I want to end up with: String[] uq = {"1","2"} ...

Sorting 2D arrays in C/C++ in increasing values; knowing the original positon after sorting ?

I have already written a program that sorts a 2D array in increasing values. Here is my input and output. Input: Array2D[0][0] = 99 Array2D[0][1] = 10 Array2D[0][2] = 97 Array2D[0][3] = 10 Array2D[0][4] = 14 Array2D[1][0] = 73 Array2D[1][1] = 53 Array2D[1][2] = 81 Array2D[1][3] = 22 Array2D[1][4] = 88 Output: Array2D[0][0]...

Help with Vector.size() in Java

I'm implementing a Graph which holds "Book" objects as its nodes. The nodes are connected if the books share a keyword. The keywords for each book are held in a Vector within the Book class. To do this, I've created 3 classes. 1) Books 2) Vertex 3) Graph The Vertex class holds the Book object and also has a Vector containing all the ot...

Why doesn't my exam mark averaging code work?

I'm trying to get the program to let me enter a users name and then a mark and display the average. This is what I've tried: // Calculate Students Average of series of exam marks stored in an array import uulib.GUI; public class ExamMarks { public static void main(String[] args) { final int SIZE = 10; int[] marks = new int...

How to refresh the form value using JQuery

I have a html form. I want to take the input value (a url), extract a number from the url using regex ( '/[0-9]{5,}/') , and then refresh the form value with the number extracted and appended to another url. If I can't find a number - I just want an error to appear in the form box. All using Jquery to avoid page reload. This is the ex...

BufferedReader problem in Java

Hello, me and my buddy are working on a program for our Object Oriented Programming course at college. We are trying to write text into a file as a database for information. The problem is that when we try to read the corresponding lines with BufferedReader we can't seem to figure out how to read the correct lines. The only functions ava...

Homework: Lisp items that appear more than once in a list

Given a list, I'm trying to return a new one that has only the items that appear more than once in the first list I receive as a parameter. I have done the following: (defun myf (lista) (if (endp lista) nil (if (member (first lista) (rest lista)) (append (list (first lista)) (myf (rest lista))) (myf (r...

Conway's Life: Iterate over a closed universe in Python

Hi, I have just started learning Python, and I'm trying to write a program for Conway's Game of Life. I'm trying to create a closed universe with boundary conditions(which are the opposite side/corner). I think I have done this, but I'm not iterating over the loop when it runs, and can't work out how to do this. Thanks very much in advan...

Accessing functions from within a Javascript Object (Javascript).

I am attempting to create a basic Hangman program. It's an array of tags which are assigned into an array of Objects (called Buttons). Each image is an image of a letter, so for example you would press the 'L' button, it would check whether this was in an WordArray (which is an array of chars), then it would act accordingly (to hide the...