3 ms·
Can I solve it? Yes. Is it a reflection of how well I can do my job? No. Will I be solving these kinds of problems at this job? Very unlikely. This is a massiv
by GiorgioG 6y ago
Can I solve it? Yes. Is it a reflection of how well I can do my job? No. Will I be solving these kinds of problems at this job? Very unlikely.
This is a massive waste of everyone's time and tells you nothing about the candidate's ability to do the job. Try again.
- d0mine 6y agoIf most candidates cannot solve it in 25 minutes (while being a simple task), then it is a valid test [(c, sum(1 for _ in same)) for c, same in itertools.groupby(s)]
- chrisandchris 6y agoDoes this a actually solve it? It should only sum when the character next to is the same as the previous. a is counted twice: ([a, 3], ... [a, 1]) While I agree that such interview questions are bad, they also give the interviewer a view on how the interviewee attempts to solve a problem. Edit: typo
- d0mine 6y agoYes, it does solve it. It produces the expected output (`a` should occur twice) Here's solution that doesn't use itertools.groupby() https://docs.python.org/3/library/itertools.html?highlight=itertools#itertools.groupby https://docs.python.org/3/library/itertools.html?highlight=i... : result = [] prev, count = None, 0 for c in s+"\0": # note: assuming "\0" can't be in `s` if c != prev: # starting new sequence if count: # save count for old sequence result.append((prev, count)) prev, count = c, 1 # reset count else: # continuation of old sequence count += 1
- chrisandchris 6y agoOk, thanks. I don‘t speak enough python to understand that it solves the issue.
- d0mine 6y agoPlease do comment if you downvote a correct solution.