6/19/2018 - 4:39 PM

## dailyQuestions

dailyQuestions

``````def createTargetFromTwoNumbers( target=9, array=[7,2,11,15]):
numbersIndexMap = {}
for i in range(0, len(array)):

number = array[i]

if number > target :
continue

try:

if type(numbersIndexMap[target-number]) is int :
return[ i, numbersIndexMap[target-number] ]
except:
print "cause I need to escape the except case"

numbersIndexMap[number]=i

def reverseNumber(number = 123):  ## I cheated

if number > 0:
sign = 1
else:
sign = -1

number = number * sign

## thanks to Qoura

reversed=0
while number > 0 :
digit = number%10
reversed = reversed*10+digit
number = number/10

return reversed * sign

print createTargetFromTwoNumbers()
print reverseNumber()
``````
``````def divide( upper = 10 , lower = 3):

absUpper = abs(upper)
absLower = abs(lower)

counter = 0
multiplicationResult = 0

while  multiplicationResult < absUpper :

counter = counter + 1
multiplicationResult = multiply(counter,absLower)

if  multiplicationResult > absUpper : ## handle if the results is decimal
counter = counter -1

if  upper < 0 or lower < 0  :  ## handle the -ve sign
return invertNumber(counter)

return counter

def multiply(a = 5 , b = 10 ):

number = a
for index in range(1, b): ## index isn't used

number = number + a

return number

def invertNumber(number):

return 0 - number

print divide()
``````