My Google interviews were similar. A guy had me write an algorithm for scoring bowling, then after everything asked me to "turn it into an API" without specifying anything beyond that.
I asked a few questions about the use cases and he refused to expand.
At that point I had no choice but to just start adding weird methods and turning the one-shot algorithm into an iterative scoring class (where you could calculate score as you added frames) and the guy started to nitpick literally everything I did.
"Why did you indent here?" Because a new block of code is there. "Why did you put the brace on the same line?" Because I like to follow 1tb style personally, but I can change it if you'd like. "Yes please do."
Then was rejected, without any feedback other than "perhaps consider brushing up on your coding abilities, or take a code camp and try again in 6 months". I've been writing code for 20 years, 11 professionally. It is, quite literally, almost all I ever do.
Ultimately realized how terrible of a company Google was, anyway, so I dodged a bullet in the end. But you just kind of have to learn to roll with these punches.