OpenAI

Verified interview challenge

Infer return types in a toy language

Match concrete arguments to generic function types and construct the resulting return type.

Unlock with Full Access

The challenge

Work with a supplied object model for primitive types, nested tuples and generic function signatures. Format those types consistently, then infer a function's return type from the concrete arguments at a call site.

A generic can stand for an entire nested type and can appear more than once in a signature. The exercise tests structural matching and consistent substitution, with no parser to build.

What you'll practise

  • Recursive structure

    Compare and format nested types without losing their shape.

  • Generic consistency

    Carry bindings through repeated occurrences and construct the concrete output type.

Your coding workspacePreview
solution.pyPython 3.13
# Your implementation goes here

# Run examples and inspect results

# Full starter code included
Test cases

Run your code to see results.

Full instructions, starter code and test cases included with Full Access.