[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Is Codechef a fucking retard?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 15
Thread images: 7

File: orami.png (252KB, 3888x3236px) Image search: [Google]
orami.png
252KB, 3888x3236px
Is codechef a fucking retard?
Or am I?

I have this problem to solve: https://www.codechef.com/problems/SUMTRIAN

And this was my proposed solution: http://pastebin.com/TuXJ0FUw

It follows the logic of pic related.

Works fine with the test values and some of my own.

Codechef says the answer is wrong.

Is it right or not?!
>>
File: the code.jpg (38KB, 587x795px) Image search: [Google]
the code.jpg
38KB, 587x795px
Have a more readable version of the code.
>>
>>58493702
>this feminine code
>>
>>58493702
From what I can tell your code look ahead at all, for example
Given
1
1 2
1 2 3
1 5 2 1

your code will sum 1, 2, 3, 2 and give the total 8.
However if it summed 1, 2, 2, 5 it would give the total 10.
Because it cannot step left once it picks the 3 it is stuffed.

Also, fix your indents and use braces all the time, sloppy shit makes the code less obvious (look at line 17 for example)
>>
>>58495157
whats wrong with 17? looks good to me.
>>
File: disgust.gif (2MB, 330x166px) Image search: [Google]
disgust.gif
2MB, 330x166px
>>58493702
>everything in main()
>>
>>58495182
Line 17 is not part of the for loop above it, because without braces only the following line is looped, yet it is indented the same as line 16 which is in the for loop.

Of course, it logically shouldn't be in the loop anyway or else the loop would loop infinitely, but that isn't the point.
>>
uhhh is codechef another spoj reskin?
>>
File: g.png (41KB, 577x462px) Image search: [Google]
g.png
41KB, 577x462px
This is my solution to the problem.
I haven't tested it much but it seems to work.
http://pastebin.com/5KsjfweP
>>
>>58495157
You can test my code at: https://www.codechef.com/ide just copying and pasting the pastebin and inserting the input you suggested. It outputs 10 as it should.
You didn't seem to understand my code, it tests every possibility.
>>
>>58495241
Come one man, it's a short code.
>>
File: the code.jpg (38KB, 550x832px) Image search: [Google]
the code.jpg
38KB, 550x832px
Okay I fixed the indentations.
The pastebin link remains the same.
Have the updated pic.

No one proved my code wrong yet.

Can it be that codechef just fucked up with the test cases and their supposedly correct outputs?
>>
File: 1401336151525.jpg (23KB, 450x444px) Image search: [Google]
1401336151525.jpg
23KB, 450x444px
>>58493702
>scanf
>>
>>58499271
cin from C++ consumes way too many resources figuring out the data type to make for a neat and clean solution.
>>
File: orami.png (73KB, 3888x3236px) Image search: [Google]
orami.png
73KB, 3888x3236px
There was another possible path and I didn't consider it.

Thanks everyone for your help.
Thread posts: 15
Thread images: 7


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.