Skip to main content
added 4 characters in body; added 1 character in body
Source Link
4R1u
  • 51
  • 3

Python 3, 5555 40 bytes

Any help with golfing it would be appreciated

lambda N:lensum([x forx%10==2for x in range(N+1)if str(x)[-1]=="2"])

Lots of thanks to the commentors for helping me out( I have problems with memory, see names below)

Python 3, 55 bytes

Any help with golfing it would be appreciated

lambda N:len([x for x in range(N+1)if str(x)[-1]=="2"])

Lots of thanks to the commentors for helping me out( I have problems with memory, see names below)

Python 3, 55 40 bytes

Any help with golfing it would be appreciated

lambda N:sum(x%10==2for x in range(N+1))

Lots of thanks to the commentors for helping me out( I have problems with memory, see names below)

deleted 14 characters in body
Source Link
4R1u
  • 51
  • 3

Python 3, 5755 bytes

Any help with golfing it would be appreciated

    lambda N:len([x for x in range(N+1)
    if str(x)[-1]=="2"])

Lots of thanks to the commentors for helping me out( I have problems with memory, see names below)

Python 3, 57 bytes

Any help with golfing it would be appreciated

    lambda N:len([x for x in range(N+1)
    if str(x)[-1]=="2"])

Lots of thanks to the commentors for helping me out( I have problems with memory, see names below)

Python 3, 55 bytes

Any help with golfing it would be appreciated

lambda N:len([x for x in range(N+1)if str(x)[-1]=="2"])

Lots of thanks to the commentors for helping me out( I have problems with memory, see names below)

added 42 characters in body
Source Link
4R1u
  • 51
  • 3

Python 3, 57 bytes

Any help with golfing it would be appreciated

    k=0
  lambda N:len([x for nx in range(1,N+1): 
     if n%10==2:k+=1
    printstr(kx)[-1]=="2"])

Lots of thanks to the commentors for helping me out( I have problems with memory, see names below)

Python 3, 57 bytes

Any help with golfing it would be appreciated

    k=0
    for n in range(1,N+1): 
     if n%10==2:k+=1
    print(k)

thanks to the commentors for helping me out

Python 3, 57 bytes

Any help with golfing it would be appreciated

    lambda N:len([x for x in range(N+1)
    if str(x)[-1]=="2"])

Lots of thanks to the commentors for helping me out( I have problems with memory, see names below)

added 38 characters in body
Source Link
4R1u
  • 51
  • 3
Loading
added 1 character in body
Source Link
4R1u
  • 51
  • 3
Loading
Source Link
4R1u
  • 51
  • 3
Loading