Shortest Solution in Python 3 for Caught Speeding - CodingBat
Python 3, 32 bytes
lambda a,b:(a-b*5>60)+(a-b*5>80)
Try it online!
Python 3, 50 bytes
If io must be done with stdin and stdout
s=int(input())-5*int(input());print((s>60)+(s>80))
Try it online!
Python 3, 51 45 bytes
lambda a,b:min(2,max(0,(a//1-5*b//1-41)//20))
Try it online!
I was able to shave 6 bytes from your approach by using everyone's favourite python golfing keyword: lambda
.
This turns your program into an anonymous function, which then can be called in the footer of a program.
Edit: I know that this question is way old, but I only just recently thought of using //1
to convert things to an integer instead of using int(...)
.