3 kyu

No More 5's, Ever

52 of 69M1Miketro

Description:

Background

This kata is inspired by Don't give me five! Really! by zappa78, which is a step-up from the original Don't give me five by user5036852.

But this one is much harder than both of those. If you're having trouble with this kata, you're recommended to try one of the above.

Problem Description

In this kata, you are required to build a function that receives two arguments, a and b, and returns the number of integers between a and b inclusive that:

  • Do not contain the digit 5.
    • The following numbers contain the digit 5: 57, 512.
  • Are not divisible by 5.
    • The following numbers are divisible by 5: 100, 420.
  • Do not have exactly 5 digits.
    • The following numbers have 5 digits: 12345, 32767.
  • Are not perfect 5th powers.
    • The following numbers are 5th powers: 1, 32, 243, 1024.

Here are the first 10 positive numbers that should be counted: 2, 3, 4, 6, 7, 8, 9, 11, 12, 13. Negative numbers also count if they are in range.

Input Constraints

  • Fixed test cases: -100 ≤ a, b ≤ 100 (one hundred)

  • Fixed test cases: -10^5 ≤ a, b ≤ 10^5 (one hundred thousand)

  • Fixed test cases: -10^10 ≤ a, b ≤ 10^10 (ten billion)

  • Fixed test cases: -10^15 ≤ a, b ≤ 10^15 (one quadrillion)

Edge Cases

  • 0 is a multiple of 5 and a 5th power.

  • Note that 5th powers can be negative.

  • If a is greater than b, return 0.

Number Theory
Mathematics
Memoization

More By Author:

Check out these other kata created by M1Miketro

Stats:

CreatedMay 18, 2023
PublishedMay 19, 2023
Warriors Trained918
Total Skips71
Total Code Submissions2079
Total Times Completed69
Python Completions52
JavaScript Completions22
Total Stars49
% of votes with a positive feedback rating97% of 17
Total "Very Satisfied" Votes16
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes0
Total Rank Assessments6
Average Assessed Rank
3 kyu
Highest Assessed Rank
2 kyu
Lowest Assessed Rank
4 kyu
Ad
Contributors
  • M1Miketro Avatar
  • dfhwze Avatar
Ad