Why this does get only 4 out of 5 solutions corect | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why this does get only 4 out of 5 solutions corect

I have this code and on the first test it gets it wrong could it be because the code takes the nearest int ? (Idk if that makes sense honestly) https://code.sololearn.com/cxuEjxsJkx1D/?ref=app

16th Feb 2021, 10:10 PM
i changed my name cuz it was cringe
i changed my name cuz it was cringe - avatar
4 Answers
+ 1
String.tr does not modify the string itself, but return a copy. Also, I wouldn't use string.tr in this case, but string.gsub. string.gsub is like string.tr but it uses regex instead of string literal. Though the question does not mention, but I think the letter count does not include punctuation marks. So use gsub to match multiple character to be removed. Use string.gsub!(/[?! \.]/, "") You also need to ceil the output, and swap the order of line 2 and line 3.
17th Feb 2021, 3:49 AM
你知道規則,我也是
你知道規則,我也是 - avatar
0
looking at the code without knowing Ruby, it looks like you’re trying to avoid using a loop with the space counter. this looks really cool and seems like it would work in most cases, however certain types of punctuation and other non-alpha characters might mess the program up. also, IDK what the tr method does cuz i dont know ruby 😸 I would double check to match the rounding system used by the code creators.
17th Feb 2021, 12:59 AM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
Eve i thought that the .length method counted the white spaces too so that s why i removed them it seems like i made myself work more
17th Feb 2021, 2:50 AM
i changed my name cuz it was cringe
i changed my name cuz it was cringe - avatar
0
It works now
17th Feb 2021, 3:50 AM
i changed my name cuz it was cringe
i changed my name cuz it was cringe - avatar