from random import random_ui64, seed
from time import monotonic
fn draw(suits: List[String], faces: List[String], numbereds: List[Int]) raises -> String:
seed(int(monotonic()))
var rand_suit_idx = int(random_ui64(0, len(suits)))
var rand_suit = suits[rand_suit_idx]
# decide whether to use a face card or a numbered card
if random_ui64(0, 2) == 0:
var rand_face_idx = int(random_ui64(0, len(faces)))
return faces[rand_face_idx] + " of " + rand_suit
else:
var rand_numbered_idx = int(random_ui64(0, len(numbereds)))
return str(numbereds[rand_numbered_idx]) + " of " + rand_suit
fn main() raises -> None:
var suits = List[String]("Clubs", "Spades", "Hearts", "Diamonds")
var faces = List[String]("Jack", "Queen", "King", "Ace")
var numbered = List[Int](2, 3, 4, 5,6 , 7, 8, 9, 10)
print(draw(suits, faces, numbered))
from random import random_ui64, seed
from time import monotonic
fn draw(suits: List[String], faces: List[String], numbereds: List[Int]) raises -> String:
seed(int(monotonic()))
var rand_suit_idx = int(random_ui64(0, len(suits)))
var rand_suit = suits[rand_suit_idx]
# decide whether to use a face card or a numbered card
if random_ui64(0, 2) == 0:
var rand_face_idx = int(random_ui64(0, len(faces)))
return faces[rand_face_idx] + " of " + rand_suit
else:
var rand_numbered_idx = int(random_ui64(0, len(numbereds)))
return str(numbereds[rand_numbered_idx]) + " of " + rand_suit
fn main() raises -> None:
var suits = List[String]("Clubs", "Spades", "Hearts", "Diamonds")
var faces = List[String]("Jack", "Queen", "King", "Ace")
var numbered = List[Int](2, 3, 4, 5,6 , 7, 8, 9, 10)
print(draw(suits, faces, numbered))