Yes, pen and paper. The approach is to pseudocode the solution, minor syntax errors aren’t punished (and indeed are generally expected anyway). The point is to simply show that you understand and can work through the concepts involved, it’s not being literally compiled.
Writing a small algorithm with pen & paper on programming exams in universities of all sizes was still common when I was in uni in the 2010s and there’s no reason to drop that practice now.