Teacher diego

Sam I Am

  • 2
  • Locked
  • Exercise
I don't know why Dr. Suess's sadistic character Sam-I-Am wanted to badger others into eating green eggs and ham, but we admire his tenacity. Here at the secret CodeGym center we respect the classics. And we respect combinatorics. Hence, your task: display all possible combinations of the words "Sam", "I" and "Am".
You can't complete this task, because you're not signed in.
Comments (7)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Laurence Chadwell Level 4 , San Antonio
9 August, 18:26
I'm pretty sure there is a more efficient way to do this, but I tried a couple of solutions for the sake of learn, and they didn't really work.
Justin SmithLevel 4
Saturday, 02:09
I agree. I think a solution would be to make an array and counters for each word to be in each position twice, but I'm not sure if it would be more memory efficient and work efficient than just manually printing each statement.
KIN SOCHEATLevel 14 , Phnom Penh
8 May, 03:16
Follow the example
Mrunali PundeLevel 6 , Mumbai
6 March, 18:50
Is there any shorter code for this?
deanLevel 8 , Deutschland
15 April, 18:18
I wonder as well, i googled factorial a string/word but couldn't find a working solution except for integers..
RisbahLevel 3 , Birmingham
3 August, 13:58
I was trying to think of ways to do it...but it seems way above my programming level.... One idea I had was to put "I", "am", "sam" in an array....and then switch around the elements in the array with Random (somehow)....
Justin SmithLevel 4
Saturday, 02:10
Risbah, I think if you did your idea (without the random maybe) and made counters for each word to be in each position no more than twice it could work maybe? Not really sure.