Click here to Skip to main content
15,914,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Let, a number n support a number (n+x), where x is the number of bits in the binary representation of n, like if n = 10, whose binary representation is 1010, i.e x=4; then it supports (10+4)=14. Now, in the questions, you are provided with an array of numbers. You have to print "SUPPORTED BY THE NUMBER (X)" if number is supported by any number 'X ' in the list and "NOT SUPPORTED" if there are no such number. If the array has duplicate entry, the function should print "Number 'X' has duplicate entry". How can i build the logic in python

What I have tried:

Python
def numberSup(A):
dict_1 = []*1000
list_a = []
set_a = ()
A.sort()
k = list(("{0:b}".format(i) for i in A))
gen = list((int(i) for i in k))
if len(set(gen))!= len(A):
    print("Duplicate Elements are not allowed"),A,gen

for i in A:
    for j in gen:
        key =  i + len(str(j))


Now How will i store the sum from both the lists as i traverse through both of them namely A and gen.?
Posted
Updated 26-Jan-17 19:16pm
v2

1 solution

If this is your real question
Quote:
How will i store the sum from both the lists as i traverse through both of them namely A and gen.?
then, this is the answer How do I add two lists together to create one final list[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900