mirror of
https://github.com/Xevion/contest.git
synced 2025-12-09 14:06:49 -06:00
icpc 2018 problem E
This commit is contained in:
@@ -46,6 +46,8 @@ def processWord(word):
|
|||||||
# print(index, select, word[index:index + select[1]])
|
# print(index, select, word[index:index + select[1]])
|
||||||
word = word[:index] + (select[0].title() if select[2].istitle() else select[0]) + word[index + select[1]:]
|
word = word[:index] + (select[0].title() if select[2].istitle() else select[0]) + word[index + select[1]:]
|
||||||
# word[index:index + select[1]] = select[0]
|
# word[index:index + select[1]] = select[0]
|
||||||
|
index += len(select[0])
|
||||||
|
else:
|
||||||
index += 1
|
index += 1
|
||||||
return word
|
return word
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
725.85 1.71 2.38
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
100.00 20.00 10.00
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import os, sys
|
||||||
|
|
||||||
|
# Process a single input
|
||||||
|
def process(profit, pita, pizza):
|
||||||
|
maxPita, maxPizza = int(profit / pita), int(profit / pizza)
|
||||||
|
combos = [(x, y) for x in range(0, maxPita + 1) for y in range(0, maxPizza + 1)]
|
||||||
|
combos = filter(lambda item : profit == (pita * item[0]) + (pizza * item[1]), combos)
|
||||||
|
return '\n'.join(' '.join(map(str, combo)) for combo in combos)
|
||||||
|
|
||||||
|
# Driver code for all inputs in folder
|
||||||
|
def main():
|
||||||
|
# Read inputs
|
||||||
|
inputs = [os.path.join(sys.path[0], 'inputs', x) for x in
|
||||||
|
os.listdir(os.path.join(sys.path[0], 'inputs'))]
|
||||||
|
# Parse inputs
|
||||||
|
inputs = [list(map(float, open(path).read().split())) for path in inputs]
|
||||||
|
# Process inputs and print outputs
|
||||||
|
print('\n'.join(map(lambda item : process(*item), inputs)))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user