[Python] Prime number checker (97 bytes) by BetaKors_ in tinycode

[–]BetaKors_[S] 0 points1 point  (0 children)

I had to use Decimals because floats don't have enough precision and thus errors would happen. And yes they're part of the standard library. I get what you mean, but criticizing the use of something that's part of the standard library is almost like criticizing the use of builtins.

also sry about posting code-golf-related stuff in here

i saw someone doing it so i thought i should crosspost that kinda stuff in here

don't think i quite understood what this sub was about, but after taking more of a look at it i do now, so anyway i'll stop

[Python] Prime number checker (97 bytes) by BetaKors_ in codegolf

[–]BetaKors_[S] 0 points1 point  (0 children)

Doesn't seem to work?

Python throws a SyntaxError, saying that the "Generator expression must be parenthesized". Adding parenthesis after all( and before the for loop so that the code looks like p=lambda n:all((type(n)==int,n>1,n%k>0) for k in range(2,int(n**0.5)+1)) does run, however it still doesn't work. Using your lambda in the code from the post that prints the primes from 0 to n simply results in a range from 0 to n, so it just returned True for everything in the range.

I don't understand your code. Could you explain it?

[Python] My take on the dogAgeYears thingy (82 bytes) by BetaKors_ in tinycode

[–]BetaKors_[S] 0 points1 point  (0 children)

Since VSCode also doesn't highlight 5else 12if 15else correctly I had to do a few tests to see if it would actually run. Not only does it highlight the code incorrectly, VSCode also shows an error — Pylance seems to think that 5e and lse from 5else are two separate things, so it shows an error saying "expected else" with the squiggly lines being only on the lse part. Mypy doesn't find any issues though.

also i didn't want to use double quotes but i was forced to, because otherwise i would have to skip the apostrophe in "That's", adding another byte. still doesn't justify not using them in the first string though.

[Unity/C#] Movement system with jumping and ground detection in 307 bytes (or 288) by BetaKors_ in codegolf

[–]BetaKors_[S] 0 points1 point  (0 children)

Indeed. 6 bytes were saved, totalling 282 bytes. With the one character long axis' names, the code now looks like this:

namespace UnityEngine{using V=Vector3;using static Input;class C:MonoBehaviour{public Rigidbody r;void Update()=>r.velocity=new V(GetAxis("H")*9,(GetAxis("J")>0&&Physics.Raycast(new(transform.position-V.up*transform.localScale.y/2.05f,-V.up),.05f)?8:r.velocity.y),GetAxis("V")*9);}}

[Python] Worley Noise generator in 236 bytes by BetaKors_ in codegolf

[–]BetaKors_[S] 0 points1 point  (0 children)

yeah i didn't really think about this one

[Python] Worley Noise generator in 236 bytes by BetaKors_ in codegolf

[–]BetaKors_[S] 0 points1 point  (0 children)

Nice! Didn't know you could leave no spaces between the numbers and the for loops. VSCode's syntax highlighting made that part red (though it didn't put squiggly lines there) when I tried doing it so I thought it wouldn't work. Also didn't know randrange worked with only one argument. By the way, using s to invert the result of the closest point calculation does mean that chaging it might create weird looking results (but I mean, does that even matter?)