Techno Blender
Digitally Yours.
Browsing Tag

integers

Can You See Through These Illusions?

Optical illusions and puzzles share overlapping vibes. Mental trickery, ‘aha’ moments, cross-eyed frustration. Did you know that the Neural Correlate Society holds an annual contest for the Best Illusion of the Year? This year’s winner created a LEGO model of Harry Potter’s Platform 9 ¾, complete with a seemingly permeable brick wall:What Inspired Dominic Monaghan's Performance in Moriarty?https://www.youtube.com/watch?v=jrbqIAdDE_wThis neat mirror demonstration also stands out among recent finalists. This week’s puzzles…

Generate sequence with equal sum of adjacent integers

Improve Article Save Article Like Article Improve Article Save Article Like Article Given an integer N, find a sequence of N integers such that the sum of all integers in the sequence is equal to the sum of any two adjacent integers in the sequence.Examples:Input: N = 4Output: 1 -1 1 -1Explanation: Total sum of the four integers is 0 and the sum of any two adjacent integers is also 0.Input: N = 5Output: 1 -2 1 -2 1Explanation: Total sum of the four integers is -1 and the sum of any two adjacent integers is also…

Largest product that can be obtained by multiplying any three integers from list

Geek is playing a video game that contains N monsters having varying power denoted by power. Geek will play total Q rounds and for each round, the power of Geek is Q. He can kill all monsters having power ≤ Q. All the monsters which were dead in the previous round will be reborn, such that for each round there will be N monsters. Since Geek wants to win each round, he wants to count the number of monsters he can kill in each round and the total sum of their powers. Can you help him?Examples:Input: N = 7, powers = {1, 2,…

Ascending order of three integers after XOR operation

Improve Article Save Article Like Article Improve Article Save Article Like Article Given three distinct integers X, Y, Z. Find an integer N that after performing XOR of each element, integers must follow that X should be minimum and Z should be maximum between three integers. If possible then print the integer, Otherwise print -1.Examples:Input: 4, 5, 6Output: 0Explanation: 4 XOR 0 = 4, 5 XOR 0 = 5, 6 XOR 0 = 6, so 4 is minimum and 6 is maximum, .Input: 12, 9, 8Output: 15Approach: To solve the problem follow the…

Counting even integers in modified Sequence

Given an integer array A of size N, and Q queries. In each query, you are given an integer X. Create a new sequence X^A, say sequence B. For each query find the number of even integers in the modified sequence for a given value of X.Examples:Input: A = {15, 6, 100, 8, 23, 45, 7, 101, 90}, N = 9, Q = 4, X = {3, 7, 10, 60}Output: {5, 5, 4, 4}Explanation: For first query, 3 XOR 15 = 12, 3 XOR 23 = 20, 3 XOR 45 = 46, 3 XOR 7 = 4 and 3 XOR 101 = 102. So total 5 even numbers. Similarly for the rest of the Q queries for X…

Quadruples for Sum and Product of Integers with XOR

Given an integer N, the task is to find X and Y where X is the number of quadruples of positive integers (A, B, C, D) such that AB + CD = N, Y is the number of quadruples of positive integers (A, B, C, D) such that (A + B)(C + D) = N. Print X XOR Y.Examples:Input: N = 4Output: 9Explanation: First we count X, the number of quadruples of positive integers (A, B, C, D) such that AB + CD = N (A, B, C, D) = (1, 1, 1, 3)(A, B, C, D) = (1, 1, 3, 1)(A, B, C, D) = (1, 2, 1, 2)(A, B, C, D) = (1, 2, 2, 1)(A, B, C, D) = (1, 3, 1,…

Count of squads of positive integers such that (A * B) + (C * D) = N

Given a positive integer N, the task is to find the count of squads of positive integers (A, B, C, D) such that (A * B) + (C * D) = N. Note: (A, B, C, D) is different from (A, D, B, C).Example:Input: 4Output: 8Explanation:(A, B, C, D)=(1, 1, 1, 3)(A, B, C, D)=(1, 1, 3, 1)(A, B, C, D)=(1, 2, 1, 2)(A, B, C, D)=(1, 2, 2, 1)(A, B, C, D)=(1, 3, 1, 1)(A, B, C, D)=(2, 1, 1, 2)(A, B, C, D)=(2, 1, 2, 1)(A, B, C, D)=(3, 1, 1, 1)Naive Approach: The basic way to solve the problem is as follows:In this implementation, we use four…

Form a bitwise equation from L+1 integers which gives result N

Improve Article Save Article Like Article Improve Article Save Article Given two integers N and L, Find out a string of length L which consists of bitwise operators &(AND), |(OR), and ^(XOR), and if these operators are placed in order between L+1 integers, (where each integer value lies between 0 to N ) it forms a bitwise equation which gives result N, also it must follow that any two consecutive characters of a string cannot be the same(&&|&^ is not acceptable but &|&|^ is acceptable).Note:…

Pair the integers of Array so that each pair sum is consecutive and distinct

Given an array arrof size N. We have to pair the integers such that each integer should be in exactly one pair and each sum of pairs is consecutive and distinct. Formally, sum(arri +  arrj) + 1 = sum(arri1 + arrj1). Print the pairs of integers satisfying all the conditions. If it is not possible to find the pairs return -1.Examples:Input: N = 6, arr = {2, 3, 1, 4, 6, 5}Output:1 6 3 54 2Explanation: All pair’s sum is consecutive.Input: N = 8 arr = {8, 7, 1, 2, 3, 5, 6, 4}Output: -1Approach: This can be solved with the…

Minimize product of two integers by swapping any number of their digits

Given two N-digit integers X and Y, the task is to minimize the product of X and Y by performing the following operation any number of times where we can choose an integer i such that 1≤ i ≤ N and swap ith lowest digits of X and Y.Examples:Input : N  = 2, X = 13, Y = 22Output: 276Explanation: On performing the operation once, with i = 1, we get X = 12 and Y = 23 (swapping the rightmost digits of X and Y). Now X*Y would be 276. It isn’t possible to make X*Y less than 276, hence the answer is 276.Input : N = 8, X =…