Kodewick
Commencer à apprendre →
Débutant←→0 / 70

L’hôtel pour animaux

#037Débutant_, ok := rooms[pet]2 min

L’hôtel pour animaux tient à jour rooms : le numéro de chambre de chaque animal. Écris IsStaying(rooms, pet) pour renvoyer true si l’animal y séjourne, et false sinon. La chambre 0 est une vraie chambre, elle aussi.

Exemples
IsStaying(map[string]int{"Mochi": 3, "Bean": 5}, "Bean")→True
IsStaying(map[string]int{"Mochi": 3}, "Rex")→False
La fonctionfunc IsStaying(rooms map[string]int, pet string) bool
main.go
package main

func IsStaying(rooms map[string]int, pet string) bool {
	// ton code ici: cherche pet dans rooms; renvoie true s'il y est
	return false
}
Ctrl + Entrée lance aussi le code
Résultat

Exécuter teste les exemples. Quand ils sont bons, appuie sur Envoyer.