3 ms·
Python: uses underscores. Java, Javascript: camelcase. .NET: Capitalize. And so forth, those are the conventions that professionals use, so stick to them for an
by ben509 7y ago
Python: uses underscores. Java, Javascript: camelcase. .NET: Capitalize. And so forth, those are the conventions that professionals use, so stick to them for an interview.
`biggestSize = 99999999 #MaxInt` This is returned if the caller passes you 0 for slicesToFind, so you're returning a nonsense value in that case. Either raise an exception (preferred as it catches errors fast) or return None.
`def area(size)` You're using pi r^2, so size is a radius, but it seems you call it with a diameter. This is why choosing distinct names is very important.
`newSize = (originalSize / newSlicesInCake)` Again, using "size" all over the place is confusing. I'd write something like `new_slice_area = (original_cake_area / new_slice_count)`.
- throwaway_a0f1 7y agoThanks for feedback about convention and variable naming- you're totally correct I should work on both. As far as 0 input, they actually told me it would always be valid so edge cases were not accounted for.
- ShamelessC 7y agoI personally think you had a strong answer despite the criticisms mentioned. But, yeah. Casing convention was surprisingly important in one of my interviews. They wanted to know that I was able to adapt to a new language as the job was for a language I didn't have on my resume. It's weird, but I understand where they're coming from. Seeing improper styling in a code review is an immediate red flag and an interview problem is ultimately a code review.