0
What is the test case #5 of the Code coach problem: Symbols?
My solution for the problem pass all the test cases except #5. and I don't find any problem in my code. So i am curious to know what the input is in test case #5.
14 Answers
+ 3
H S Share your code.
+ 3
H S
Change defined size 10 to 100
int initial_string_length=100;
int string_length_incr=100;
int init_str_len=100;
int str_len_incr=100;
+ 2
First you can code on the playground here and test with a few different imupts. So you can see what happend and find out the solution.
+ 2
H S Because in case 5 string size is more than our expected size. I think.
It may work with 30 also.
+ 2
AJ #Infinity Love Lol, i have just tried with value 1 just to see if it passes case#1 which has input length greater than 1 and weirdly it passes even case 5 😂😂.
+ 2
If I understand you correctly, your problem is that it doesn't tell you the last three test cases. Keep in mind that that's the point! If your code had no bugs, you wouldn't care about the case tester's arbitrary inputs.
Programmers don't just mentally juggle identifiers until they find the bug. Rather, they try to reproduce the bug. That way, they know that they fixed the bug if the output is correct and the inputs remain the same.
I suggest you copy paste your code into a code bit, then test it with arbitrary inputs until the bug appears.
+ 2
#it is very easy in python
x = input()
alpha = x
sym2 = x
sym = ["quot;,"#","@","*","!","&","%"]
for c in range(7):
alpha = alpha.replace(sym[c],"");
c += 1;
for z in range(10):
alpha = alpha.replace(str(z),"")
z += 1
numsym = x.replace(alpha,"")
num = numsym
for c in range(7):
num = num.replace(sym[c],"")
c += 1;
for j in range(len(alpha)):
sym2 = sym2.replace(alpha[j],"")
j += 1;
for v in range(len(alpha)):
num = num.replace(alpha[v],"")
v += 1;
for s in range(len(num)):
sym2 = sym2.replace(num[s],"")
s+=1
for k in range(len(sym2)):
x = x.replace(sym2[k],"")
k+=1
print (x)
+ 2
In python try this.
from string import *
def sym(inp):
for i in inp:
if i in ascii_letters:
print(i,end="")
elif i == " ":
print(end=" ")
elif i in digits:
print(i,end="")
else:
print(end="")
sym(input())
Try to find how it works. Any doubt I'll explain...
+ 1
Ja Play I have tried many
+ 1
Hampher no one really knows apart from sololearn guys
+ 1
Hampher Congratulation. Such as task will be solved usually with regex statement. So a code with the solution is very short. The size of input text is not limited. Possible characters are: letters, numbers and space.
0
AJ #Infinity Love , here is my code
https://code.sololearn.com/cUDXiijCimFn/?ref=app
0
AJ #Infinity Love It works. But i dont understand the logic why it does not work with 10.
0
AJ #Infinity Love but i used dynamic memory so if the string lenght is greater than 10 then it will increase the lenght during runtime.
I have just ran the program with the old value 10 and i gave it input string whose length is greater than 10 and it work