Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ASSIGNMENTS/ATM Problem solved in Python
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
t=int(input())
for _ in range(t):
n,k=map(int,input().split())
arr=list(map(int,input().split()))
s=""
for i in range(n):
if arr[i]<=k:
k-=arr[i]
s+='1'
else:
s+='0'
print(s)
21 changes: 21 additions & 0 deletions OPEN CHALLENGE/Decimal to Binary and Binary to Decimal
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def Binary(n):
global s
if(n > 1):
Binary(n//2)
s+=str(n%2)
return s

def decimal(n):
n=int(n)
deci, i= 0, 0
while(n!= 0):
dec = n% 10
deci = deci + dec * pow(2, i)
n = n//10
i += 1
return deci

s=""
print(Binary(1234))
print(decimal(11010))