Skip to main content
10 events
when toggle format what by license comment
Jul 23, 2018 at 12:20 comment added Jo King If you're keeping it as a function, you can move the n=0 part into the header, like def x(a,b,n=0)
Jul 22, 2018 at 14:03 comment added Jonathan Allan FYI single spaces can work as indents too, so your 135 without any other golfing is really 114.
Jul 22, 2018 at 13:54 comment added Jonathan Allan 90 bytes using an unnamed function (declared as a lambda) and a sum for the counting - Try it online!. 86 is also possible by use of a clever golf by Asone Tuhid - lambda a,b:sum(sum(map(int,str(i)))==2*sum(map(int,str(i%1000)))for i in range(a,b+1))
Jul 22, 2018 at 13:38 history edited user8276 CC BY-SA 4.0
Implemented feedback from comments
Jul 21, 2018 at 22:15 comment added Jo King You can't take a and b as pre-declared variables. You either have to have a function or take them via input
Jul 21, 2018 at 17:08 comment added Asone Tuhid I'd suggest replacing n=n+1 with n+=1 and moving it right after the if statement (if...:n+=1)
Jul 21, 2018 at 17:07 comment added Asone Tuhid Welcome to PPCG! Check out Tips for golfing in Python for tips and tricks, there's a similar thread for most languages if you're interested. Also, it's good practice to include a TIO link as demonstration.
Jul 21, 2018 at 15:43 comment added Wheat Wizard You don't need the indentation after the if btw. Also it will probably be cheaper to convert to string before you take the first or last 3 digits.
Jul 21, 2018 at 15:36 review First posts
Jul 21, 2018 at 16:18
Jul 21, 2018 at 15:34 history answered user8276 CC BY-SA 4.0