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

Return to Answer

deleted 44 characters in body
Source Link
AnttiP
  • 8k
  • 16
  • 64

Python 3.8 (pre-release), \$L=80\$\$L=79\$, \$N\approx255^{1500}\$

-23 bytes thanks to @Jonathan Allan

f=lambda b,s=0,l=0:b and f(b[1:],255*s+b[0],l+(l!=1500)l+1)or s.to_bytes(l-(l>1500),"big")

Try it online! Try it online!

Python source code can't contain null bytes. This converts the input (bytestring) to base 255 and then back to bytes. After 1500 removes a redundant byte.

Python 3.8 (pre-release), \$L=80\$, \$N\approx255^{1500}\$

-2 bytes thanks to @Jonathan Allan

f=lambda b,s=0,l=0:b and f(b[1:],255*s+b[0],l+(l!=1500))or s.to_bytes(l,"big")

Try it online!

Python source code can't contain null bytes. This converts the input (bytestring) to base 255 and then back to bytes. After 1500 removes a redundant byte.

Python 3.8 (pre-release), \$L=79\$, \$N\approx255^{1500}\$

-3 bytes thanks to @Jonathan Allan

f=lambda b,s=0,l=0:b and f(b[1:],255*s+b[0],l+1)or s.to_bytes(l-(l>1500),"big")

Try it online!

Python source code can't contain null bytes. This converts the input (bytestring) to base 255 and then back to bytes. After 1500 removes a redundant byte.

deleted 235 characters in body
Source Link
AnttiP
  • 8k
  • 16
  • 64

Python 3.8 (pre-release), \$L=80\$, \$N\approx255^{1500}\$

-2 bytes thanks to @Jonathan Allan

lambdaf=lambda b,s=0,l=0:0*[b and f(sb[1:=255*s+x],255*s+b[0],l+(l!=1500)for x in b]or)or s.to_bytes(len(b)-(len(b)>1500)l,"big")

Try it online! Try it online!

Python source code can't contain null bytes. This converts the input (bytestring) to base 255 and then back to bytes. After 1500 removes a redundant byte.

Python 3.8 (pre-release), \$L=80\$, \$N\approx255^{1500}\$

lambda b,s=0:0*[(s:=255*s+x)for x in b]or s.to_bytes(len(b)-(len(b)>1500),"big")

Try it online!

Python source code can't contain null bytes. This converts the input (bytestring) to base 255 and then back to bytes. After 1500 removes a redundant byte.

Python 3.8 (pre-release), \$L=80\$, \$N\approx255^{1500}\$

-2 bytes thanks to @Jonathan Allan

f=lambda b,s=0,l=0:b and f(b[1:],255*s+b[0],l+(l!=1500))or s.to_bytes(l,"big")

Try it online!

Python source code can't contain null bytes. This converts the input (bytestring) to base 255 and then back to bytes. After 1500 removes a redundant byte.

added 362 characters in body
Source Link
AnttiP
  • 8k
  • 16
  • 64

Python 3.8 (pre-release), \$L=82\$\$L=80\$, \$N\approx255^{1500}\$

f=lambdalambda b,s=0:0*[(s:=255*s+x)for x in b]or s.to_bytes(len(b)-(len(b)>1500),"big")

Try it online! Try it online!

Python source code can't contain null bytes. This converts the input (bytestring) to base 255 and then back to bytes. After 1500 removes a redundant byte.

Python 3.8 (pre-release), \$L=82\$, \$N\approx255^{1500}\$

f=lambda b,s=0:0*[(s:=255*s+x)for x in b]or s.to_bytes(len(b)-(len(b)>1500),"big")

Try it online!

Python source code can't contain null bytes. This converts the input (bytestring) to base 255 and then back to bytes.

Python 3.8 (pre-release), \$L=80\$, \$N\approx255^{1500}\$

lambda b,s=0:0*[(s:=255*s+x)for x in b]or s.to_bytes(len(b)-(len(b)>1500),"big")

Try it online!

Python source code can't contain null bytes. This converts the input (bytestring) to base 255 and then back to bytes. After 1500 removes a redundant byte.

Source Link
AnttiP
  • 8k
  • 16
  • 64
Loading

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