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
String and Armstrong Number
00:00
5 left

String and Armstrong Number

MediumPython

Problem

Neudesic data-processing utilities often receive text alongside numeric configuration values. Implement one function that normalizes a text value and finds all Armstrong numbers within a specified range.

Your function must:

  1. Convert alphabetic characters to lowercase.
  2. Replace every non-alphanumeric character with a space.
  3. Collapse consecutive whitespace and remove leading or trailing whitespace.
  4. Reverse the order of the resulting words, without reversing characters within each word.
  5. Return every Armstrong number from 0 through limit, inclusive. A number is an Armstrong number when it equals the sum of each digit raised to the number of digits in the number.

Formal Specification

Input consists of an ASCII string text and a non-negative integer limit. Return a dictionary with two keys: transformed, a string, and armstrong_numbers, a list of integers in ascending order.

Examples

Example 1

Input: text = " Neudesic, Azure Team! ", limit = 500

Output: {"transformed": "team azure neudesic", "armstrong_numbers": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407]}

Punctuation becomes spaces, words are normalized, and their order is reversed.

Example 2

Input: text = "Python## Algorithms", limit = 10

Output: {"transformed": "algorithms python", "armstrong_numbers": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}

Constraints

  • 0 <= len(text) <= 10^5
  • 0 <= limit <= 10^6
  • text contains ASCII characters only.
  • Armstrong numbers must be returned in ascending order.

Constraints

  • 0 <= len(text) <= 10^5
  • 0 <= limit <= 10^6
  • text contains ASCII characters only
  • Armstrong numbers must be returned in ascending order

Function Signature

def process_neudesic_data(text, limit):
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.