Skip to content

Instantly share code, notes, and snippets.

View swarathesh's full-sized avatar

Chandra Swarathesh Addanki swarathesh

View GitHub Profile
@swarathesh
swarathesh / install-tensorflow.sh
Created March 8, 2017 17:26 — forked from erikbern/install-tensorflow.sh
Installing TensorFlow on EC2
# Note – this is not a bash script (some of the steps require reboot)
# I named it .sh just so Github does correct syntax highlighting.
#
# This is also available as an AMI in us-east-1 (virginia): ami-cf5028a5
#
# The CUDA part is mostly based on this excellent blog post:
# http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/
# Install various packages
sudo apt-get update
from LinkedListpract.LinkedList import LinkedList
linkedlist = LinkedList()
linkedlist.insertstart(1)
linkedlist.insertstart(2)
linkedlist.insertend(12)
linkedlist.traverse()
print("\n")
m = int(input("enter m"))
n = int(input("enter n"))
abso = m-n if m-n>0 else (m-n)*-1
print abso
#Print the count of all the vowels that are available in the string
inp = raw_input("enter the string").lower()
countA = inp.count('a')
countE = inp.count('e')
countI = inp.count('i')
countO = inp.count('o')
countU = inp.count('u')
#print the count
#How to check if a given number is a power of 2 ?
inp = int(raw_input("enter number"))
while inp%2 == 0 :
inp //=2
answer = 'power of 2 ' if inp == 1 else 'not power of 2 '
#pritn the answer
print answer
#How to check if a given number is a power of 2 ?
n = int(raw_input("enter number"))
count =0
while n != 0 :
n = n & (n - 1)
count+=1
print(count)
@swarathesh
swarathesh / BinarySearch.py
Created June 15, 2017 10:46
#day 2 recursions
def binary_search_rec(a, key, low, high):
if low > high:
return -1
mid = low + ((high - low) / 2)
if a[mid] == key:
return mid
elif key < a[mid]:
return binary_search_rec(a, key, low, mid - 1)
else:
def find_sum_of_two_2(A, val):
i = 0
j = len(A) - 1
while i < j:
s = A[i] + A[j]
if s == val:
return True
if s < val:
def sm(arr,val):
low = 0
hig = len(arr)-1
while low < hig:
sum = arr[low]+arr[hig]
if sum == val :
return True
if sum < val :
low+=1
@swarathesh
swarathesh / RoughWork.py
Created June 16, 2017 12:46
#day 4 min subset
def maxset(A):
minsum =0
maxsum = 0
minset=[]
maxseT=[]
for i in A :
if i >0:
minsum+=i
minset.append(i)