armaghanwa
BAN USER"""
IMPLEMENTATION IN PYTHON.
CODE INSPIRED BY PeyarTheriyaa
Example 1:
Input < 10$
Output > 100 and 101
Example 2:
Input < 1$2$
Output > 1121, 1122, 1221, 1222
Stack Explanation for example of input 1:
Stack 0:
numberList = ['1','0']
c = '1'
pre = '1'
i = 0
Stack 1:
i = 1
c = '$'
pre = '10'
Stack 2:
i = 2
c = '$'
pre = '101'
Stack 3:
i = 3
break
print > 101
Stack 4:
i = 2
c = '$'
pre = '100'
Stack 5:
i = 4
break
print > 100
The $ should be replaced by the each preceding digit and displayed as output.
"""
def combinations(input,pre,i):
if (i < len(input)):
_char = input[i]
if _char >= '0' and _char <= '9':
combinations(input,pre + _char,i+1)
if _char == '$':
for j in numList:
combinations(input,pre+j,i+1)
else:
print(pre)
input = '10$'
numList = []
# Get the numbers saved to a list
for i in input:
if (i >= '0' and i <= '9'):
numList.append(i)
combinations(input,'',0)

armaghanwa
March 29, 2019 """"
Input Array
Requirement is to loop the Array such such that
1 234
  
5 6 7 8
   
9 1011 12
 
13141516
Python Code
"""
x =[
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]
]
flag = True
minColumn = 0
maxColumn = len(x)  1
maxRow = len(x)  1
minRow = 0
rowCursor = 0
colCursor = 0
while(flag):
#Move down
while(True):
rowCursor += 2
if (rowCursor >= maxRow):
rowCursor = maxRow
#minRow += 1
break
#Move left
while(True):
colCursor += 2
if (colCursor >= maxColumn):
colCursor = maxColumn
minColumn += 1
break
#Move up
while(True):
rowCursor = 2
if(rowCursor <= minRow):
rowCursor = minRow
maxRow = 1
minRow += 1
break
#Move right
while(True):
colCursor = 2
if(colCursor <= minColumn):
colCursor = minColumn
maxColumn = 1
break
if(minColumn >= maxColumn or minRow >= maxRow ):
flag = False
print(x[rowCursor][colCursor])

armaghanwa
March 28, 2019 ""
THIS IMPLEMENTATION IS JUST A PYTHON VERSION OF AN OLDER POST WITH SOME EXPLANATION
Input: Two arrays. One for interval and other for the price of each interval.
Compute: We need to find the best value for the time duration we rent out the car, such that
there is no intersection between the time intervals. For simplicity I have just use discrete time interval with no overlap.
""
def bestDeal():
## [s,e]
interval = ((1,2),(2,4),(4,10))
price_interval = (30,20,100)
max_price = 0
best_interval = 0
for i in range(0,len(interval)):
price_comp = price_interval[i]/(interval[i][1]  interval[i][0])
if max_price < price_comp:
max_price = price_comp
best_interval = i
print('Best Interval',interval[i],'at $',price_interval[i])
Replillyalaird, Associate at Achieve Internet
I am Lilly from Eau Claire USA, I am working as a manager in a Best products company. My interest ...
Repstacyrdavid, Associate at Abs india pvt. ltd.
Hi, I am Stacy working as a Cashier in Dollar store the US. I work for Us government to Collect ...
RepPriscillaRYoung, Aghori Mahakal Tantrik at Absolute Softech Ltd
Hi, I am Priscilla from California. I am working as a Business management consultant in Quality Merchant Services company. I ...
Open Chat in New Window
 armaghanwa April 01, 2019