Description
Ex0. A fun bash game BashCrawl (not mandatory)
A fun game that helps you get famaliar with Linux command.
The game is attached in the files. See /bashcrawl . It has its README.It will be uploaded on Gitea soon. Have fun.
Ex1. Hiding Photos
Related Topics: Linux.
Kyon is thinking of moving his favourite Mikuru’s photos from SOS Quantum Library sql/ to his own webserver webserver/ without being noticed.
“If Haruhi knows this, Haruhi will destory the world. We have to avoid this”.
Create: create the working directory of the database and webserver, and initialize the database;
Dump: dump the data in the database into the webserver;
List: list all the files stored in the webserver;
Display: display the data in the webserver;
Destroy: remove the working directory of database and webserver.
He has already implemented the skeleton of ex1.sh , but now he . There are 5 of such lines in the script that are marked as TODO comments:
1 # TODO: Replace this line with a linux command line.
Please help him finish this script by replacing the TODO s with a Linux command line you learned from lecture.
1. Create a directory named sql/ .
2. Copy the file sql/database.txt to the directory webserver/ 3. List all files in directory webserver/ .
4. Display webserver/database.txt in stdout .
5. Remove the webserver/ and sql/ directories.
Testing
To test the script, please first make it executable by running:
Then, you can test the script by running the following commands and observe the results.
Ex2. Validating Password
Related Topics: loops, arrays, boolean, ASCII.
Miyamori Aoi is designing the wbsite for Musani Animation. When designing the register page, she plans to Write a function that checks whether the password that the user type in meets all the requirements below (or say it is valid):
Contains at least 1 alphabetic characters;
Contains at least 1 numerical characters; Contains at least 1 non-alphanumeric characters. The max length of a password is 50 characters.
The function takes a password (an array of chars) as input, returns true if the password is valid and returns false if not.
Miyamori is busy with their new animation. Please help her implement the function.
Note: In fact, when writing a web page, we use Regular Expression to validate whether a password meets our requirement. We do not use C++ but we use JavaScript for web programming. For those interested, you can Google it yourself.
Example
Example input:
Example output:
Ex3. Flipping an image
Related Topics: loops, arrays
Description
Here our topic is about the principle behind image processing software, like how to flip an image horizontally and invert it.
Like
Will result in
Of course this image will be too complicated for us to handle here. Let’s simplify the problem.
We are given a binary matrix as a simple image.
To flip an image horizontally means that each row of the image is reversed.
For example, flipping [1,1,0] horizontally results in [0,1,1] .
To invert an image means that each 0 is replaced by 1 , and each 1 is replaced by 0 .
For example, inverting [1,0,1] results in [0,1,0]
TODO
Just modify on the image. There is no need to return a new image here.
Input
The first line contains a number n , which is the size of the matrix image .
The following lines represents the matrix, which only contains 0 or 1 . Each row separated by a and each column separated by space.
Output
The flipped and inverted matrix
Example
Example input:
Example output:
Explantion:
First flip horizontally
Then invert it
Reviews
There are no reviews yet.