PracHub
QuestionsLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Shopify

Parse a CSV and Generate a Gift Exchange

Last updated: Jul 28, 2026

Quick Overview

Parse escaped CSV participant data and generate a one-to-one gift exchange in which nobody is assigned to themselves. Cover malformed rows, duplicate emails, small inputs, randomness requirements, reproducible tests, privacy, and possible forbidden-pair extensions.

  • medium
  • Shopify
  • Software Engineering Fundamentals
  • Software Engineer

Parse a CSV and Generate a Gift Exchange

Company: Shopify

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

# Parse a CSV and Generate a Gift Exchange Implement a small gift-exchange service. The input is CSV text with headers `name,email`. Parse valid participants and return assignments in which every participant gives to exactly one other participant, receives from exactly one participant, and nobody is assigned to themselves. Explain how randomness is produced, which malformed rows are rejected, and how the result is tested. Assume emails uniquely identify participants. The function should return a structured error when fewer than two valid participants remain or when an email appears more than once. ### Constraints & Assumptions - Names may contain commas or quotes according to normal CSV escaping rules. - Leading and trailing whitespace around an email is ignored; email comparison is case-insensitive. - The exchange does not require uniform sampling from every possible derangement unless the caller explicitly requests that stronger property. - Do not email participants or persist personal data as part of this exercise. ### Clarifying Questions to Ask - Is any valid no-self assignment acceptable, or must every derangement be equally likely? - Are household or historical-pair exclusions required? - Should invalid rows fail the whole import or be reported individually? - Must repeated runs be reproducible from a seed for testing? ### What a Strong Answer Covers ```premium-lock What a Strong Answer Covers ``` ### Follow-up Questions - How would you add forbidden pairs? - How would you provide verifiable randomness? - How would you safely notify participants without revealing the full assignment graph?

Quick Answer: Parse escaped CSV participant data and generate a one-to-one gift exchange in which nobody is assigned to themselves. Cover malformed rows, duplicate emails, small inputs, randomness requirements, reproducible tests, privacy, and possible forbidden-pair extensions.

Related Interview Questions

  • Harden a URL-Caching HTTP Service for Production - Shopify (medium)
  • Use AI Responsibly During SQL Pair Programming - Shopify (medium)
  • How would you improve AI-generated code? - Shopify (easy)
  • Demonstrate Git and build workflow - Shopify (medium)
|Home/Software Engineering Fundamentals/Shopify

Parse a CSV and Generate a Gift Exchange

Shopify logo
Shopify
Jul 8, 2026, 12:00 AM
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
0
0

Parse a CSV and Generate a Gift Exchange

Implement a small gift-exchange service. The input is CSV text with headers name,email. Parse valid participants and return assignments in which every participant gives to exactly one other participant, receives from exactly one participant, and nobody is assigned to themselves.

Explain how randomness is produced, which malformed rows are rejected, and how the result is tested. Assume emails uniquely identify participants. The function should return a structured error when fewer than two valid participants remain or when an email appears more than once.

Constraints & Assumptions

  • Names may contain commas or quotes according to normal CSV escaping rules.
  • Leading and trailing whitespace around an email is ignored; email comparison is case-insensitive.
  • The exchange does not require uniform sampling from every possible derangement unless the caller explicitly requests that stronger property.
  • Do not email participants or persist personal data as part of this exercise.

Clarifying Questions to Ask Guidance

  • Is any valid no-self assignment acceptable, or must every derangement be equally likely?
  • Are household or historical-pair exclusions required?
  • Should invalid rows fail the whole import or be reported individually?
  • Must repeated runs be reproducible from a seed for testing?

What a Strong Answer Covers Premium

Follow-up Questions Guidance

  • How would you add forbidden pairs?
  • How would you provide verifiable randomness?
  • How would you safely notify participants without revealing the full assignment graph?
Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Shopify•More Software Engineer•Shopify Software Engineer•Shopify Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.