New answers tagged

5

if key4 != key1 and key4 != key2 and key4 != key3: If you append to key_order upon picking a non-duplicate value you can just use in instead. You can then more simply use a for loop to select the number of keys to output. key_order = [] for _ in range(4): while True: key = random.randint(1, 4) if key not in key_order: ...


1

The logic here was kind of hard to understand, but I think this is an equivalent refactoring with comments inlined: open System open System.Security.Cryptography module Chars = let numbers = ['0'..'9'] let lower = ['a'..'z'] let upper = ['A'..'Z'] let special = ['!' .. '/'] @ ['@'] // First parse the arguments separately. Use a DU to let ...


1

I am not an expert at type level programming, but from my experience with folds I know that you can add an extra parameter to the result type to implement foldl in terms of foldr. Here is what that would look like in this case: newtype VecBuilder s m a = VecBuilder { buildVec :: s -> Vec m a } unfold' :: forall n a. SNatI n => (a -> (a, a)...


0

Your core has what looks to be an abandoned main guard that calls simplex_noise with an incorrect number of arguments. This should probably just be deleted. Consider adding PEP484 type hints to all of your function signatures, like def random_noise(size: int, seed: int) -> np.ndarray: The x/y loops in your noise functions should probably be converted into ...


Top 50 recent answers are included