Dodany fragment w rubym i wejście ze słowami kluczowymi
This commit is contained in:
parent
5b79910c3e
commit
a0767a74c8
@ -1,47 +0,0 @@
|
|||||||
monty = ["left", "chess", "back", "load"]
|
|
||||||
|
|
||||||
|
|
||||||
def getWordsSendDict(myList = []):
|
|
||||||
|
|
||||||
output = {}
|
|
||||||
output['Movement'] = checkMovement(myList)
|
|
||||||
output['Direction'] = checkDirection(myList)
|
|
||||||
output['Action'] = checkAction(myList)
|
|
||||||
print(output)
|
|
||||||
return output
|
|
||||||
|
|
||||||
def checkMovement(myList = [], *args):
|
|
||||||
file = open("movement.txt", 'r')
|
|
||||||
content = file.readlines()
|
|
||||||
content = [x.strip('\n') for x in content]
|
|
||||||
for i in content:
|
|
||||||
for j in myList:
|
|
||||||
if j == i:
|
|
||||||
file.close()
|
|
||||||
return i
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
def checkDirection(myList = [], *args):
|
|
||||||
file = open("directions.txt", 'r')
|
|
||||||
content = file.readlines()
|
|
||||||
content = [x.strip('\n') for x in content]
|
|
||||||
for i in content:
|
|
||||||
for j in myList:
|
|
||||||
if j == i:
|
|
||||||
file.close()
|
|
||||||
return i
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
def checkAction(myList = [], *args):
|
|
||||||
file = open("actions.txt", 'r')
|
|
||||||
content = file.readlines()
|
|
||||||
content = [x.strip('\n') for x in content]
|
|
||||||
for i in content:
|
|
||||||
for j in myList:
|
|
||||||
if j == i:
|
|
||||||
file.close()
|
|
||||||
return i
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
|
|
||||||
getWordsSendDict(monty)
|
|
14
dictionary.rb
Normal file
14
dictionary.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
txt = open("input.txt")
|
||||||
|
|
||||||
|
filenames = ["actions.txt", "directions.txt", "movement.txt"]
|
||||||
|
dictionary = {}
|
||||||
|
|
||||||
|
txt.each_line do |line|
|
||||||
|
filenames.each do |name|
|
||||||
|
if File.read(name).include?line
|
||||||
|
dictionary[name.chomp('.txt')] = line.chomp("\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
puts dictionary
|
4
keywords.txt
Normal file
4
keywords.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
left
|
||||||
|
chess
|
||||||
|
back
|
||||||
|
load
|
Loading…
Reference in New Issue
Block a user