Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Print Numbers Ending Without 5

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Print Numbers Ending Without 5. Start with the requirements on the right.

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.

Problem

Orion Innovation's telemetry filters need to exclude numeric markers whose decimal representation ends in digit 5. Given two integers, return every integer between them, inclusive, whose absolute decimal value does not end in 5.

The result must be ordered from the smaller bound to the larger bound, even when the inputs are provided in reverse order. For this problem, -15 ends in 5, while -14 does not.

Formal Specification

Implement filter_range(start, end):

  1. Treat the interval as inclusive.
  2. Normalize the bounds so iteration proceeds in ascending order.
  3. Return a list of integers whose absolute value modulo 10 is not 5.
  4. Return an empty list only when no value in the interval satisfies the condition.

Constraints

  • -10^9 <= start, end <= 10^9
  • abs(end - start) <= 10^6
  • The interval is inclusive
  • The output must be ordered from the smaller bound to the larger bound

Function Signature

def filter_range(start, end):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output