C++ Code to Find Minimum Moves with Weapons to Kill Enemy

Arnab Chakraborty
Updated on 15-Mar-2022 04:58:48

787 Views

Suppose we have an array A with n elements, and another number H. H is health of an enemy. We have n weapons and damaging power of ith weapon is A[i]. Different weapons can be used to kill the enemy. We cannot use same weapon twice in a row. We have to count minimum how many times we can use weapons to kill the enemy.So, if the input is like A = [2, 1, 7]; H = 11, then the output will be 3, because if we use weapon with damage power 7, then use 2 then again use 7 ... Read More

C++ Code to Get Updated String with Same A and B Count

Arnab Chakraborty
Updated on 15-Mar-2022 04:55:38

205 Views

Suppose we have as string S with even length n. S contains only two types of characters 'a' and 'b'. We want to modify the string so that every its prefix of its length has an equal amount of letters 'a' and 'b'. To achieve that, we can perform the following operation arbitrary number of times: Select some position in his string and replace the letter on this position with the other letter. Return the updated string.So, if the input is like S = "aabbbb", then the output will be "baabab"StepsTo solve this, we will follow these steps −n := ... Read More

C++ Code to Find Card Spread for Equal Sum Distribution

Arnab Chakraborty
Updated on 15-Mar-2022 04:51:50

200 Views

Suppose we have an array A with n elements. Here n is even. A[i] is a number written on ith card. There are n/2 people who want to play a game. At the beginning, each player will take two cards. We have to find the way to distribute cards in such a way that sum of values written on the cards will be same for each player.So, if the input is like A = [1, 5, 7, 4, 4, 3], then the output will be [(0, 2), (5, 1), (3, 4)], because A[0] + A[2] = 8, A[5] + A[1] ... Read More

Count Operations to Make Two Arrays Same in C++

Arnab Chakraborty
Updated on 15-Mar-2022 04:46:15

287 Views

Suppose we have two arrays A and B with n number of elements. Consider an operation: Select two indices i and j, then decrease ith element by 1 and increase jth element by 1. Each element of the array must be non-negative after performing an operation. We want to make A and B same. We have to find the sequence of operations to make A and B same. If not possible, return -1.So, if the input is like A = [1, 2, 3, 4]; B = [3, 1, 2, 4], then the output will be [(1, 0), (2, 0)], because ... Read More

What is Double DES

Ginni
Updated on 14-Mar-2022 10:17:56

8K+ Views

The Data Encryption Standard (DES) is a symmetric key block cipher which creates 64-bit plaintext and 56-bit key as an input and makes 64-bit cipher text as output. The DES function is create up of P and S-boxes. P-boxes transpose bits and S-boxes substitute bits to make a cipher.DES is a Feistel Block Cipher implementation, called a LUCIFER. It need a Feistel structure with 16 rounds, where a different key can be used for each round. The major reasons to understand DES (Data Encryption Standard) is that it forms the foundation for encryption algorithms. This creates it easy for one ... Read More

Properties of Data Encryption Standard

Ginni
Updated on 14-Mar-2022 10:14:58

1K+ Views

DES is a block cipher. The encryption procedure is create of two permutations (Pboxes) that it can be defined initial and final permutations, and 16 Feistel rounds. Each round need a different 48-bit round key created from the cipher key according to a pre-represented algorithm. The DES function uses a 48-bit key to the rightmost 32 bits (RI−1) to create a 32-bit output.There are two properties of DES which are as follows −Avalanche EffectAvalanche effect defines a small change in the plaintext (or key) should make an important change in the ciphertext. It can change in one bit of plaintext ... Read More

Variations of DES

Ginni
Updated on 14-Mar-2022 10:12:59

3K+ Views

There are two main variations of Data Encryption Standard are as follows −Double DES − Double DES is an encryption approach which need two instance of DES on same plain text. In both instances it uses multiple keys to encrypt the plain text. Both keys are needed at the time of decryption.The 64 bit plain text goes into first DES instance which than transformed into a 64 bit middle text utilizing the first key and thus it goes to second DES instance which provides 64 bit cipher text by utilizing second key.Double DES is easy as it does that normal ... Read More

Elements of DES

Ginni
Updated on 14-Mar-2022 10:10:04

786 Views

There are various elements of DES which are as follows −Use of S-Boxes − The tables used for substitution i.e., the S-boxes, in DES are kept hidden by IBM. IBM supports that it took them over 17 person years to appear up with the internal design of the S-boxes.Key Length − Cryptographic system has two important elements including the cryptographic algorithm and the key. The inner operating of the DES algorithm are completely popular to the general public. Hence, the strength of the DES lies only in the other element including its key, which should be secret.Differential Cryptanalysis − Differential ... Read More

What is Expansion Permutation in Information Security

Ginni
Updated on 14-Mar-2022 10:07:55

1K+ Views

This operation expands the right half of the information, R from 32 bits to 48 bits and this operation changes the order of the bits as well as repeating specific bits. It is called an expansion permutation.This operation has two objective including it creates the right half the similar size as the key for the XOR operation and it supports a longer result that can be compressed during the substitution operation. It can be enabling one bit influence two substitutions, the dependency of the output bits on the input bits spread quicker. This is known as avalanche effect.DES is designed ... Read More

Number of Rounds in DES Algorithm

Ginni
Updated on 14-Mar-2022 10:05:26

1K+ Views

DES uses 16 rounds. Each of the 16 rounds includes the broad-level steps are as follows −Key Transformation − An initial 64-bit key is changed into a 56-bit key by discarding each 8th bit of the initial key. Therefore for each round, a 56 bit key is available. From this 56-bit key, a different 48-bit subkey is generated during each round using a process is known as key transformation.The 56-bit key is divided into two halves, each of 28 bits. These halves are circularly shifted left by one or two positions, based on the round.For instance, if the round number ... Read More

Advertisements