Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3
Sankalp๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป I will give you a tip: Take input as a String using nextLine(). Use split(" ") method which returns a String array. E.g. "Hello World" -> [Hello, World] Then it should be much easier.
9th Jan 2020, 2:45 PM
Denise RoรŸberg
Denise RoรŸberg - avatar
+ 2
Jayakrishna punctuation does not count.
7th Jan 2020, 7:46 PM
Denise RoรŸberg
Denise RoรŸberg - avatar
+ 2
Denise RoรŸberg ok. I understood that.. In 1, reply, When I posting 1 or 2 words I missed to mention, after posting I edited that.. You may read it before that... OK. He just missing char count only.. Let us see, can he do it...
7th Jan 2020, 8:57 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 2
Sankalp๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป Math.ceil () + count only letters = solution. Edit: You can believe us. We have already solved this challenge. ;)
9th Jan 2020, 2:04 PM
Denise RoรŸberg
Denise RoรŸberg - avatar
+ 2
Sankalp๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป I am a bot confused about input -> XX:XX XX Maybe you confused the challenges. Looks like military time. But concrats that you solved it.
9th Jan 2020, 4:30 PM
Denise RoรŸberg
Denise RoรŸberg - avatar
+ 1
why you are adding space by n=" " +n. And use ceil function. There mentioned to round up...
7th Jan 2020, 7:12 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 1
Sankalp๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป No need to add space. If you add you will get extra word count... And use ceil function...
7th Jan 2020, 7:20 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 1
Sankalp๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป Using Math.ceil() is correct. Read the description and look at the testcase 1. "You have to remove all punctuation". Testcase 1 contains "?". That's why your code fails.
7th Jan 2020, 7:39 PM
Denise RoรŸberg
Denise RoรŸberg - avatar
+ 1
Sankalp๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป Yes. I missed that one more, with that your code by char++, the punctuation marks also counts so you need calculate only charecters ..
7th Jan 2020, 7:45 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 1
Denise RoรŸberg see his code... He is calculating all chars other than space... Iam also telling the same... I already solved it at the time of challenge...
7th Jan 2020, 7:50 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 1
Sankalp๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป Its simple... 1. Count chars without punctuations... 2. Count words Find avg by ceil function... I think it's better to, i give code.. Only you missing char count... Can you try one more time for char count..
7th Jan 2020, 7:55 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 1
Jayakrishna Sankalp๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป "Takes in a string, figure out the average length of all the words and return a number representing the average length. Remove all punctuation. Round up to the nearest whole number." Remove all punctuation! Case 1: Can you do that? can 3 you 3 do 2 that 4 -> 12 / 4 = 3 3.0 rounded up = 3 Case 2: The longest word in the dictionary is... the 3 longest 7 word 4 in 2 the 3 dictionary 10 is 2 -> 31 / 7 = 4.43 rounded up: 5
7th Jan 2020, 7:56 PM
Denise RoรŸberg
Denise RoรŸberg - avatar
+ 1
Sankalp๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป Round gives 4.42 to 4.0 4.78 to 5.0 Simply Belove 0.5 to 0.0 and above 0.5 to 1.0 ceil results both to 5.0 i.e(4.4, 4.7)
7th Jan 2020, 8:04 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 1
Sankalp๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป ceil() rounds always up. 3.0 -> 3.0 3.1 - 3.9 -> 4.0 round() 2.0 - 2.4 -> 2 2.5 - 2.9 -> 3
7th Jan 2020, 8:09 PM
Denise RoรŸberg
Denise RoรŸberg - avatar
+ 1
Jayakrishna I misunderstood you earlier. I thought you meant in the challenge you have to count punctuation marks. Instead, you meant that his code did it. Yes, I noticed that. I think we're done here. I don't know what else to mention.
7th Jan 2020, 8:51 PM
Denise RoรŸberg
Denise RoรŸberg - avatar
+ 1
Can you try it? Or can I give solution?
9th Jan 2020, 8:33 AM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 1
Sankalp๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป OK. I already mentioned that you missing in charecter count. Use ceil function. Look for those...
9th Jan 2020, 8:40 AM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 1
Sankalp๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป Just focus on description, not on the test cases...
9th Jan 2020, 8:49 AM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 1
Sankalp๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป we also prefer to solve by own.. So that's why I asked to try.. try... Just reminding what you missing.. We just want to know also what is your preference... But it seems that you are not picking the logic.. I faced that situation lot of times.. If I struck, and came back in other day to solve, it's better that to reset code and write again from the start... So do like this.. Try.. Try.. Again.. If need help then ask...
9th Jan 2020, 2:35 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
0
ndhdkdid
9th Jan 2020, 7:51 AM
Najib Dahir
Najib Dahir - avatar