Sam I Am

  • 3
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(10)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
rajLevel 13 , Bhilai
5 May, 02:07
create different variable and shuffle them to find all combination
Lars HoogmaLevel 18 , Sneek
2 May, 14:14
I suggest using an array for the strings and 2 for loops for the printing.
Laurence Chadwell Level 7 , San Antonio
9 August 2019, 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 8
17 August 2019, 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.
anytaraliLevel 4
30 December 2019, 22:50
yeah, I tried some algorithm as well. but converting them into an array and then looping it with some logic, I am getting options where they are giving only 2 word combinations as well. like IAm and SamI
KIN SOCHEATLevel 25 , Phnom Penh
8 May 2019, 03:16
Follow the example
Mrunali PundeLevel 6 , Mumbai
6 March 2019, 18:50
Is there any shorter code for this?
deanLevel 8 , Deutschland
15 April 2019, 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 2019, 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 8
17 August 2019, 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.