1answer.
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
FinnZ [79.3K]
3 years 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:
joja [24]3 years ago
5 0

Answer:

I don't know if this is right output is {1,3}

Explanation:

You might be interested in
Are the ways data is represented and transmitted with computers laws of nature or laws of man?
puteri [66]
I believe the correct answer is Laws of Man
4 0
3 years ago
Blender is used by which video game team member?
prohojiy [21]

Answer:

The 2nd one

Explanation:

6 0
3 years ago
.Why are protocols important for networking?
NNADVOKAT [17]

Answer: Networking protocols are important as they define a set of rules to be used for exchanging information between computer nodes.

Explanation:

in terms of networking it is required for the source and the destination to have a set of predefined rules which enables the router to send and receive information across the network in such as way that both the ends are able to receive the messages.

The information exchange takes place first by the client by introducing itself to the remote server. the remote server upon receiving the information uses some form of handshaking and acknowledges the client of the receipt of the message.

besides this there are many routing protocols which tells us about the way how packets are sent from the client to the source. There are two types of routing protocols:

1. static routing protocols

2. dynamic routing protocols.

6 0
3 years ago
Messages that have been accessed or viewed in the Reading pane are automatically marked in Outlook and the message subject is no
vivado [14]

Answer:

Mark as Unread

Explanation:

I just know

5 0
3 years ago
Read 2 more answers
Today we will be making a Caesar Cipher to encrypt and decrypt messages.A Caesar Cipher is a simple cipher that translates one l
Len [333]

Answer:

#include <iostream>

#include <stdio.h>

#include <ctype.h>

using namespace std;

string

encrypt (string text, int s)

{  string resultingString = "";

 for (int i = 0; i < text.length (); i++)

   {      if (!isspace (text[i]))

{

  if (isupper (text[i]))

    resultingString += char (int (text[i] + s - 65) % 26 + 65);

  else

  resultingString += char (int (text[i] + s - 97) % 26 + 97);

}

     else

{

  resultingString += " ";

}

  }

 return resultingString;

}

string

decrypt (string text, int s)

{

 string resultingString = "";

 for (int i = 0; i < text.length (); i++)

   {

     if (!isspace (text[i]))

{

  if (isupper (text[i]))

    resultingString += char (int (text[i] + s - 65) % 26 + 65);

  else

  resultingString += char (int (text[i] + s - 97) % 26 + 97);

}

     else

{

  resultingString += " ";

}

   }

 return resultingString;

}

string upper(string str){

   for (int i=0;i<str.length();i++){

       str[i]=toupper(str[i]);

   }

   return str;

}

int

main ()

{

 string text = "This is test text string";

 

 int s = 3;

 string cipherText = "";

 string decipherText = "";

int menu=-1;

while (menu!=3){

   cout<<"1. Encrypt"<<endl;

   cout<<"2. Decrypt"<<endl;

   cout<<"3. Exit"<<endl;

   cin >>menu;

   cin.ignore();

   if(menu==1){

       cout<<"Enter Plain string "<<endl;

       getline(cin,text);

       text=upper(text);

         cipherText = encrypt (text, s);

           cout << "cipher text: " << cipherText << endl;

   }

   else if(menu==2){

       cout<<"Enter Encrypted string "<<endl;

       getline(cin,cipherText);

               cipherText=upper(cipherText);

         decipherText = decrypt (cipherText, 26 - s);

 cout << "decipher text: " << decipherText << endl;

   }

   else {

       cout<<"Not valid"<<endl;

   }

}

 return 0;

}

Explanation:

Display menu with options 1 encrypt, 2 decrypt, 3 exit. Write a function to translate string to upper case. Iterate through string and for each index use toupper function to translate alphabet to upper case and store it back to current index of string.On exiting from loop return string. Pass upper case string to encrypt function.

In encrypt function pass string by reference and shift value. Create an empty string resultingString. Iterate through string for each character check if its space, if its a space add it to resulting string otherwise using ascii values convert char to its ascii add shift value and subtract 65 (staring ascii value for capital alphabet) take modules with 26 for new character and than add 65 to get alphabet.Now add this alphabet to resulting string. Upon loop completion return resultingString.

For decryption use same function as encryption. We are using cyclic property to decrypt using same function therefor subtract shift from 26 and pass resulting shift value to decrypt function.

8 0
3 years ago
Other questions:
  • g Create a public non-final generic class called YourSimpleLinkedList. You should extend SimpleLinkedList which is parameterized
    10·1 answer
  • How to save customised keyboard shortcuts on word
    11·1 answer
  • How to program chamberlain universal garage door opener?
    13·1 answer
  • What is the different between a computer and a phone?​
    15·1 answer
  • _____ is an effort by an employee to attract attention to a negligent, illegal, unethical, abusive, or dangerous act by a compan
    8·1 answer
  • What is a set of illustrations displayed in a specific sequence to pre-visualize what your mobile app looks like and how it work
    5·1 answer
  • What is the term for a set of actions carried out on inputs?
    7·1 answer
  • A professional photographer working for a top newspaper would like control over the quality and editing
    14·2 answers
  • Read the scenario and then answer the question using only the information provided.
    14·2 answers
  • ____________are the video images provided for editor to cut to and from instead of making viewers watch talking heads
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!