Generate Random Regional Records

Quick Overview

Implement generation of N random integers, extend it to an inclusive numeric range, then create and print N objects whose number and one of three region labels are selected randomly.

Generate Random Regional Records

Company: Icapital

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

# Generate Random Regional Records Design and explain code for three related tasks: generate `N` random integers; generate `N` random integers within a requested range from `x` through `y`; and create `N` records containing a generated number plus a random region chosen from `US_EAST`, `US_WEST`, and `EU_WEST`. ### Constraints & Assumptions - Clarify the domain of the first unbounded request before implementing it. - State whether range endpoints are inclusive and whether uniform sampling is required. - The original task does not supply a seed, so exact generated values are not prescribed. ### Clarifying Questions to Ask - Which random-number generator and reproducibility requirements apply? - Can `x` exceed `y`, and how should invalid `N` or ranges be handled? - Are the three regions equally likely? ```hint Inject the source of randomness Separating random generation from record construction makes deterministic tests possible without changing production behavior. ``` ### What a Strong Answer Covers - A precise random domain and inclusive-range calculation. - Uniformity and avoidance of modulo bias where relevant. - A small record type with clear construction and output behavior. - Seeded or fake-generator tests for bounds, count, and region selection. ### Follow-up Questions - How would you make generation cryptographically secure? - How would you generate weighted, rather than uniform, regions?

Overview: Implement generation of N random integers, extend it to an inclusive numeric range, then create and print N objects whose number and one of three region labels are selected randomly.

|Home/Software Engineering Fundamentals/Icapital
Icapital logo
Icapital
Aug 25, 2026
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
0
0

Generate Random Regional Records

Design and explain code for three related tasks: generate N random integers; generate N random integers within a requested range from x through y; and create N records containing a generated number plus a random region chosen from US_EAST, US_WEST, and EU_WEST.

Constraints & Assumptions

  • Clarify the domain of the first unbounded request before implementing it.
  • State whether range endpoints are inclusive and whether uniform sampling is required.
  • The original task does not supply a seed, so exact generated values are not prescribed.

Clarifying Questions to Ask Guidance

  • Which random-number generator and reproducibility requirements apply?
  • Can x exceed y , and how should invalid N or ranges be handled?
  • Are the three regions equally likely?

What a Strong Answer Covers Guidance

  • A precise random domain and inclusive-range calculation.
  • Uniformity and avoidance of modulo bias where relevant.
  • A small record type with clear construction and output behavior.
  • Seeded or fake-generator tests for bounds, count, and region selection.

Follow-up Questions Guidance

  • How would you make generation cryptographically secure?
  • How would you generate weighted, rather than uniform, regions?
Loading comments...