The interviewer was very friendly. The question was a pivot table. I had reviewed this problem beforehand, but the input format was different from the one I had prepared for, so at the start I spent a long time confused about how to hook up to this input. The input format from my interview is below. The follow-up was to output running / grand totals on the x axis and the y axis. I ran out of time for the third part, and the interviewer didn't bring it up since we were out of time anyway. I got the first and second parts done (the values were correct, but the printed format was kind of ugly).
There was a small hiccup right at the start, something the interviewer probably didn't love: I jumped straight into writing a function. The interviewer wanted me to write a class, properly init it, take in the input, and only then write the function. I agree with the interviewer's approach. I haven't done an OOP-style problem in a long time and felt a bit rusty, which is my own problem lol. Good practice anyways.
SHIRTS = [
{"Store ID": "abcd1234", "Date": "2021-05-25", "Color": "red", "Size": "XS", "Shirts sold": 1},
{"Store ID": "abcd1234", "Date": "2021-05-25", "Color": "blue", "Size": "L", "Shirts sold": 20},
{"Store ID": "abcd1234", "Date": "2021-05-25", "Color": "green", "Size": "M", "Shirts sold": 300},
{"Store ID": "abcd1234", "Date": "2021-05-26", "Color": "red", "Size": "XS", "Shirts sold": 4},
{"Store ID": "abcd1234", "Date": "2021-05-26", "Color": "black", "Size": "S", "Shirts sold": 50},
{"Store ID": "5678wxyz", "Date": "2021-05-25", "Color": "blue", "Size": "XL", "Shirts sold": 600},
{"Store ID": "5678wxyz", "Date": "2021-05-25", "Color": "green", "Size": "M", "Shirts sold": 7},
{"Store ID": "5678wxyz", "Date": "2021-05-25", "Color": "black", "Size": "L", "Shirts sold": 80},
{"Store ID": "5678wxyz", "Date": "2021-05-26", "Color": "blue", "Size": "S", "Shirts sold": 900},
{"Store ID": "e1f9g2h8", "Date": "2021-05-26", "Color": "red", "Size": "S", "Shirts sold": 1},
{"Store ID": "e1f9g2h8", "Date": "2021-05-27", "Color": "black", "Size": "M", "Shirts sold": 20},
]
Discussion
Loading comments…