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
Start free
IPv6 Parser
00:00
5 left

IPv6 Parser

HardPython

Problem

Write an IPv6 parser. Example input 1234:abcd:0000:0000:0102:0000:00... should produce a byte array ending [..., 0, 0, 192, 128, 0, 1].

Asked in the onsite round 1 stage. The sample address and the tail of the expected byte array are quoted in the post; the middle is cut off by the points wall.

Implement ipv6_to_bytes(address). The input is a valid IPv6 address using hexadecimal groups and optional :: compression. Return a list of exactly 16 integers in network byte order, with values from 0 through 255.

Constraints

  • The input is a valid IPv6 address.
  • The address contains exactly eight 16-bit groups after expanding ::.
  • Each explicit group contains 1 to 4 hexadecimal characters.
  • At most one :: appears in the input.
  • Return exactly 16 integers, each in the range 0 through 255.

Function Signature

def ipv6_to_bytes(address):
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements are in the Question tab.

Sign up free to run or submit. Log in
Code
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 2
Run your code to see test output here.