You are viewing a single comment's thread. Return to all comments →
Allison, thanks for the suggestion. Actually I added second 'if' to enhance readability, obviously that can be omitted. You can find a huge debate over the internet upon whether to bracket a single statement or not, so I won't go into that. Perhaps non-bracketing style have come into picture because of people moving out of C/Java style and working with Python/Haskell. Whatever is the reason, everything has its pros and cons. Avoiding it does "no harm"/"good", until you know what you are doing, well, it applies to any piece of code.
I usually look for an alternate/better solution even after solving the problem. That's why I wanted it to be more readable for someone looking for a different approach. Don't get mad over me because I didn't follow some particular style of coding. By the way, even "strcmp" is not needed that way, just check if t12=='P'. One doesn't code in "CodeGolf" and "Hackathon" alike. Here, I just gave an alternate approach with enhanced readability, if it helps someone, with belief that target audience is intelligent enough to shorten the code. I seriously had no intention to make it "inelegant". Though, thanks again for the suggestions, would surely help someone get better insight :)
"Don't get mad over me because I didn't follow some particular style of coding."
I'm not sure why you're getting defensive over my comment; I made a recommendation (in which I used the word "recommend") on brackets because it improves readability, reduces likelihood of introducing bugs into code, and is generally required form when coding professionally. You were not writing in Python or Haskell, you were writing in C.
You posted something and termed it as an "elegant" solution, I pointed out the parts with issues as "inelegant" (a word choice made due to your use of "elegant") for the benefit of new coders who might be using it to learn. Adding redundancy to your logic (by using a second 'if' for a follow-up conditional instead of an 'else-if' and needlessly checking for 'AM' when the t12 options are binary) is not elegant and would be kicked back during code review in a professional environment. I wasn't commenting on your use of strcmp at all, so I don't even know why you threw that comment in. The bottom line is that redundancy almost always decreases readability, so it's best to comment your code and not add unnecessary computation steps. Whether or not you care is up to you, it makes no difference to me, but I'm saying it for the benefit of anybody using the code you posted as a model.
Calm down Allison. I actually agreed to you that this can benefit someone and thats why also thanked you for the suggestion. I never said that its the best solution. I just told you why I wrote it that way.
Thanks for being sexist, you're a real gem!
You told me not to "get mad" when I just gave some constructive criticism and a suggestion for your solution, and are now following up by telling me to "calm down". To me, that's not embracing feedback.
Can I know why is my comment (with upvotes) deleted and not the comments with several downvotes ! Is it because the comment was from a common hackerrank member and not by a Moderator ? Please don't set a bad example by doing such things.
My exact comment was :
"Nitpicker spotted ! I'm not sure why will someone get so aggressive in her comments. Is it because Empty vessels make the most sound? AllisonP: Why don't you make better use of your aggression in some programming contest rather than finding faults here and there.
It was funny reading your comments. For a while, leave your personal choices aside and try google. You'll be shocked to know that a lot many programmers prefer not using unnecessary brackets for single line statements. Now, don't tell me that you know more because you are the best programmer in the world. That would be funnier. Lol !"
If you guys didn't find this comment appropriate, there are a lot of un-appropriate things in the other comments (numerous downvotes clearly state that). If the issue is that "some moderator" was addressed in the comment, then let me clarify that the comment was posted when the person was neither "moderator" nor the part of hackerrank team.
At least, I could have been notified once about the issues with the comment so that I could have modified it. But, deleting it without any notification is clearly not in the right spirit.
Perhaps it's a bit late, but one of the common assumptions people coming from Java make (including me) is to think that Java style is the source of truth.
Short answer is NO. There is a wonderful C code style, mostly supported by people like Kernighan and Ritchi which can be use as the "source of truth" for C code style: https://www.kernel.org/doc/Documentation/CodingStyle
I've got a simpler problem
I keep failing test case 4 but surely
on the 24 hours clock.... my stupid it isn't is it... doh!
Beats me why anyone would want to solve such a problem in C anyway though... surely this was what AWK was invented for.
There is an AWK to C converter too.