Password reset Помощ
https://pastebin.com/YbSrdLm4
Условието е от тук:
https://judge.softuni.org/Contests/Practice/Index/2303#0
Дава ми само 50/100 в judge, дадения инпут ми работи. Моля за помощ!
https://pastebin.com/YbSrdLm4
Условието е от тук:
https://judge.softuni.org/Contests/Practice/Index/2303#0
Дава ми само 50/100 в judge, дадения инпут ми работи. Моля за помощ!
;-)
string = input()
new_pass = string
while True:
command = input().split(' ')
if command[0] == "Done":
print(f"Your password is: {new_pass}")
break
elif command[0] == "TakeOdd":
current_pass = ""
for index in range(len(new_pass)):
if(index % 2 != 0):
current_pass += new_pass[index]
new_pass = current_pass
print(new_pass)
elif command[0] == "Cut":
fromm = int(command[1])
to = int(command[1]) + int(command[2])
new_pass = new_pass.replace(new_pass[fromm:to],"",1)
print(new_pass)
elif command[0] == "Substitute":
substr = command[1]
sub = command[2]
if substr in new_pass:
new_pass = new_pass.replace(substr, sub)
print(new_pass)
else:
print('Nothing to replace!')
Ето и едно решение на C#.:
https://pastebin.com/GMNQfTBp
Благодаря! Не мога да разбера защо така работи обаче :Д
The way your code was set up, it always depended on receiving TakeOdd as the first command, even though it is not stated that it will always be received as such. Your code had to be changed so that TakeOdd can be received as a possible command.
In addition, the initial password needs to be set to the initial predefined string.