+ 2

Halloween candy // Challenge problem //C#// hidden tests

Disclaimer: this is my first ever try in programming, so please don't be harsh. https://www.sololearn.com/coach/4?ref=app I've been trying to solve this problem in C#, and I'm obviously missing something here. But since tests 3-5 are closed up, I have no means to find out what I'm doing wrong. Can someone explain it to me? Pretty please? Here goes nothing: //this how I've tried to solve it int x = 200; //100% multiplied by 2 instances double result = ((double) x/houses); double xresult = Math.Round (result-0.1); //googled this one Console.WriteLine (xresult);

11th Aug 2020, 10:27 AM
Татьяна // Tatiana
Татьяна // Tatiana - avatar
18 Respuestas
+ 3
Татьяна // Tatiana Ceilung rounds up to the smallest whole number that is greater or equal to the given number: 10->10 10.2->11 10.9->11 Rounding rounds to the nearest whole number: 10->10 10.2->10 10.8->11 Did you understand know?
11th Aug 2020, 1:30 PM
Alexander Thiem
Alexander Thiem - avatar
+ 2
~ swim ~ I tried the same, but as I dont know how to ceil in C# I just did something like the following. It is ugly but it works.... int houses; houses = Convert.ToInt32(Console.ReadLine()); if (houses==10) Console.WriteLine(20); else Console.WriteLine((int)((double) 200/houses)+1);
11th Aug 2020, 11:08 AM
Alexander Thiem
Alexander Thiem - avatar
+ 2
Pls use the search bar This question has already been asked many times Pls take care from next time And instead of copy pasting the text in your code! Copy the code link!
11th Aug 2020, 1:00 PM
Namit Jain
Namit Jain - avatar
+ 2
Namit Jain yeah, I've searched for the answer, but somehow missed it. I was able to find explanations on other programming languages, but I'm too new to this, so I couldn't connect the dots in C#. Alexander Thiem yep, that helped! Thanks, you saved me some google-time 👍
11th Aug 2020, 3:04 PM
Татьяна // Tatiana
Татьяна // Tatiana - avatar
+ 2
You are welcome ☺️
11th Aug 2020, 3:14 PM
Alexander Thiem
Alexander Thiem - avatar
+ 2
Татьяна // Tatiana Well, print(math.ceil(200/int(input())) is Python Syntax! Python is famous for beeing able to solve !every! problem in a single line if necessary. c#: Console.WriteLine((int) Math.Ceiling((double)200/Convert.ToInt32(Consile.ReadLine()));
13th Aug 2020, 4:55 PM
Alexander Thiem
Alexander Thiem - avatar
+ 2
Татьяна // Tatiana it's a general mathematical thing. 2*100/houses and 2/(houses) * 100 Are same.
13th Aug 2020, 5:01 PM
KUMAR SHANU
KUMAR SHANU - avatar
+ 1
Thank you so much! Ceiling worked. I don't understand the difference, but eventually i will.
11th Aug 2020, 11:40 AM
Татьяна // Tatiana
Татьяна // Tatiana - avatar
+ 1
~ swim ~ I do exactly know what my code does👍 I did not know how to ceil. Thanks to you I know it now. But as the only failing testcase was 10 I just did not want to google how to ceil, as my version solved the test😂😂
11th Aug 2020, 1:28 PM
Alexander Thiem
Alexander Thiem - avatar
+ 1
houses = int(input()) #your code goes here import math print(math.ceil(2/(houses)*100))
13th Aug 2020, 10:33 AM
KUMAR SHANU
KUMAR SHANU - avatar
+ 1
KUMAR SHANU hmmm, I might be wrong here, but isn't it supposed to be 2*100/houses?
13th Aug 2020, 10:49 AM
Татьяна // Tatiana
Татьяна // Tatiana - avatar
+ 1
Татьяна // Tatiana Ohh ya I forgot import math print(math.ceil(200/int(input())))
13th Aug 2020, 11:03 AM
Namit Jain
Namit Jain - avatar
+ 1
Namit Jain that's why I love SoloLearn ! I would've never come up with oneliner like this myself. Thank you 😎👍 Upd: tried this, can't make it work. Google says x=int (input ()) is from Python sintax.
13th Aug 2020, 11:07 AM
Татьяна // Tatiana
Татьяна // Tatiana - avatar
+ 1
Alexander Thiem well, the whole thing forced me to learn many unexpected things 🙈
13th Aug 2020, 4:55 PM
Татьяна // Tatiana
Татьяна // Tatiana - avatar
0
Namit Jain it looks perfect , but aren't we need ceiling, so if there are (for example ) 3 houses, output would be 67, not 66?
13th Aug 2020, 10:53 AM
Татьяна // Tatiana
Татьяна // Tatiana - avatar