/* I been trying to solve this problem . this is my own coding
/here is the HW INSTRUCTION
Let the user to try of maximum 8 times to find the random number
For every try display if the user find or not the number and the number of tries
At the end of each game display to the user the number of tries to find the number
Allow the user to play a maximum of 4 times, by asking him at the end of the game if he want to play again
<> “Do you want to play again (Yes/No)?
At the end of all games, display for each game the average of number of tries to find the random numbers, as follows:
int n = console.nextInt();
Game No Game 1 Game 2 Game 3 Game 4
Number of tries 5
3
8
8
Result Success Success Fail Success*/
//WHAT I'M STUCK AT IS HOW CAN I POSSIBLY FUNCTION THE GAME FOR SECOND TIME CORRECTLY WHILE KEEPING //CORRECT COUNTING FOR ATTEMPTS AND LIVES
import java.util.Scanner;
import java.util.Random;
public class inputLap
{
public static char roller;public static String playerName; public static int rounds=8,lives=0,randy;
public static String getName(String aString)
{Scanner sc= new Scanner(System.in);
System.out.println("enter player's Name:");aString=sc.next();
playerName=aString;
return playerName;
}
public static char menu()
{Scanner sc= new Scanner(System.in);
if(lives<=4&&rounds>0){
System.out.println("Do you want to continue?(y/Y):\n (x/X) to exit. ");roller=sc.next().charAt(0);
}
return roller;
}
public static int getGame() {
Scanner sc = new Scanner(System.in);
System.out.println("make a guess from 1-20");
int Guessed = sc.nextInt();
return Guessed;
}
public static void main(String[] args) {
getName(playerName); Random r = new Random();
int answer;
do {randy=r.nextInt(20);
answer=getGame();
rounds--;
if(rounds==7&&rounds>0)
{rounds--;
for (int i=0;i<=6;i++)
{
answer=getGame();
if(answer==randy)
{lives++;
System.out.println("congratulation you are right");break;
}
else
{System.out.println("you have "+(rounds+1
)+" remaining");}
switch(rounds){case 0:while(lives!=4){System.out.println("hard luck\nyou have"+(lives-4)+"lives left");
break; }break;}
}
}else if(answer==randy){lives++;System.out.println("congratulation you are right");}
menu();
switch( roller)
{
case 'y':
case 'Y':rounds=8;getGame();answer=getGame();break;
case'x':
case 'X':
lives=5;
System.out.println("bye bye "+playerName+" !!");
break;
}
} while(lives<=4);
}
}
In: Computer Science
Regular => Context-Free
Give a proof by induction on regular expressions that:
For any language A, if A is regular, then A is also context-free.
You may assume that the statements from the previous Closure under Context-Free Languages problem are proved.
R is a regular expression if RR is:
a for some a∈alphabet Σ,
the empty string ε,
the empty set ∅,
R1∪R2, sometimes written R1∣R2, where R1 and R2 are regular expressions,
R1∘R2, sometimes written R1R2, where R1 and R2 are regular expressions,
R1∗, where R1 is a regular expression.
Closure under Context-Free Languages
union
concatentation
Kleene star
In: Computer Science
This task exercises your ability to use python to represent data and use flow control and functions to re-organize the data. You need to submit the ipynb file to Moodle.
A data scientist has collected tube information and saved the video info in multiple CSV files. Each CSV file has the following columns:
· video_id
· trending_date
· title
· channel_title
· category_id
· publish_time
· tags
· views
· likes
· dislikes
· comment_count
· thumbnail_link
· comments_disabled
· ratings_disabled
· video_error_or_removed
· description
You are asked to write python code to process CSV data files. You can only use collections, numpy, and CSV modules. The task needs you to solve 6 problems as listed below. Use the template ipynb file to complete your code. For each question, your code should output an answer CSV file, so that the results can be viewed with MS Excel. Use one cell for each question. After running the 6 cells one after another, your solution should output 6 answer CSV files. The answer files must be named as “question1.csv”, “question2.csv”, … , “question6.csv”. Write documentation in your code. Add comments to explain key steps.
2 visible test cases are provided to you. Each has an input.csv file and the corresponding answer files.
Your code will be tested with multiple hidden test cases (HTCs). For each HTC video file, your code should generate the corresponding answers in 6 answer CSV files. The HTCs are similar to the given test cases. You can assume that HTC video files have all the above-mentioned columns. For each column, HTCs have the same value type and ranges. For example, HTC video files have the column “likes” and “dislikes”, with all values being non-negative integers. You don’t have to consider missing values or non-standard values (e.g. “117394” is never saved as “117,394”). The cells in your solution will be executed one after another.
Question 6:
Show all categories with at least 10 videos. For each category, show the category name, number of videos, videoId with the highest views (if same, print the one that appears first in the CSV), average comment count, number of videos disabled comments, and a list of unique channels that published videos in the category (in ascending order alphabetically. separated by '|'). Save the results in the descending order of video count.
Convert the category id to the actual category name. Since different countries have different category id encoding, your code should allow dynamically convert the category id to the category name. That means your code must directly read the categories from the category_id.txt file. Do not hard coding the categories in your code.
The output file should have the following headers:
category_name |
video_count |
most_popular_video |
average_comment |
disable_comment_count |
channels |
I just need help with the last question, question 6.
In: Computer Science
Please explain this code line by line
void printperm(int *A,int n,int rem,int j)
{
if(n==1)
{
for(int k=0;k<j;k++)
cout<<A[k]<<" +
";
cout<<rem<<"\n";
return;
}
for(int i=0;i<=rem;i++)
{
if(i<=rem)
A[j]=i;
printperm(A,n-1,rem-i,j+1);
}
}
In: Computer Science
6. What does the XXXXX need to be replaced with to trigger the function in the following code when the submit button is pressed:
<form XXXXX="submitIt()"> Enter name: <input type="text"> <input type="submit"> </form>
<input type="number" name="quantity" >
Rewrite the HTML code above using the required attribute to let the input accept only a number from 1 to 20.
Country code: <input type="text" name="country_code" XXXXXX="[A-Za-z]{3}" title="Three letter country code">
Rewrite the HTML code above substituting XXXXX with the attribute name that lets the input accept only 3 alphabetic characters:
Username: <input type="text" name="usrname" XXXXX>
Rewrite the HTML code above substituting XXXXX with the attribute name that tells the Web page to check the presence of a value before the HTML form can be submitted:
Country <input type="text" name="country" value="USA" XXXXX>
Rewrite the HTML code above substituting XXXXX with the attribute name that prevents user from typing data into the text input:
<script> function myFunction() { var inpObj = document.getElementById("id1"); if (!inpObj.XXX()) { document.getElementById("demo").innerHTML = inpObj.validationMessage; } else { document.getElementById("demo").innerHTML = "Input OK"; } } </script> <p>Enter a number and click OK:</p> <input id="id1" type="number" min="100" max="300" required> <button onclick="myFunction()">OK</button> <p>If the number is less than 100 or greater than 300, an error message will be displayed.</p> <p id="demo"></p>
function validateForm() { var x = document.forms["myForm"]["fname"].value; if (XXX) { alert("Name must be filled out"); return false; }
}
<p id="demo"></p> <script> ????? = "Hello"; </script>
In: Computer Science
An advisory practice was the target of an attack, whereby the malware allowed the fraudster to gain access to an adviser’s login details for all systems he had used recently. The fraudster now had access to every website or account that required a login. This included personal banking, platform desktop software, Xplan software and Facebook. The next time the adviser tried to log in to his platform desktop software, he was locked out. He rang our account executive team to report his access was locked. He couldn’t login, even though he was using his correct user name and password. The platform reset his password. The next day when the adviser tried again to login, he was locked out of the system again. It became obvious that the adviser’s user ID had been compromised. At this point, the user ID was deleted.
1. Identify and explain the malware attack experienced in the above scenario [5 Marks]
2. What recommendations would you provide for preventing such type of attacks? The recommendations should be discussed individually for the scenario and should not be a general list of recommendations [5 Marks]
In: Computer Science
C program simple version of blackjack following this design.
1. The basic rules of game
A deck of poker cards are used. For simplicity, we have
unlimited number of cards, so we can generate a random card without
considering which cards have already dealt. The game here is to
play as a player against the computer (the dealer). The aim of the
game is to accumulate a higher total of points than the dealer’s,
but without going over 21. The cards 2 to 10 have their face values
as points. J, Q, and K are10 points each, and the Ace is either 1
point or 11 points (player's choice). To simplify the matter, we
consider that the Ace is 11 points and we don’t have card J, Q, or
K unless you like to implement the option anyway.
a) Betting
The player first places a bet. Let’s assume the minimum bet is $10
and maximum = is $1000.
b) Each play will result in one of the following events for the player
c) The start of the game
At the start, the player and the dealer receive two cards each. The
player’s cards are normally dealt face up (displayed), while the
dealer has one face down (called the hole card) and one face up.
The best possible blackjack hand is an opening deal of an Ace with
any of the ten-point cards. This is called a "blackjack", or a
natural 21, and the player holding this automatically wins unless
the dealer also has a blackjack. If a player and the dealer each
have a blackjack, the result is a push.
d) The player’s turn
The player can keep his hand as it is (stand) or take more cards
from the deck (hit), one at a time, until either the player judges
that the hand is strong enough to go up against the dealer’s hand
and stands, or until it goes over 21, in which case the player
immediately loses (busted).
e) The dealer’s turn
The dealer turns over the hidden hole card. The dealer hits (takes more cards) or stands depending on the value of the hand. The dealer must hit if the value of the hand is lower than 17, otherwise the dealer stands.
If the dealer is busted, the player wins. Otherwise the player wins
if s/he has a higher score, loses if s/he has a lower score, or
pushes if s/he has the same score as the dealer.
Blackjack consideration is not required, unless you like to implement the option anyway. By the way, a blackjack hand beats any other hand, also those with a total value of 21 but with more cards (which is not a natural blackjack).
f) The program towards the
end
If the player won or lost, s/he must decide whether to quit or to
play another game unless the player runs out of money. Your program
should give the player an initial betting amount of $1000.00.
2. The specific design of this project
a) The main() program and its variables
You will need to decide on appropriate variables in which to store
the player's bankroll (in order to keep track of how much money or
how many points the player has), the bet at a game, and other
information. Let’s use an integer array gamerecord[] to store how
many times the player won, lost, hit a blackjack, and got busted.
(Again, blackjack is optional).
The bankroll, bet, and gamerecord[] should be kept up to date on
the player's current status. (The program calls playing() to play a
game, as discussed below. )
After each game, the program must report the result of the game:
the amount of money won or lost, the current value of the bankroll,
how many times the player won and lost, and how many times the
player hit a blackjack and got busted. (You may want to record and
report how many times the dealer got busted as well, as an
option.)
After each game (by calling playing()), the program should allow the player to continue playing until s/he chooses to quit, or until s/he runs out of money. This central program control may be done within main(), in a do-while loop: 1) call playing() to play a game; 2) check whether to play again. We will add some more components later.
b) “Dealing” the card: the dealing() function
A separate dealing() function will be used to
generate a card number. You may want to implement and double check
this function first. You will use a random number generator. The
random number generator needs to be seeded with the current time at
the beginning of the main program. The possible random values
generated are 1 to 10 (or 13 if J, Q, and K are considered),
representing the cards’ face values. This function will return the
number generated. The return value 1 represent the Ace’s face value
(and the return value 11, 12, and 13 are J, Q, and K’s face value,
respectively.) A large random number n can be converted to
a value between 1 to 13 by: (1 + n%13).
c) “Playing” the game: playing() function
A second function playing() will be used to play a
single game until the player either wins or loses a bet, based upon
the rules given above. This function should get a bet, modify the
current amount of the player's bank roll according to the game
result, modify the gamerecord array values of the player won or
lost, and the player hit the blackjack or got
busted. These values are returned through function
parameters by address passing in playing().
Within the function, the player is asked to place a bet (10 to 1000
within the bankroll amount), so the corresponding value is read
from the keyboard. The system (dealer) then "deals the cards"
(simulated by calling the function dealing(), one card at a time).
After each dealing, this function should report the card values,
except the dealer’s hole card. The function should have two
variables to store the player and the dealer’s scores. Remember
face value 1 represents score 11 (or 1 if you want to be more
complete as an option, and 11, 12, or 13 represents score 10).
The player can keep his hand as it is (stand) or take more cards
from the deck (hit), one at a time, until either the player judges
that the hand is strong enough to go up against the dealer's hand
and stands, or until it goes over 21, in which case the player
immediately loses the bet.
The dealer turns over his hidden hole card by displaying the hold
card face value, and starts the game process automatically until
the dealer wins or loses.
d) "Ending" and "Beginning" of the game
This part is implemented after you have done your programming as
described above already.
You need a separate function ending() to do the following: you should report the current value of the bank roll, how many times the player won, lost, hit a blackjack, and went busted. You need to save the above information into a text file as well.
You need a separate function beginning() to do the
following at the beginning of your program in main(): the function
will open the text file you used to save the game information for
reading if it exists, so that your game can continue from previous
played results. If the file does not exist or the bank roll has a
balance below the minimum bet, you start the game from scratch as
usual, and report “new game” or “continual game”.
So, main() includes 1) beginning(); 2) a loop: playing(); 3) ending();
In: Computer Science
Write a function that takes an Array of cases, as well as an FSA String value.
This Case data is an Array where each item in the Array is a
custom Case Object. The Array is really [case1, case2, case3, ...],
and each Case Object has the following structure:
{
"Age Group": "40 to 49 Years",
"Neighbourhood Name": "Annex",
"Outcome": "RESOLVED",
"Client Gender": "FEMALE",
"Classification": "CONFIRMED",
"FSA": "M5R",
"Currently Hospitalized": "No",
"Episode Date": "2020-09-12",
"Assigned_ID": 17712,
"Outbreak Associated":
"Sporadic",
"Ever Intubated": "No",
"Reported Date": "2020-09-16",
"Currently in ICU": "No",
"Source of Infection":
"Healthcare",
"_id": 161028,
"Ever in ICU": "No",
"Ever Hospitalized": "No",
"Currently Intubated":
"No"
}
An FSA if a forward sortation area (the first 3 characters in a
Canadian postal code):
https://en.wikipedia.org/wiki/Postal_codes_in_Canada#Forward_sortation_areas
Return a new Array with only those case Objects that contain the
given fsa value.
You should support the FSA value being CAPITALIZED or lowercase, as
well as deal with any case Objects that don't have an FSA value
(e.g., null/undefined)
In your solution, make use of the following:
- create an empty array
- use a for...of loop to loop over all Objects in cases
- if a case includes the given fsa, add the case Object
to the empty Array
Your function should return the newly created Array.
function getCasesByFSA(cases, fsa) {}
In: Computer Science
1. Provide a scenario depicting a man-in-the-middle attack.
2. What will always be the weakest link in any security implementation? Why?
3. Define the method and purpose of social engineering.
In: Computer Science
Assignment; For this component, you will write a report or critique on the paper you chose from Assignment 1. Your report should be limited to approx. 1500 words (not including references).
Use 1.5 spacing with a 12 point Times New Roman font. Though your paper will largely be based on the chosen article, you should use other sources to support your discussion or the chosen papers premises.
Citation of sources is mandatory and must be in the IEEE style.
TOPIC: Social Engineering and phishing attacks
Your report or critique must include: Introduction: Identification of the paper you are critiquing/ reviewing, a statement of the purpose for your report and a brief outline of how you will discuss the selected article (one or two paragraphs).
Body of Report: Describe the intention and content of the article. If it is a research report, discuss the research method (survey, case study, observation, experiment, or other method) and findings. Comment on problems or issues highlighted by the authors. Report on results discussed and discuss the conclusions of the article and how they are relevant to the topics of this Unit of Study.
3 Conclusion: A summary of the points you have made in the body of the paper. The conclusion should not introduce any ‘new’ material that was not discussed in the body of the paper. (One or two paragraphs) References: A list of sources used in your text. They should be listed alphabetically by (first) author’s family name. Follow the IEEE style.
In: Computer Science
Using a spreadsheet (such as Excel) or a calculator, perform the
operations described
below. Document results of all intermediate modular
multiplications. Determine
a number of modular multiplications per each major transformation
(such as
encryption, decryption, primality testing, etc.).
a. Test all odd numbers in the range from 223 to 229 for primality
using the
Miller-Rabin test with base 2.
b. Encrypt the message block M= 7 using RSA with the following
parameters: e
= 17 and n = 223 *229.
c. Compute a private key (d, p, q) corresponding to the given above
public key
(e, n).
d. Perform the decryption of the obtained ciphertext
e. By using the private/public key from above, perform the digital
signature for
a small message contain your names +IDs
(ikhlas_80860_iman_80571_elyas_79829). You should
perform the digital
signature by using RSA signature algorithm, and by using Digital
signature
standard (DSS).
f. Verify the signatures.
Note: for performing the signature, you can take the first byte of
the hash output.
In: Computer Science
The notation used in the above problem is called symbolic notation. Alternatively, we can use the 4-digit octal notation to specify, which is defined as follows: • Digits from left (most significant) to right (least significant): [special bits][owner bits][group bits][world bits] • Special bit digit = (4 if setuid) + (2 if setgid) + (1 if sticky), 0 for none of them • All other digits = (4 if readable) + (2 if writable) + (1 if executable), 0 for none of them For example, if no special bit is set on, the first digit should be a zero (i.e., “special bits”=0). For the owner bits, if the owner has read and write privileges, then the second digit should be (4 if readable) + (2 if writable) = 6 (i.e., “owner bits”=6). If group and world have no privilege, they will have a zero each, and the third and fourth digits should be 0 and 0, respectively (i.e., “group bits”=0 and “world bits”=0). The converted representation should then be “0600”. One of the useful resources for this representation is: https://en.wikipedia.org/wiki/File_system_permissions.
Convert each of the symbolic permissions to octal notation and each of the octal permissions to symbolic notation. a. -rw-r--r-- b. -rwxr-xr-x c. 0400 d. 1777 e. 4755
In: Computer Science
Part I: transformCase(original) and
transformCases(cases)
*
* Write functions to transform COVID case data into a new Object
format.
*
* The `transformCase(original)` function takes an Object like
so:
*
* {
* "Age Group": "20 to 29 Years",
* "Neighbourhood Name": "Humewood-Cedarvale",
* "Outcome": "ACTIVE",
* "Client Gender": "FEMALE",
* "Classification": "CONFIRMED",
* "FSA": "M6C",
* "Currently Hospitalized": "No",
* "Episode Date": "2020-09-11",
* "Assigned_ID": 17704,
* "Outbreak Associated": "Sporadic",
* "Ever Intubated": "No",
* "Reported Date": "2020-09-18",
* "Currently in ICU": "No",
* "Source of Infection": "Close contact",
* "_id": 161020,
* "Ever in ICU": "No",
* "Ever Hospitalized": "No",
* "Currently Intubated": "No"
* },
*
* And transforms the data in the `original` case Object into a new
Object
* that looks like this (see comments on right-hand side with
details):
*
* {
* id: 161020, // rename _id to id
* isActive: true, // true if Outcome is "ACTIVE", false
otherwise
* neighbourhood: "Humewood-Cedarvale", // rename Neighbourhood Name
to neighbourhood
* hospitalInfo: {
* current: {
* hospitalized: false, // true if Currently Hospitalized is Yes,
false otherwise
* inICU: false // true if Currently In ICU is Yes, false
otherwise
* intubated: false, // true if Currently Intubated is Yes, false
otherwise
* },
* historical: {
* hospitalized: false, // true if Ever Hospitalized is Yes, false
otherwise
* inICU: false // true if Ever In ICU is Yes, false otherwise
* intubated: false, // true if Ever Intubated is Yes, false
otherwise
* }
* }
* }
******************************************************************************/
function transformCase(original) {}
/*******************************************************************************
Part II: transformCases(cases) with
iteration
*
* The `transformCases(cases)` (NOTE: transformCase singular vs.
transformCases plural)
* takes an Array of case Objects, and returns a new Array of
transformed Objects,
* calling transformCase() on each.
*
* In your solution, make use of the following:
*
* - create a new empty Array to hold all the transformed
cases
* - use a for-loop or .forEach() method to loop over all Objects in
the of the cases Array
* - pass each case Object to your transformCase() function to get a
new Object
* - add the new Object to your new array
* - return the new array with all the transformed Objects
******************************************************************************/
function transformCases(cases) {}
/*******************************************************************************
Part III: transformCases(cases) with .map()
*
* Rewrite your transformCases() function a second time using the
Array .map() method
* see
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
*
* In your solution, make use of the following:
*
* - use the .map() method of the cases Array to create a new
Array
* - In the .map() method's function, call your transformCase()
function
* - return the Array created by the .map() method
******************************************************************************/
function transformCases2(cases) {}
In: Computer Science
Given a sparse matrix represented in COO (Coordinate list), what is the pseudocode to perform the bellman-ford algorithm for single source shortest path by doing iterative sparse matrix-vector multiplication?
In: Computer Science
Python Jupiter Notebook
Write a program that keeps getting a set of numbers from user
until the user enters "done". Then shows the
count, total, and
average of the entered numbers.
Example:
Enter a number: 55
Enter a number: 90
Enter a number: 12
Enter a number: done
You entered 3 numbers, total is 157, average is 52.33333
In: Computer Science