Assignment 3

Due Apr 10 by 1pm Points 8 Available after Feb 29 at 9am

Recent updates

22 Mar The assignment submission system, MarkUs, is available, but the online style checking is not. We will send an announcement when it is

ready.

CSC108H Assignment 3

Deadline: 10 April 2020 by 1:00pm

Late policy: There are penalties for submitting the assignment after the due date. These penalties depend on how many hours late your submission is.

Please see the syllabus on Quercus for more information.

Please do not violate the U of T Code of Student Conduct

Please do not look for extra help outside the course resources. It is disheartening. We have investigated and are interviewing more than four dozen students

in CSC108 for academic offences in Assignment 2 (although some have been delayed due to COVID-19).

The reasons we have heard are typical of what we hear every semester. They are discussions ranging from someone who had an upper-year CS friend

helping them and that person was also helping someone else too much by sharing that same code, or a roommate was stuck and so they worked together

for a bit, or they posted their code on WeChat or similar for feedback and other people copied it.

Please don’t do any of that, or read your code over the phone to your friend, or steal someone’s code, or use a tutoring service to write it with you, or have a

friend back home do most of it for you. The U of T has a Code of Student Conduct

(https://www.md.utoronto.ca/sites/default/files/Student%20Conduct%2C%20Code%20of.pdf) . It’s only 12 pages long, and describes your rights and

responsibilities related to the U our university. If you’re looking for something to do, it’s probably worth a read!

We use a program that detects similarities. It works even if you rename everything and move blocks of code around: it looks for sequences of statements

with similar structure, wherever they may be.

We have regular TA and instructor office hours and are happy to help! During lecture times, the instructor and classroom TAs are available, and we can help

you in a private voice and text chat using Blackboard Collaborate. Please come visit if you’re stuck on A3!

If you come for help, please first submit your code on MarkUs. Remember that you can submit a file as many times as you like, there is no limit! That way the

we can look at your code directly, and even share our screens with you while we discuss your issue.

If you normally rely on too much help, try to work on your own more for this assignment, and come visit office hours as many times as you like!

Introduction

In this assignment, you will write a program to analyze poetry, counting syllables and looking for rhymes.

This handout explains the problem you are to solve and the tasks you need to complete for the assignment. Please read it carefully.

Goals of this Assignment

Write function bodies using dictionaries and file reading.

Write code to mutate lists and dictionaries.

Use top down design to break a problem down into subtasks and implement helper functions to complete those tasks.

Write tests to check whether a function is correct.

Files in the download

Please download the Assignment 3 files and extract the zip archive.

Starter code:

poetry_reader.py and poetry_functions.py

These are the only files you need to modify and submit. These two files contain the headers for the functions you will need to write for this

assignment, and a few completed function docstrings. Many of these functions will be called by the main program ( poetry.py ). You can, and should,

write some helper functions in this file. Your lives will be easier if you do.

Helper module: poetry_constants .py

Read this! This file contains several definitions of new types that we use in the function type annotations.

Main Program: poetry.py

Run this first. The file contains a program that calls the functions in the starter code files. You can run it now, although it won’t work properly until you

complete the functions in the starter files. Still, you’ll be able to use this to check your progress.

Data: poetry/*.txt

In the poetry directory are several files containing poems that you can use to test your code.

Data: dictionary.txt

This file contains a huge list of English words and their pronunciations.

Data: poetry_forms.txt

This file contains information describing various poetic forms.

Checker: a3_checker.py

We have provided a checker program that you should use to check your code. See below for more information about a3_checker.py .

Poetry Forms

Poetry differs from prose because it has a fixed structure. Different forms of poetry, such as sonnets and haiku, have rules about which words must rhyme

and the number of syllables in each line.

In this assignment, you will write a program to read a poem from a file, figure out the pronunciation, count the number of syllables in each line, and determine

which lines rhyme.

Some poetry forms specify the number and order of stressed and unstressed syllables within a line. We will not consider syllabic stress in this assignment.

Some poetry forms specify that particular words must alliterate, or start with the same sound. We will not consider alliteration in this assignment.

De

# 最近案例

## MATA22 Assignment 3

MATA22 Assignment 3

Due Date: On the week March 2-6 in your own tutorials at rst 15 mins

- This question helps you understand subspace and basis

(a) Let U = f(z1; z2; z3; z4; z5) 2 C : 6z1 = z2; z3 + 2z4 + 3z5 = 0g.

Check if U is a subspace. If U is a subspace, then nd a basis

which span U.

(b) Suppose b1; b2; b3; b4 is a basis of vector space V . Prove that

b1 + b2; b2 + b3; b3 + b4; b4

is also a basis of V:

(c) Prove or disprove : there exist a basis p0; p1; p2; p3 2 P3(R) ( P3(R)

is the set of all polynomial over real number with highest possible

degree = 3 ) such that none of polynomials p0; p1; p2; p3 has degree

(d) Suppose U and W are both ve-dimensional subspaces of R9. Prove

that U \W 6= f0g: - This question helps you understand direct sum

(a) Suppose U1; U2; U3:::Un are nite-dimensional subspaces of V such

that

U1 + U2 + U3 + ::: + Un

is a direct sum. Prove that

U1 U2 U3 ::: Un

is also nite-dimensional and

dim(U1 U2 U3 ::: Un) = i=n

i=1dim(Ui):

(b) Let

Ue = ff(x) : R ! Rjf(x) = f(x)g

and

Uo = ff(x) : R ! Rjf(x) = f(x)g

i. Prove Ue; Uo are subspaces.

ii. Prove any functions f(x) : R ! R ( denote as RR ) can be

represented as sum of an even function and an odd function.

iii. Prove that

RR = Ue Uo

by using above facts.

(c) Check if the following statement is true. If it’s true, prove it. If not

, show a counter example.

fMnng = fSynng fSknng

where fSynng means the set of all n by n symmetric matrices and

fSknng means the set of all n by n skew symmetric matrices. - This question helps you understand linear map

(a) Suppose a; b 2 R: Dene T : R3 ! R2 by

T(x; y; z) = (2x 4y + 3z + b; 6x + cxyz):

i. show that T is linear map if and only if a = b = 0.

ii. Can you nd the matrix representation of T, if a = b = 0.

iii. Find the range and kernel of T, if a = b = 0.

(b) Can you give an example of an isomorphism mapping from R3 to

P2(R) ?

## CSC108H Assignment 3

# CSC108H Assignment 3

**Deadline:**Monday, December 2 @ 22:00**Resubmission with 20% deduction (optional but recommended):**Wednesday, December 4 @ 22:00

## Goals of this Assignment

- Write function bodies using dictionaries and file reading.
- Write code to mutate lists and dictionaries.
- Use top down design to break a problem down into subtasks and implement helper functions to complete those tasks.
- Write tests to check whether a function is correct.

## CSCB09 Assignment 3: Processes and Parallelism

## Introduction

This term, we’re building the components of a simple file synchronization system. In the first assignment, you wrote code for computing the hash of input from standard input, so that we can identify when files have changed. In the second assignment, you wrote code to build and traverse a file tree. Finally, in this assignment, you’ll actually implement file synchronization by copying files from a source file tree to a destination file tree. (In essence, you will be implementing the functionality of rsync without any special options.) You’ll use multiple processes to complete this work in parallel, to (hopefully) speed up the task.

## AI – Game Theory, Social Choice, and Mechanism

(Properties of voting rules.) Alice likes to analyze the outcomes of elections; specifically, she is interested in the different outcomes that different voting rules produce on the same votes. To do so, she executes many different rules on the same set of votes, a painstak- ing process. She likes knowing about properties of voting rules that ease her task. For example, she likes to know which voting rules satisfy the Condorcet criterion, so that if there is a Condorcet winner, she immediately knows that that will be the winner for

- those rules, without having to go through the trouble of executing each rule individually. Recently, Alice has become interested in the phenomenon of votes cancelling out. Let us say that a set^1 Sof votescancels out with respect to voting rule rif foreverysetT of votes, the winner^2 thatrproduces forTis the same as the winner thatrproduces forST. For example, the set of votes{a bc, bac, cab}cancels out with respect to the plurality rule: each candidate is ranked first once in this set of votes, so it has no net effect on the outcome of the election. The same set does not cancel out with respect to Borda, though, because from these votes,agets 4 points,bgets 3, andcgets 2, which may affect the outcome of the election. Alice likes to know when a set of votes cancels out with respect to a rule, so that she can just ignore these votes, easing her computation of the winner. Define a pair ofopposite votesto be a pair of votes with completely opposite rankings of the candidates, i.e. the votes can be written asc 1 c 2 .. .cm andcm cm 1 .. .c 1. Let us say that a voting rulersatisfies the Opposites Cancel Out (OCO)criterion if every pair of opposite votes cancels out with respect tor.

(^1) Technically, a multiset, since the same vote may occur multiple times. (^2) … or set of winners if there are ties.

1a. (12 points)From among the (reasonable^3 ) voting rules discussed in class, give 3 voting rules that satisfy the OCO criterion, and 3 that do not (and say which ones are which!).

```
Define acycleof votes to be a set of votes that can be written asc 1 c 2
```

.. .cm, c 2 c 3 … cmc 1 , c 3 c 4 .. .cmc 1 c 2 ,… , cmc 1 c 2 .. .cm 1. Let us say that a voting rulersatisfies theCycles Cancel Out (CCO)criterion if every cycle cancels out with respect tor.

1b. (12 points)From among the (reasonable) voting rules discussed in class, give 3 voting rules that satisfy the CCO criterion, and 3 that do not.

Define a pair ofopposite cyclesof votes to be a cycle, plus all the opposite votes of votes in that cycle. Note that these opposite votes themselves constitute a cycle, the opposite of which is the original cycle. Let us say that a voting rule rsatisfies theOpposite Cycles Cancel Out (OCCO)criterion if every pair of opposite cycles cancels out with respect tor.

1c. (12 points)From among the (reasonable) voting rules discussed in class, give 5 voting rules that satisfy the OCCO criterion, and 1 that does not.

1d. (14 points)CriterionC 1 isstrongerthan criterionC 2 if every rule that satisfiesC 1 also satisfiesC 2. Two criteria areincomparableif neither is stronger than the other. For every pair of criteria among OCO, CCO, and OCCO, say which one is stronger (or that they are incomparable).

- (A multi-unit auction with externalities.) We are running a multi-unit auction for badminton rackets in the town Externa, where nobody owns one yet and we are the only supplier. Of course, being the only person to own a badminton racket is no fun; bidders care about which other bidders win rackets as well. In such a setting, where bidders care about what other bidders win, we say that there areexternalities. Let us assume that each agent is awarded at most one racket, and that shuttlecocks and nets are freely available. In the most general bidding language for this setting, each bidder would specify, for every subset of the agents, what her value would be if exactly the agents in that subset won rackets. This is impractical because there are exponentially many subsets. Instead, we will consider more restricted bidding languages. Let us suppose that it is commonly known which agents live close enough to each other that they could play badminton together. This can be represented as a graph, which has an edge between two agents if and only if they live close enough to each other to play together. In the first bidding language, every agentisubmits a single valuevi. The semantics of this are as follows. If the agent does not win a racket, her utility is 0 regardless of who else wins a racket. If she does win a racket, her value is vtimes the number of her neighbors that also win a racket.

(^3) E.g., not dictatorial rules, rules for which there is a candidate that cant possibly win, randomized rules, etc. Also, approval cannot be one of the rules because it is not based on rankings. If you use Cup, Cup only satisfies a criterion if it satisfies it for every way of pairing the candidates.

```
Alice
```

```
Bob
```

```
Carol Daniel
```

```
Eva
```

```
Frank
```

```
Figure 1: Externas proximity graph.
```

```
Suppose we receive the following bids:
```

```
Alice
```

```
Bob
```

```
Carol Daniel
```

```
Eva
```

```
Frank
```

```
4
```

```
4
```

(^25) 5 4 Figure 2: Graph with bids. The number next to an agent is that agents bid. Suppose we have three rackets for sale. One valid (but not optimal) allo- cation would be to give rackets to Carol, Daniel, and Eva. Carol would get a (reported) utility of 2, Daniel would get 10 (25, because two of Daniels neighbors have rackets), and Eva 5, for a total of 17. 2a. (12 points)Give the optimal allocation, as well as the VCG (Clarke) payment for each agent. 2b. (13 points)In general (general graphs, bids, numbers of rackets), is the problem of finding the optimal allocation solvable in polynomial time, or NP-hard? (Hint: think about theCliqueproblem (which is almost the same as theIndependent Setproblem).) One year has passed, and we have returned to Externa. Everyones rackets have broken (we are not in the business of selling high-quality rackets here) and they need new ones. However, the people in the town were not entirely happy with our previous system. Specifically, it turned out that each agent only ever played with (at most) a single other agent, so that multiplying the value by the number of neighbors with rackets really made no sense. Also, agents have realized that they would receive different utilities for playing with different agents. In the new system, we must not only decide on who receives rackets, but (for the agents who win rackets) we must also decide on the pairing, i.e.,who plays with whom. Each agent can be paired with at most one other agent. Each agentisubmits a valuevijfor every one of her neighborsj; agentireceivesvij if she is paired withj(and both win rackets), and 0 otherwise. Suppose we receive the following bids:

```
Alice
```

```
Bob
```

```
Carol Daniel
```

```
Frank
```

(^12) 4 3 2 1 4 Eva 5 5 6 1 5 Figure 3: Graph with bids. Each number is the value that the closer agent on the edge has for playing with the further agent on the edge. Suppose we have four rackets for sale. One valid (but not optimal) outcome would be to pair Alice and Bob, and Daniel and Eva (and give them all rackets), for a total utility of 4 + 1 + 1 + 6 = 12. 2c. (12 points)Give the optimal outcome (pairing and allocation), as well as the VCG (Clarke) payment for each agent. 2d. (13 points)In general (general graphs, bids, numbers of rackets), is the problem of finding the optimal outcome solvable in polynomial time, or NP- hard? (Hint: think about theMaximum-Weighted-Matchingproblem. Keep in mind that the number of rackets is limited, though.)

## CSCI-UA.0480-11: Intro to Computer Security Homework 1

CSCI-UA.0480-11: Intro to Computer Security Spring 2019

Homework 1

via classes.nyu.edu1. Threat modeling: Imagine you’ve just been hired to produce a comprehensive threat model for

CitiBike , New York’s public bike share system. Describe three security policies, and for each of

them describe a technical mechanism to enforce those policies. Choose one policy each that

deals with a threat from thieves (financially motivated attackers), terrorists (attackers aiming to

cause violent disruption) and trolls (attackers trying to cause inconvenience or annoyance).

2. Hash functions : In class we discussed several desirable properties for hash functions, in

particular one-wayness and collision-resistance . In this exercise, we’ll show that neither property

implies the other. We can do this by counter-example:

继续阅读“CSCI-UA.0480-11: Intro to Computer Security Homework 1”

## Assignment 1: Command Line Arguments and Pointers

## Introduction

Over the course of the four assignments in this course you will implement different components of a simple file synchronization system. For examples, take a look at rsync or consider the services provided by OneDrive, Dropbox, Google Drive, or Box. The components you’ll be asked to build could also form the basis for a version control system like svn or git. In this, assignment, you’ll be writing a program to compute hash values for files.

## ASSIGNMENT #3 CS246, SPRING 2019

ASSIGNMENT #3 CS246, SPRING 2019

Assignment #3

Questions 1a, 2a, and 3a are due on Due Date 1; Question 1b, 2b, and 3b are due on Due Date 2.

On this and subsequent assignments, you will take responsibility for your own testing. This assignment is

designed to get you into the habit of thinking about testing before you start writing your program. If you

look at the deliverables and their due dates, you will notice that there is no C++ code due on Due Date 1.

Instead, you will be asked to submit test suites for C++ programs that you will later submit by Due Date 2.

Test suites will be in a format compatible with that of the latter questions of Assignment 1, so if you did a

good job writing your runSuite script, that experience will serve you well here.

Design your test suites with care; they are your primary tool for verifying the correctness of your code. Note

that test suite submission zip files are restricted to contain a maximum of 40 tests, and the size of each file

is also restricted to 300 bytes; this is to encourage you not combine all of your testing eggs in one basket.

You must use the standard C++ I/O streaming and memory management (MM) facilities on this assignment;

you may not use C-style I/O or MM. More concretely, you may #include the following C++ libraries

## Homework Problem Set 5 MATH 8

Homework Problem Set 5

MATH 8

Problem 1: Prove the general Triangle Inequality for any n 2 N and for any real numbers

a1; a2; : : : ; an 2 R:

Xn

i=1

ai

继续阅读“Homework Problem Set 5 MATH 8”

## EECS 281: Data Structures and Algorithms

EECS 281: Data Structures and Algorithms

Lab 10 Assignment

Q1 What kind of algorithms are Prim’s and Kruskal’s? (0.5 pts)

A. brute force

B. greedy

C. divide and conquer

D. branch and bound

E. none of the above 继续阅读“EECS 281: Data Structures and Algorithms”