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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Software Coding: Rock Paper Scissors
00:00
5 left

Software Coding: Rock Paper Scissors

EasyPython

Problem

For a ValueMomentum coding assessment simulator, process a sequence of Rock Paper Scissors rounds between two players. For each round, determine whether Player 1 wins, Player 2 wins, or the round is a draw, then return the complete result sequence and cumulative scores.

Formal Specification

Implement rock_paper_scissors(player1, player2), where player1 and player2 are arrays of equal length containing only the strings "rock", "paper", or "scissors". Return a dictionary with these keys:

  • results: an array containing "P1", "P2", or "Draw" for each round
  • player1_wins: the number of rounds won by Player 1
  • player2_wins: the number of rounds won by Player 2
  • draws: the number of drawn rounds
  • winner: "Player 1", "Player 2", or "Draw" based on cumulative scores

Use the standard rules: rock beats scissors, scissors beats paper, and paper beats rock. The winner is determined by a single pass through the rounds.

Constraints

  • 1 <= len(player1) = len(player2) <= 10^5
  • Every move is one of "rock", "paper", or "scissors"
  • Input arrays are guaranteed to have equal lengths

Function Signature

def rock_paper_scissors(player1, player2):
Interviewer

Your question is Software Coding: Rock Paper Scissors. 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.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.