Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Learning a Proprietary Language On the Fly
00:00
5 left

Learning a Proprietary Language On the Fly

HardPython

Problem

How would you handle a coding interview where you must learn a proprietary language on the fly?

Implement an interpreter for the language specified below, using the syntax rules provided during the interview. Each program is a list of valid command strings.

The function receives program, a list of strings, and returns the integer values produced by PRINT commands in order. Supported commands are SET name operand, ADD name operand, MUL name operand, SWAP name1 name2, and PRINT name. An operand is either an integer literal or the name of an initialized variable.

Constraints

  • 1 <= len(program) <= 500
  • Each command contains valid syntax from the specified language
  • Variable names contain only letters and underscores
  • Every referenced variable has been initialized
  • Integer literals fit within standard Python integers
  • Commands execute in the order provided

Function Signature

def execute_program(program):
Interviewer

Your question is Learning a Proprietary Language On the Fly. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.