answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
dedylja
1 month ago
10

HackerCards is a trendy new card game. Each type of HackerCard has a distinct ID number greater than or equal to 1, and the cost

of each HackerCard equals its ID number. For example, HackerCard 1 costs 1, HackerCard 5 costs 5, and so on. #!/bin/python3 10 11 # Complete the hackerCards function below. 12 def hackerCards (collection, d): 13 14 > if _name == '__main__':. Leanne already has a collection started. For her birthday, Mike wants to buy her as many cards as he can given his budget. He wants to buy one each of some cards she doesn't already have. If he has to make one choice among several, he will always choose the lowest cost option. Determine which cards he will buy For example, Leanne's collection = [2, 4, 5] and Mike has d = 7 to spend. He can purchase a maximum of 2 cards, the 1 and the 3 to add to her collection. Two other options he has are 1 and 6 (costs more) or 7(fewer cards, costs more). Function Description Complete the function hackerCards in the editor below. The function must return an array of integer ID's of the cards Mike will purchase in ascending order. hackerCards has the following parameter(s): collection(collection [O)....collection(n-1)]: an array of integer ID numbers of cards in Leanne's collection d: an integer that denotes Mike's budget Constraints ⢠1sns 105 ⢠1s collection[i] $ 109, where Osi
Computers and Technology
1 answer:
zubka84 [1K]1 month ago
5 0

Answer:

No estoy seguro si esto es correcto, la salida es {1,3}

Explanation:

You might be interested in
FOREACH, EXPLODE and MAIL are examples of crazy functions.
zubka84 [1067]
The selected response is B
4 0
1 month ago
Describe a strategy for avoiding nested conditionals. Give your own example of a nested conditional that can be modified to beco
maria [1035]

Answer:

To prevent nested conditionals, one can utilize logical expressions like the AND operator.

A recommended approach is creating an interface class with a method designed for a shared function. This design approach is known as the strategy design pattern. The conditional statements can be consolidated into this method. Subsequently, each class can implement this interface and invoke that shared method as needed by constructing instances of subclasses and calling the common method for those objects. This illustrates polymorphism.

Explanation:

Nested conditionals occur when if or else if statements are placed within another condition. For instance:

if( condition1) {

//runs when condition1 is true

  if(condition2) {

//runs when both condition1 and condition2 are true

  }  else if(condition3) {

 //when condition1 is true and condition3 is also true

} else {

 //condition1 is true but neither condition2 nor conditions3 are satisfied

}  }

Excessive nested conditionals can complicate the program, rendering it hard to read or comprehend, particularly if there's improper indentation. Debugging also becomes challenging when there are numerous nested statements.

Thus, several strategies can be adopted to eliminate nested conditionals, such as utilizing a switch statement.

For instance, I’ll present an example of the strategies discussed earlier:

Logical Expressions Usage:

A method to avoid nested conditionals is by employing logical expressions with logical operators like the AND operator. The previous nested conditionals can be reframed as:

if(condition1 && condition2){ //only runs when both condition1 and condition2 are true

} else if(condition1 && condition3) {

executes only if both condition1 and condition3 are true

} else if(condition1 ){

//condition1 is satisfied but neither condtion2 nor condtion3 are true  }

This can be further simplified to one condition as:

if(!condition3){

// when  condition1 and condition2 are both satisfied

}

else

// condition3 is met

Now, consider a simple instance dealing with whether to attend school based on certain conditions.

if (temperature< 40)

{

   if (busArrived=="yes")

   {

       if (!sick)

       {

           if (homework=="done")

           {

               printf("Go to school.");

           }

       }                    

   }

}

Here, nested conditionals are evident. This can be restructured into a solitary conditional using the AND logical operator.

if ((temperature <40) && (busArrived=="yes") &&

(!sick) && (homework=="done"))

{    cout<<"Eligible for promotion."; }

The alternate method is utilizing an interface. For example, you can

abstract class Shape{

//declare a method common to all sub classes

  abstract public int area();

// same method that varies by formula of area for different shapes

}

class Triangle extends Shape{

  public int area() {

     // implementation of area code for Triangle

return (width * height / 2);

  }

}

class Rectangle extends Shape{

  public int area() {

     // implementation of area code for Rectangle

    return (width * height)

  }

}

Now, you can readily create Rectangle or Triangle instances and invoke area() for any of those objects, resulting in execution of the appropriate version accordingly.

4 0
1 month ago
The symbol asterisk(*) in a select query retrieves​
Harlamova29_29 [1022]

Answer:

The solution to this issue can be found in the explanation section provided below.

Explanation:

The asterisk (*) symbol within a select query retrieves all columns in the designated table. For instance, if there is a table named "employee" comprising three columns: id, name, address.

To use the asterisk (*) in a select query to obtain all columns in the result, it appears as follows:

for example:

select * from employee;

This query command selects all columns from the "employee" table to be included in the output.

3 0
1 month ago
What ""old fashioned"" features of checking accounts is p2p replacing
zubka84 [1067]

Answer:

Bank or wire transactions and ATM cash withdrawals

Explanation:

With peer-to-peer options like PayPal and Venmo, there's significantly less need to handle cash, particularly when transferring between individuals.

If only one option is to be chosen, I would prefer "ATM Cash Withdrawals."

3 0
12 days ago
When a switch configuration includes a user-defined error threshold on a per-port basis, to which switching method will the swit
maria [1035]
When the user-defined error threshold established on a per-port basis is met, the switch will revert to using the STORE-AND-FORWARD switching method.
7 0
1 month ago
Other questions:
  • The Pentium 4 Prescott processor, released in 2004, had a clock rate of 3.6 GHz and voltage of 1.25 V. Assume that, on average,
    8·1 answer
  • How many bits would be needed to count all of the students in class today? There are 5 children in the class.
    7·1 answer
  • Explain how abstraction is used in a GPS system
    12·2 answers
  • How concerned are you about the security of rtos in cars smart homes and wearable technology?
    15·1 answer
  • Modern operating systems decouple a process address space from the machine’s physical memory. List two advantages of this design
    15·1 answer
  • Which selections are possible for controlling the start time of audio playback? Check all that apply. Automatic Rewind when done
    10·1 answer
  • Tanya wants to include a video with all its controls on her web page. The dimensions of the video are as follows:
    6·2 answers
  • Cindy visits her favorite website on a lunch break using a hospital computer. After she downloads a file, she notices that the c
    7·1 answer
  • ___________is used for drawing 3D objects in the field of Science and Engineering.
    12·2 answers
  • A bicycle sharing company is developing a multi-tier architecture to track the location of its bicycles during peak operating ho
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!