Day 10: Binary Numbers :
import sys
n = int(raw_input().strip())
string = '{0:b}'.format(n)
array=string.split('0')
array.sort()
print len(array[len(array)-1])
Day 11: 2D-Arrays :
arr = []
max=-999
for arr_i in xrange(6):
arr_temp = map(int,raw_input().strip().split(' '))
arr.append(arr_temp)
for i in xrange(4):
for j in xrange(4):
temp=arr[i][j]+arr[i][j+1]+arr[i][j+2]+arr[i+1][j+1]+arr[i+2][j]+arr[i+2][j+1]+arr[i+2][j+2]
if temp > max:
max=temp
print max
import sys
n = int(raw_input().strip())
string = '{0:b}'.format(n)
array=string.split('0')
array.sort()
print len(array[len(array)-1])
Day 11: 2D-Arrays :
arr = []
max=-999
for arr_i in xrange(6):
arr_temp = map(int,raw_input().strip().split(' '))
arr.append(arr_temp)
for i in xrange(4):
for j in xrange(4):
temp=arr[i][j]+arr[i][j+1]+arr[i][j+2]+arr[i+1][j+1]+arr[i+2][j]+arr[i+2][j+1]+arr[i+2][j+2]
if temp > max:
max=temp
print max
No comments:
Post a Comment