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
Day-of-Week Logic
00:00
5 left

Day-of-Week Logic

HardPython

Problem

Recursion Pharmaceuticals schedules experiment milestones using Gregorian calendar dates. Given a target date, a reference date with a known weekday, and the reference weekday, calculate the target date's weekday without using Python's date or calendar libraries.

Implement a function that supports dates before or after the reference date. Use the proleptic Gregorian calendar, including the rule that century years are not leap years unless divisible by 400.

Formal Specification

Input consists of two dates represented as [year, month, day], plus the reference weekday as one of Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, or Sunday. Return the target date's weekday as a string.

The reference date is guaranteed to be valid, and the target date may occur on either side of it. The weekday supplied for the reference date is correct.

Constraints

  • 1 <= year <= 9999
  • Both dates are valid Gregorian dates.
  • The target date may be before, equal to, or after the reference date.
  • The reference weekday is one of the seven full English weekday names.
  • Do not use Python date or calendar libraries.

Function Signature

def weekday_from_reference(target_date, reference_date, reference_weekday):
Interviewer

Your question is Day-of-Week Logic. 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.