From f6e1682810ee0bf8962d4b226722bf165bc93a24 Mon Sep 17 00:00:00 2001 From: bhavikb07 <43561956+bhavikb07@users.noreply.github.com> Date: Mon, 29 Oct 2018 16:24:26 +0530 Subject: [PATCH 1/2] Create ATM Problem solved in Python Solved ATM problem in Python version 3 --- ASSIGNMENTS/ATM Problem solved in Python | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 ASSIGNMENTS/ATM Problem solved in Python diff --git a/ASSIGNMENTS/ATM Problem solved in Python b/ASSIGNMENTS/ATM Problem solved in Python new file mode 100644 index 00000000..2a26dc88 --- /dev/null +++ b/ASSIGNMENTS/ATM Problem solved in Python @@ -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) From 5354c34c15070ead4bc1f215fc07d8278cba4369 Mon Sep 17 00:00:00 2001 From: bhavikb07 <43561956+bhavikb07@users.noreply.github.com> Date: Mon, 29 Oct 2018 16:39:02 +0530 Subject: [PATCH 2/2] Create Decimal to Binary and Binary to Decimal The function for binary to decimal is working all good except the fact that it takes the answer from the previous result and merge the answer . But it will work fine for separate calling of the function. Like for eg: print(Binary(23)) print(Binary(21)) will lead you to correct answer for 23 but wrong for 21. so try: for i in range(21,24,2): s="" print(Binary(i)) --- .../Decimal to Binary and Binary to Decimal | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 OPEN CHALLENGE/Decimal to Binary and Binary to Decimal diff --git a/OPEN CHALLENGE/Decimal to Binary and Binary to Decimal b/OPEN CHALLENGE/Decimal to Binary and Binary to Decimal new file mode 100644 index 00000000..1645d432 --- /dev/null +++ b/OPEN CHALLENGE/Decimal to Binary and Binary to Decimal @@ -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)) +