Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Don't give me five!

Question :

You will be given the starting and ending integers of a sequence and should return the number of integers within it which do not contain the digit 5. The start and end numbers should be included!

Examples:

1,9 → 1,2,3,4,6,7,8,9 → Result 8

4,17 → 4,6,7,8,9,10,11,12,13,14,16,17 → Result 12

50,60 → 60 → Result 1

-59,-50 → → Result 0

The result may contain five.

The start number will always be smaller than the end number. Both numbers can be also negative!

I'm very curious for your solutions and the way you solve it. Maybe someone of you will find an easy pure mathematics solution.

Edit This is a code-golf challenge, so the shortest code wins.

Answer*

Draft saved
Draft discarded
Cancel
8
  • \$\begingroup\$ Isn't this PHP7.1 syntax? \$\endgroup\$ Commented Jan 20, 2017 at 10:06
  • \$\begingroup\$ @aross: It is. But PHP 7.1 is older than 5 hours (pubished on December, 1) \$\endgroup\$ Commented Jan 20, 2017 at 10:50
  • 1
    \$\begingroup\$ of course, I just asked because I'm used to specifying the version if it's 7 or up. That's also kind of the convention for Python \$\endgroup\$ Commented Jan 20, 2017 at 11:00
  • 1
    \$\begingroup\$ Convention for PHP - as far as I have seen - is to use the most recent version unless specified otherwise. \$\endgroup\$ Commented Jan 20, 2017 at 16:12
  • \$\begingroup\$ I don't think many people have the latest minor version. The least common denominator at the moment would probably be 5.5. Personally I'm using FC 25 (considered pretty cutting edge), which currently distributes PHP 7.0. If you're on Windows you probably need to update manually. \$\endgroup\$ Commented Jan 20, 2017 at 16:17

AltStyle によって変換されたページ (->オリジナル) /