Return to Snippet

Revision: 66588
at May 31, 2014 15:49 by rikesh_kisnah


Initial Code
#!/usr/bin/python
import logging
import csv 
from inspect import currentframe, getframeinfo

logger = logging.getLogger('root')
FORMAT = "[%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s"
logging.basicConfig(format=FORMAT)
#logger.setLevel(logging.NOTSET)
logger.setLevel (logging.DEBUG)


def sum(array):
  logger.debug ("array function")  
  if len(array) < 2:
    print "Error! Array small"
    return -1

  array.sort() 
  print "Sorted array : %s" %array 
  print "%d %d" % (array[0],array[1])
  return array[0] + array[1]

if __name__ == "__main__":
  mylist = [10,3,4,1,7]
  x = sum(mylist) 
  print "sum of 2 min numbers : %d" %x

Initial URL

                                

Initial Description
Find sum of 2 smallest number

Initial Title
An interview question

Initial Tags

                                

Initial Language
Python