- Fork this repository under your own account
- Clone the forked repository to your computer
- Create a
.gitignorefile so generated files won't be committed - Commit your progress frequently and with descriptive commit messages
- All your answers and solutions should go in this repository
-
You can use any resource online, but please work individually
-
Don't just copy-paste your answers and solutions, use your own words instead
-
Don't push your work to GitHub until your mentor announces that the time is up
Write a method which takes two matrices as parameters and returns a new matrix. The method should compare each element in the input matrices and fill the returned matrix with the greater values. You only have to deal with square matrices. A square matrix is a matrix with the same number of rows and columns.
Write 2 different test cases for the method.
Input 1
[
[2, 1],
[0, 1]
]
Input 2
[
[0, 3],
[-1, 1]
]
Output
[
[2, 3],
[0, 1]
]
Input 1
[
[-1, 1, 0],
[0, 1, 0],
[0, 1, 0]
]
Input 2
[
[0, 0, 0],
[0, 1, 0],
[0, 0, 0]
]
Output
[
[0, 1, 0],
[0, 1, 0],
[0, 1, 0]
]
Write a method which can read and parse a file.
The method must take a frequency as a parameter
and collects all of the words that appear in
that amount of times in the source file.
It shall write the selected words into output.txt.
If there is no word present with the given frequency it shall not do anything.
The method must be able to handle the case if the input file name does not exists.
Example file can be found here.
Input frequency
2
The output.txt contains this line:
apple, pear, pirate
You're going to model a Zoo with animals and workers and create some interactions between them.
-
It has a name, an age, a gender and
- a
fedTimesmeaning the number of times the animal got food
- a
We should be able to create animals two ways:
-
providing
name,age,gender -
or only providing
name, whenageandgenderwill get default values1and"unknown"respectively -
It has an
eat()method which only increasesfedTimes. -
It has an
isHungry()method which returns whether the animal is currently hungry. -
It has a
toString()method which returns information about him/her in the format:- "
nameis aageyears oldgenderanimal and was fedfedTimestimes"
- "
- Lion is always hungry.
- Monkey is randomly hungry.
- Elephant is hungry in every second occasion
when a
Workerchecks on them.
-
It has a name and
- an
animalsToLookAfterlist of containing the animals that they are looking after (we should be able to change this field later on)
- an
We should be able to create workers two ways:
-
providing
name,animalsToLookAfter -
or only providing
name, when theanimalsToLookAfterlist should be an empty list
It has a doDailyRoutine() method which:
-
iterates through the worker's
animalsToLookAfterlist and feed them if it is necessary.-
first, he/she calls the specific animal's
isHungry()method -
and if it returns true, then call the animal's
eat()method.
-
- Take a look at this directory structure:
homework
|--math
| |--.git
| |--calculus
| | |--jacobian_matrix.md
| | └--exercises
| | └--week01_hw.txt
| └--geometry
| |--week01_hw.txt
| └--pithagorean_theorem.md
└--history
|--.git
|--taylor_polynomial.md
|--history_of_rome.md
└--history_of_greece.md
-
Your task is to write commands in the correct order from the directory given below.
-
Do it with less commands without chaining them together.
-
Assume that the following files are currently in the staging area:
math/calculus/jacobian_matrix.mdmath/geometry/pithagorean_theorem.md
-
Your current directory is
homework/- Create an
exercisesdirectory inmath/geometry/ - Move
geometry/week01_hw.txttomath/geometry/exercises/ - Move
history/taylor_polynomial.mdtomath/calculus/ - Remove
math/geometry/pithagorean_theorem.mdfrom the staging area - Rename
math/geometry/pithagorean_theorem.mdtomath/geometry/pythagorean_theorem.md - Commit all the changes in the
math/folder
- Create an
-
Solution:
type your answer here
1 mkdir math/geometry/ 2 mv geometry/week01_hw.txt math/geometry/exercises/ 3 mv history/taylor_polynomial.md math/calculus 4 5 mv math/geometry/pithagorean_theorem.md math/geometry/pythagorean_theorem.md 6 git add . git commit -m "reorganising files"