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
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 def 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

Your question is IPv6 Parser. 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.