homework

python getting weekday from an input date.

Hi I'm trying to work on a homework problem where I have an input date in the format YYYY-MM-DD I need to import a couple modules and create a function weekday where it splits up the date and returns the weekday. So far I imported: from time import * from datetime import * I need help in my weekday function where I must use a .spl...

How to write simplest makefile for perl

I know to simply run perl in linux you do perl program.pl args . How do I make convert that for a makefile? CC=perl CFLAGS=-O0 TARGET=./problem1 OUTFILE=./log.txt $(TARGET): problem1.o $(CC) $(CFLAGS) -o $(TARGET) problem1.o problem1.o: problem1.cpp $(CC) $(CFLAGS) -c problem1.perl clean: rm -f *.o $(TARGET) $(OUTFILE) run...

Little glitch in implementing RSA algorithm

I am trying to implement the RSA algorithm, but for some reason my code below doesn't produce correct results (note that only the relevant code is shown). BigInteger n = p.multiply(q); BigInteger totient = (p.subtract(BigInteger.ONE)).multiply(q.subtract(BigInteger.ONE)); Random rand = new Random(); BigInteger e; do { e = new BigInteg...

Border around string python

Write a function spaced(s) that outputs spaces and a dashdot border around a string s. The sample code, which calls spaced("Hello") would output: --.-.-.-.- . . - Hello - . . -.-.-.-.-. Please help me out with this :D. Im new to programming and im trying to learn this stuff. I dont have any programming ...

First year prgorammer needs help with a nullpointer exception in java

As a portion of a first year assignment, I need to create a class which uses a provided linked list implementation to implement a provided stack interface which is then tested by another provided class. I was able to easily complete the assignment using my own LL; however, I was told that I needed to use the one provided. Exception in ...

Java newbie having problem with null point exception.

Trying to use StackLL method size() is returning a null pointer error. I cannot figure out why this is, as count is initialized to 0. My only guess is that I am not properly creating an instance of LinkedList.java. However, I have no idea what I should do to correct this. Any help would be greatly appreciated. The following code is a po...

Please help with my basic java implementation of Conway's game of life.

I have spent quite a while trying to write a program to implement Conway's game of life - [Link with more info.][1] . I am following some online guides and was given the majority of the functions. I wrote the "next" and "neighbours" methods shown below. Could anyone tell me if these are good implementations, and how they could be made b...

What would you change in this program? (Java)

public class Zoo{ public static void main (String[] args){ Animal animal1 = new Animal ("Giraffe", 5, 'M'); Animal animal2 = new Animal ("Lion", 10, 'F'); System.out.println (animal1.getName () + " " + animal1.getAge () + " " + animal1.getGender ()); System.out.println (animal2.getName () + " " + ani...

Error CS0563 (One of the parameters of a binary operator must be the containing type)

My source code (below) is generating Error CS0563 because both of the parameters in my CombinedJobs operator+ (see "//Step 5: ..." in source code) are listed as Job (as opposed to int, double, etc). How can I change this code to eliminate this error? This code is in response to the assignment listed below. Assignment: "Design a Job cla...

How to implement k-map for 4 bit input using Quine-McCluskey Method

I have done it till 68th slide of this file http://webdocs.cs.ualberta.ca/~amaral/courses/329/webslides/Topic5-QuineMcCluskey/Topic5-QuineMcCluskey.PPT But i don't know how to further implement it and get right answer. The problem i am facing is how i can do that. 0,1,8,9 -00- 0,2,8,10 -0-0 2,6,10,14 --10 i have ...

How to change the hex string to 4 byte in java?

I am doing a assignment about this. For Eaxmple: I have a message (String), and the length is 302 in dec, 12e in hex. String message = "THE MESSAGE BODY"; int lengthOfMessage = number.length(); // 302 String lengthOfMessageInHex = Integer.toHexString(lengthOfMessage); // 12e Now, I need to change the lengthOfMessageInHex from "12e" t...

How do I use two pipes in Unix C?

I have a homework to do that says the following: Write a program in C that creates a child who will also create a child, make a pipe between the three processes, the fist process(father) will connect the second(child) and the child will connect with the third (child of the child). Our program should display the total number of system u...

Unix C program issue using pipes and processes

Here's the story: Write a program in C that creates a child process and a granchild process (child of a child process!). The father process should read the contents of a file which name will take as an argument when you run the program. The father should send the text read to the child, which takes to convert those characters 'a' found ...

C# iterators and pointers?

I know there are no pointers in C#, but I am trying to figure out how to do the following, which I would have done with pointers (or better yet, iterators) in C++ (I am taking a course in C#, but I already know C++). We got an assignment to write a simple "store" program (inventory, transactions, etc.). My first idea (coming from C++) w...

C# quickSort with random pivot.

Hello! I am trying to modify the heapSort algorithm into version with random pivot , and I dont know what to do. Could any one help me ? This is the code: //QuickSort w C# using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace QuickSort { class Program { //Zamienia miejscami...

Simple MIPS question, about load byte

I have the following question here .data a: .asciiz "2021" x: .byte 7,2,12 .text main: addi $t2, $0, 1 lb $t3, a($t2) Can someone explain to me, HOW the value of $t3 is 48? thanks EDIT this is an another question which is similiar, and is confusing. .data a: .word 12,-5,4,0 x: .byte 5 .text main: addi $t1, $0, 8 lw $t2, a($0) lw $t3...

Compilation error in usage of templates

Hi, I have below code. template <class T> class Test { public: template<class T> void f(); //If i define function here itself, error is not reported. }; template <class T> void Test<T>::f() { } //Error here. int main() { Test<float> ob; ob.f<int>(); } It produces below error. error C2244: 'Test<T>::f' : unable t...

Maximum independent set in a tree. Review algorithm, need proof.

pseudocode: void recursive('k'){ // 'k' and 'i' vertices sumA = 0; sumB = 0; for each non visited 'i' neighbor do{ recursive('i'); sumA = sumA + b['i']; sumB = sumB + max(a['i'], b['i']); } a['k'] = 1 + sumA; b['k'] = sumB; } void main(){ a = b = 0; //initialize tables with 0 (zeros) recursive('X'); ...

My Random Number Generator isn't doing what I intended it to be

This is a school project: Objective: Ask the user to input 2 number A random number will be print to the user. Must catch if input isn't Integer. I have check online source, which i copied the code and use it. Min + (int)(Math.random() * ((Max - Min) + 1)) The code work fine except if I input any integer less than 10. The Program...

Problem with simple pipe communication in C

I have a problem with this exercise: Write a program in C that creates a child and between father and child, there will be two-way communication using pipes. His father would read a file (whose name will be given the user) and will send letters to the child. The child will count the number of words starting from with 'a'; if the number...