We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
"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.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Time Conversion
You are viewing a single comment's thread. Return to all comments →
"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.