Sam I Am

  • 3
  • Locked
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 (14)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Joe M
Level 47 , Owings Mills, United States
29 August 2020, 19:49
IntelliJ shortcut for System.out.println() is "sout + TAB". very helpful here
mastere
Level 9 , Rochester, United States
6 October 2020, 12:42
You can also use a loop or just use copy and paste ctrl + c to copy and ctrl + v to paste.
Ashish RajAnand
Level 13 , Bhilai , India
5 May 2020, 02:07
create different variable and shuffle them to find all combination
Lars Hoogma
Level 19 , Sneek, Netherlands
2 May 2020, 14:14
I suggest using an array for the strings and 2 for loops for the printing.
Lu Froz
Level 4 , Hackensack, United States
19 August 2020, 22:14
Hey Lars can you help me with the loop part of this? Thank you.
Roman
Level 41
21 August 2020, 05:55
Please use the Help section for questions relating to tasks.
Laurence Chadwell
Level 7 , San Antonio, United States
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 Smith
Level 8 , United States
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.
anytarali
Level 4 , United States
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 SOCHEAT
Level 34 , Phnom Penh, Cambogia
8 May 2019, 03:16
Follow the example
Mrunali Punde
Level 6 , Mumbai, India
6 March 2019, 18:50
Is there any shorter code for this?
dean
Level 8 , Deutschland, Germany
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..
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 Smith
Level 8 , United States
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.