Questions
Python Pierrette is at Legoland. She enjoys all the rides but hates to wait in lines....

Python

Pierrette is at Legoland. She enjoys all the rides but hates to wait in lines. Thanks to technology,

she has an app that tells her for each ride i a time ti when there is no line. However, she wants to

take the rides in increasing fun factor order. Pierrette assigns each ride i a fun factor fi . What is

the maximum number of rides she can take?

Make sure that your code runs in O(n2 ) time in order to pass all the test cases (n is the number of

rides)

# [last_name] [first_name], [student_ID]

from typing import List


def max_num_rides(rides: List[List[int]]) -> int:

    """Calculate the maximum number of rides one can take with given constraints.

    Pierrette is at Legoland. She enjoys all the rides but hates to wait in lines.

    Thanks to technology, she has an app that tells her for each ride a time when

    there is no line. However, she wants to take the rides in increasing fun factor

    order. Pierrette assigns each ride a fun factor. This function takes pairs of

    times and fun factors for all the rides, and returns the maximum number of

    rides Pierrette can take.

    Arguments:

        rides (list): A list of [time, fun factor] pairs. For each ride, the rides

            list contains a pair of time and fun factor. Both the time and the fun

            factor are integers. Assume that it takes no time to take a ride. You

            may further assume that all the time values are distinct and all the

            fun factor values are also distinct.

    Returns:

        int: The maximum number of rides Pierrette can take.

    Examples:

        >>> print(max_num_rides([[2, 5], [1, 3]]))

        2

        >>> print(max_num_rides([[4, 2], [42, 3], [59, 8], [12, 4], [1, 5], [5, 7]]))

        3

    """

    pass # FIXME

In: Computer Science

You are the IT director for XYZ Manufacturing. Your company is a B2B (business-to-business) organization that...

You are the IT director for XYZ Manufacturing. Your company is a B2B (business-to-business) organization that supplies auto parts to General Motors. There are 200 employees at XYZ Manufacturing with a headquarters in Detroit, Michigan, and field offices in Omaha, Nebraska; Austin, Texas; and Orlando, Florida. There are over 10,000 items in the inventory for XYZ Manufacturing and you receive raw material (i.e. steel, plastic, wiring, etc.) from China.

XYZ Manufacturing has been struggling for years with inadequate computer resources to track inventory and handle user requests from internal management, orders and invoices from General Motors, orders and invoices from your suppliers, and management reports. There is clearly an inability to store and retrieve complex “big data,” and recently there have been frequent security breaches. Your CIO is extremely frustrated with this situation and is looking for an alternative approach to providing IT services. She has asked you for input on this investigation.

Write a paper that describes advantages and disadvantages that cloud computing offers to XYZ Manufacturing. Include a sensible, detailed strategy to migrate to cloud computing, addressing the issues of performance, scalability, and economic factors.

Your paper should be 8-10 pages in length. Include at least five credible references.

In: Computer Science

Learning Objectives After the successful completion of this learning unit, you will be able to: Implement...

Learning Objectives

After the successful completion of this learning unit, you will be able to:

  • Implement syntactically correct C++ arrays.
  • Solve a variety of standard problems using arrays.

Array Practice

I recommend that before you begin the assignment you write as many of these small ungraded programming challenges as you can. You should at least write 2 or 3 of them. They are a good way to gradually build up your confidence and skills. Of course, you'll have to write a program to test each function as well. Note that none of these functions should include any input or output!

  • Write a function named noNegatives(). It should accept an array of integers and a size argument. It should return true if none of the values are negative. If any of the values are negative it should return false

            bool noNegatives(const int array[], int size);
    
  • Write a function named absoluteValues(). It should accept an array of integers and a size argument. It should replace any negative values with the corresponding positive value.

            void absoluteValues(int array[], int size);
    
  • Write a function named eCount. It should accept an array of chars and a size argument. It should return the number of times that the character 'e' shows up in the array.

            int eCount(const char array[], int size);
    
  • Write a function named charCount. It should be similar to eCount, but instead of counting 'e's it should accept a third argument, a target char. The function should return the number of times the target char shows up in the array.

            int charCount(const char array[], int size, char targetChar);
    
  • Write a method named isSorted. It should accept an array of integers and a size argument. It should return true if the values are sorted in ascending order. False if they are not.

            bool isSorted(const int array[], int size);
    
  • Write a method named equalNeighbors. It should accept an array of chars and a size argument. It should return true if there are two adjacent elements in the array with equal values. If there are not, it should return false.

            bool equalNeighbors(const char array[], int size);
    

This is not a homework assignment, so feel free to post your code to one of these (not more than one) to the forum at any time.

For Credit

Assignment 4.1 [45 points]

Write a program that reads five (or more) cards from the user, then analyzes the cards and prints out the category of hand that they represent.

Poker hands are categorized according to the following labels: Straight flush, four of a kind, full house, straight, flush, three of a kind, two pairs, pair, high card.

To simplify the program we will ignore card suits, and face cards. The values that the user inputs will be integer values from 2 to 9. When your program runs it should start by collecting five integer values from the user and placing the integers into an array that has 5 elements. It might look like this:

Enter five numeric cards, no face cards. Use 2 - 9.
Card 1: 8 
Card 2: 7
Card 3: 8
Card 4: 2
Card 5: 3

(This is a pair, since there are two eights)

No input validation is required for this assignment. You can assume that the user will always enter valid data (numbers between 2 and 9).

Since we are ignoring card suits there won't be any flushes. Your program should be able to recognize the following hand categories, listed from least valuable to most valuable:

Hand Type Description Example
High Card There are no matching cards, and the hand is not a straight 2, 5, 3, 8, 7
Pair Two of the cards are identical 2, 5, 3, 5, 7
Two Pair Two different pairs 2, 5, 3, 5, 3
Three of a kind Three matching cards 5, 5, 3, 5, 7
Straight 5 consecutive cards 3, 5, 6, 4, 7
Full House A pair and three of a kind 5, 7, 5, 7, 7
Four of a kind Four matching cards 2, 5, 5, 5, 5

(A note on straights: a hand is a straight regardless of the order. So the values 3, 4, 5, 6, 7 represent a straight, but so do the values 7, 4, 5, 6, 3).

Your program should read in five values and then print out the appropriate hand type. If a hand matches more than one description, the program should print out the most valuable hand type.

Here are three sample runs of the program:

Enter five numeric cards, no face cards. Use 2 - 9.
Card 1: 8 
Card 2: 7
Card 3: 8
Card 4: 2
Card 5: 7
Two Pair!
Enter five numeric cards, no face cards. Use 2 - 9.
Card 1: 8 
Card 2: 7
Card 3: 4
Card 4: 6
Card 5: 5
Straight!
Enter five numeric cards, no face cards. Use 2 - 9.
Card 1: 9 
Card 2: 2
Card 3: 3
Card 4: 4
Card 5: 5
High Card!

Additional Requirements

1) You must write a function for each hand type. Each function must accept a const int array that contains five integers, each representing one of the 5 cards in the hand, and must return "true" if the hand contains the cards indicated by the name of the function, "false" if it does not. The functions should have the following signatures.

bool  containsPair(const int hand[])
bool  containsTwoPair(const int hand[])
bool  containsThreeOfaKind(const int hand[])
bool  containsStraight(const int hand[])
bool  containsFullHouse(const int hand[])
bool  containsFourOfaKind(const int hand[])

Note that there are some interesting questions regarding what some of these should return if the hand contains the target hand-type and also contains a higher hand-type. For example, should containsPair() return true for the hand [2, 2, 2, 3, 4]? Should it return true for [2, 2, 3, 3, 4]? [2, 2, 3, 3, 3]? I will leave these decisions up to you.

2) Of course, as a matter of good practice, you should use a constant to represent the number of cards in the hand, and everything in your code should still work if the number of cards in the hand is changed to 4 or 6 or 11 (for example).  Writing your code so that it does not easily generalize to more than 5 cards allows you to avoid the objectives of this assignment (such as traversing an array using a loop). If you do this, you will receive a 0 on the assignment.

3) You do not need to write a containsHighCard function. All hands contain a highest card. If you determine that a particular hand is not one of the better hand types, then you know that it is a High Card hand.

4) Do not sort the cards in the hand. Also, do not make a copy of the hand and then sort that.

5) An important objective of this assignment is to have you practice creating excellent decomposition.  Don't worry about efficiency on this assignment. Focus on excellent decomposition, which results in readable code. This is one of those programs where you can rush and get it done but end up with code that is really difficult to read, debug, modify, and re-use. If you think about it hard, you can think of really helpful ways in which to combine the tasks that the various functions are performing.  5 extra credit points on this assignment will be awarded based on the following criteria: no function may have nested loops in it. If you need nested loops, the inner loop must be turned into a separate function, hopefully in a way that makes sense and so that the separate function is general enough to be re-used by the other functions. Also, no function other than main() may have more than 5 lines of code. (This is counting declarations, but not counting the function header, blank lines, or lines that have only a curly brace on them.) In my solution I was able to create just 3 helper functions, 2 of which are used repeatedly by the various functions.

These additional criteria are intended as an extra challenge and may be difficult for many of you. If you can't figure it out, give it your best shot, but don't be too discouraged. It's just 5 points. And be sure to study the posted solution carefully.

Suggestions

Test these functions independently. Once you are sure that they all work, the program logic for the complete program will be fairly straightforward.

Here is code that tests a containsPair function:

int main() {
        int hand[] = {2, 5, 3, 2, 9};

        if (containsPair(hand)) {
                cout << "contains a pair" << endl;
        }
}

Submit Your Work

Name your source code file according to the assignment number (a1_1.cpp, a4_2.cpp, etc.). Execute the program and copy/paste the output that is produced by your program into the bottom of the source code file, making it into a comment. Use the Assignment Submission link to submit the source file. When you submit your assignment there will be a text field in which you can add a note to me (called a "comment", but don't confuse it with a C++ comment). In this "comments" section of the submission page let me know whether the program works as required.

Keep in mind that if your code does not compile you will receive a 0.

In: Computer Science

You have just been put in charge of safety at your plant. The probability of an...

You have just been put in charge of safety at your plant. The probability of an injury occuring on any given day is p. Your boss says that once the company has 10 totoal days in which at least one injury is reported the insurance premium triples. To plan financially, she wants to know how many days to expect until the insurance premium is going to triple. Write a class called SafetyAnalysis.java that does the following:

a. Reads in a value of p from the user. Checks if it is a double and a feasible probability.

b. Determines if there is an injury each day. To do this, generate a random number between 0 and 1. If the number you generated is less than p then there was an injury. Otherwise, there was not an injury on that day.

c. Continue determining if there was an injury each day until a total of 10 days worth of injuries have occurred (hint: use a loop where you don’t know how many iterations are required).

d. Repeat b. - c. 1000 times (hint: use a loop where you do know how many iterations are required). Return the average number of days it takes until 10 total injuries occur. (hint: each time you complete c., you have a new value to include in your average) e. Report the average number of days over the 1000 experiments that it takes until 10 days of injuries occur. Print this value to the screen with the appropriate labeling information

In: Computer Science

A local biologist needs a program to predict population growth. The inputs would be: The initial...

A local biologist needs a program to predict population growth. The inputs would be: The initial number of organisms The rate of growth (a real number greater than 1) The number of hours it takes to achieve this rate A number of hours during which the population grows For example, one might start with a population of 500 organisms, a growth rate of 2, and a growth period to achieve this rate of 6 hours. Assuming that none of the organisms die, this would imply that this population would double in size every 6 hours. Thus, after allowing 6 hours for growth, we would have 1000 organisms, and after 12 hours, we would have 2000 organisms. Write a program that takes these inputs and displays a prediction of the total population. An example of the program input and output is shown below: Enter the initial number of organisms: 10 Enter the rate of growth [a real number > 0]: 2 Enter the number of hours to achieve the rate of growth: 2 Enter the total hours of growth: 6 The total population is 80

i am using python

In: Computer Science

A- Briefly explain what is the purpose of the SW operation in S-DES i.e. How would...

A- Briefly explain what is the purpose of the SW operation in S-DES i.e. How would S-DES be weakened if the SW operation was ommitted.

B- Briefly explain why in DES the key is 56-bits instead of 64-bits?

In: Computer Science

(PYTHON) A Prime number is an integer greater than 1 that cannot be formed by multiplying...

(PYTHON)

A Prime number is an integer greater than 1 that cannot be formed by multiplying two smaller integer other than 1 and itself. For example, 5 is prime because the only ways of writing it as a product, 1 × 5 or 5 × 1.

In this question you will write a program that takes a sequence of integers from the user and display all the prime numbers contained in that sequence.

We will separate this question in 2 steps:

Step 1 (5 pts) Write a script that accepts a sequence of positive integer from the user and display all the prime numbers from that sequence. Your program should accept and save in a list the input from the user until the value -1 is entered. Your program should also make sure that only positive values are entered. You can assume the users only enter integers.

Step 2 (5 pts) We can improve the program usability by adding the following functions:

- A function is_prime that receives an integer as parameter, check if this integer is a prime number and returns a boolean value depending on the result. -

A function find_primes that receives the user sequence as parameter and use the function is_prime to figure out which are the prime values. The function then returns a list containing all the prime values contained in the user sequence.

Your user input script should be similar as in part 1 and use the result of the find_primes function to display the list of prime numbers.

In: Computer Science

You have been appointed as a design engineer and assigned to design a secured network for...

You have been appointed as a design engineer and assigned to design a secured network
for a private organization. Evaluate your approach to improve the security posture of
your network before, during, and after your network implementation.

In: Computer Science

several trends and issues that are specifically relevant to the field of instructional design and technology.

several trends and issues that are specifically relevant to the field of instructional design and technology.

In: Computer Science

Goal: After the manager of a local McDonalds hired several ASU grads to work the cash...

Goal:

After the manager of a local McDonalds hired several ASU grads to work the cash registers, he realized that they were having trouble figuring out the correct amount of change to return to their customers. The manager wants you to create a VB.NET program that calculates the correct amount of change to be given to a customer following a transaction.

Guidelines:

You should have

  • Option Explicit On (this forces you to declare all of your variables)
  • Option Strict On (this forces you to explicitly convert from one data type to another rather than relying on VB.Net to make these conversions for you implicitly)
  • At least one relevant image on your form (lots of McDonalds and $$ images available on the Net)
  • Calculate, Clear, and Exit buttons along the bottom of your form

Inputs:

  Transaction Amount

  validation: data must have been entered, data must be numeric, amount cannot be negative or greater than $1000.00

Amount of Cash Provided By The Customer

validation: data must have been entered, data must be numeric,

amount cannot be negative and must be equal to or greater than the Transaction Amount

Outputs:

Total Amount of Change To Be Returned

Number of Twenties To Be Returned

Number of Tens To Be Returned

Number of Fives To Be Returned

Number of Ones To Be Returned

Number of Quarters To Be Returned

Number of Dimes To Be Returned

Number of Nickels To Be Returned

Number of Pennies To Be Returned

In: Computer Science

Guidelines Look up one of the many sites describing the BMI, and read a bit about...

Guidelines

Look up one of the many sites describing the BMI, and read a bit about how it is used to indicate general health. Create a VB.Net program that, given a user’s height in inches and weight in pounds, will calculate and display his/her BMI. After calculating the user's BMI, indicate the user's health status.  

BMI = (weight * 703) / (height * height)

Display the user’s Height Status:

    BMI

Health Status

Below 18.5

    Underweight

18.5 -24.9

    Normal

25 - 29.9

    Overweight

30 & Above

    Obese

Input: Height and Weight.

Output: BMI (to one decimal, like 27.7) and Weight Status (a string, like “Overweight”)

After the remarks at the top of your program, add “Option Explicit On” and “Option Strict On”. The former requires you to explicitly declare each variable used and the latter requires you to explicitly convert data from one type to another, rather than rely on VB.Net to implicitly convert data.    

In: Computer Science

describe how prime numbers or quadratic congruence can be used to crack an encryption system?

describe how prime numbers or quadratic congruence can be used to crack an encryption system?

In: Computer Science

Does anyone know how to find if a certain String is available in an ArrayList? I...

Does anyone know how to find if a certain String is available in an ArrayList?

I was asked by my instructor to make a certain program about Student Record

In the area where I need to add some student in the ArrayList it won't add if there is the same name in the ArrayList

at first I used the equals method and contains method but later I found it was prohibited to use such method.

Is there a way to find if a String is Available in the ArrayList without using the method

Please check on else if(response==2)

import java.util.*;
public class performanceTask {

   public static void main(String[] args) {
       int response;
       ArrayList<String> listOfStudent = new ArrayList<String>();

       Scanner aScanner = new Scanner(System.in);
       do {
           System.out.println("[Selection Bar]");
           System.out.println("[1] List of Students.");
           System.out.println("[2] Add Student.");
           System.out.println("[3] Edit Student.");
           System.out.println("[4] Delete Student.");
           System.out.println("[5] Clear list of Students.");
           System.out.println("[6] Exit Program.");
           System.out.println("--------------------------");
           System.out.println("Select an option: ");
           response = aScanner.nextInt();
          
           if(response == 1) {
               int size = listOfStudent.size();
               if(size == 0) {
                   System.out.println("No Records Found!\n");
               } else {
                   Collections.sort(listOfStudent);
                   for(int i = 0; i<listOfStudent.size(); i++) {
                       System.out.println(i + ". " + "[" + listOfStudent.get(i) + "]");
                      
                   }
                   System.out.println("\n");
              
               }
           }else if (response == 2) {
               System.out.println("Enter Name of a Student: ");
               String addStudent = aScanner.next();
              
               if (listOfStudent.contains(addStudent)) {
                   System.out.println(addStudent +" already existed! \n");
                  
               } else {
                   System.out.println("Do you want to save " + addStudent + "? [y/n]: ");
                   String saveIt = aScanner.next();
                       if(saveIt.equals("y") || saveIt.equals("Y") ) {
                           listOfStudent.add(addStudent);
                           System.out.println(addStudent +" has been successfully added! \n ");
                       }else if (saveIt.equals("n") || saveIt.equals("n")) {
                           System.out.println("\n");
                           continue;
                       }else {
                           System.out.println("It must be y or n only!");
                       }
                   }
              

In: Computer Science

1) Convert negative fractional decimal number to 8-bit binary number: – 16.625 (use 2's complement binary...

1) Convert negative fractional decimal number to 8-bit binary number: – 16.625 (use 2's complement binary format)

Hint: –17 + 0.375

Given the hint above, the fractional number will be divided into two parts,
- Whole number,
- Fractional part, must be positive

(2) Proof to check that your calculation above is correct

In: Computer Science

Spatial indexing with quadtrees in python The quadtrees data structure is a special type of tree...

Spatial indexing with quadtrees in python

The quadtrees data structure is a special type of tree structure, which can recursively divide a flat 2-D space into four quadrants. Each hierarchical node in this tree structure has either zero or four children. It can be used for various purposes like sparse data storage, image processing, and spatial indexing. Spatial indexing is all about the efficient execution of select geometric queries, forming an essential part of geo-spatial application design. For example, ridesharing applications like Ola and Uber process geo-queries to track the location of cabs and provide updates to users. Facebook’s Nearby Friends feature also has similar functionality. Here, the associated meta-data is stored in the form of tables, and a spatial index is created separately with the object coordinates. The problem objective is to find the nearest point to a given one. You can pursue quadtree data structure projects in a wide range of fields, from mapping, urban planning, and transportation planning to disaster management and mitigation. We have provided a brief outline to fuel your problem-solving and analytical skills. Objective: Creating a data structure that enables the following operations

 Insert a location or geometric space

 Search for the coordinates of a specific location

 Count the number of locations in the data structure in a particular contiguous area

In: Computer Science