This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from LinkedListpract.LinkedList import LinkedList | |
| linkedlist = LinkedList() | |
| linkedlist.insertstart(1) | |
| linkedlist.insertstart(2) | |
| linkedlist.insertend(12) | |
| linkedlist.traverse() | |
| print("\n") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| m = int(input("enter m")) | |
| n = int(input("enter n")) | |
| abso = m-n if m-n>0 else (m-n)*-1 | |
| print abso |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def maxset(A): | |
| minsum =0 | |
| maxsum = 0 | |
| minset=[] | |
| maxseT=[] | |
| for i in A : | |
| if i >0: | |
| minsum+=i | |
| minset.append(i) |
OlderNewer