add some exercises

This commit is contained in:
julien committed 2026-10-13 20:33:50 +02:00
1 parent f6abf65e91
commit d79c543c72
13 files changed
+232

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
# Défi : interpréter une commande
#
# Tu construis une petite interface terminal.
#
# Écris la méthode `parse_command(input)`.
#
# Entrées possibles :
#
# "play 3"
# "help"
# "quit"
#
# Résultats attendus :
#
# parse_command("play 3")
# => { action: :play, card: 3 }
#
# parse_command("help")
# => { action: :help }
#
# parse_command("quit")
# => { action: :quit }
#
# Une commande invalide doit retourner :
#
# { action: :invalid }
#
# Exemples invalides :
#
# "play"
# "play three"
# "play 0"
# "play 3 extra"
# "hello"
#
# Contraintes :
# - accepte les espaces au début et à la fin ;
# - `play` n'accepte qu'un entier strictement positif ;
# - la commande doit respecter exactement une des formes prévues ;
# - ne lève pas d'exception pour une entrée invalide.
#
# Exemples supplémentaires :
#
# parse_command(" play 3 ")
# => { action: :play, card: 3 }
#
# parse_command("play 3 extra")
# => { action: :invalid }
def parse_command(input)
# À compléter.
end