Absolutely it works that way. Nobody has a formula for coming up with jokes, they usually try different ones until people laugh. Guess and check. Exactly like taking SHA-256 hashes based on the Merkle tree until the hash, taken as a number, is less than or equal to the target.