Here's how you can create a function in Swift that takes a string as a parameter and returns a seeded random number between 1 and 10:
main.swift363 chars13 lines
Explanation:
srand48
sets the seed based on the hash value of the input string. This ensures that the same input string will always produce the same random number.drand48
generates a random double between 0 and 1.ceil
rounds up the result of randomNumber * 10
to get a number between 1 and 10.gistlibby LogSnag