El texto del libro para niños Polar Bear, Polar Bear, What Do You Hear? Tiene un patrón muy simple. Puede usar el texto para enseñar conceptos introductorios de programación.
Mi hijo se aburrió rápidamente con esta idea, así que decidí jugar al golf con ella.
El reto
En el lenguaje de programación que elija, escriba el programa más pequeño posible que imprima el siguiente texto. La salida debe coincidir exactamente, incluyendo mayúsculas, minúsculas y puntuación.
Polar Bear, Polar Bear, what do you hear?
I hear a lion roaring in my ear.
Lion, Lion, what do you hear?
I hear a hippopotamus snorting in my ear.
Hippopotamus, Hippopotamus, what do you hear?
I hear a flamingo fluting in my ear.
Flamingo, Flamingo, what do you hear?
I hear a zebra braying in my ear.
Zebra, Zebra, what do you hear?
I hear a boa constrictor hissing in my ear.
Boa Constrictor, Boa Constrictor, what do you hear?
I hear an elephant trumpeting in my ear.
Elephant, Elephant, what do you hear?
I hear a leopard snarling in my ear.
Leopard, Leopard, what do you hear?
I hear a peacock yelping in my ear.
Peacock, Peacock, what do you hear?
I hear a walrus bellowing in my ear.
Walrus, Walrus, what do you hear?
I hear a zookeeper whistling in my ear.
Zookeeper, Zookeeper, what do you hear?
I hear children...
...growling like a polar bear,
roaring like a lion,
snorting like a hippopotamus,
fluting like a flamingo,
braying like a zebra,
hissing like a boa constrictor,
trumpeting like an elephant,
snarling like a leopard,
yelping like a peacock,
bellowing like a walrus...
that's what I hear.
B
y C
adentro Polar Bear
y Boa Constrictor
necesarias? (En Batch esto me cuesta el 10% de mi recuento de bytes ...)