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
4 RĂ©ponses
+ 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.
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.
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
0
It works now