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".
Sam I Am
- 3
Locked
Comments (14)
- Popular
- New
- Old
You must be signed in to leave a comment
Joe M
29 August 2020, 19:49
IntelliJ shortcut for System.out.println() is "sout + TAB".
very helpful here
+2
mastere
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.
+1
Ashish RajAnand
5 May 2020, 02:07
create different variable and shuffle them to find all combination
+3
Lars Hoogma
2 May 2020, 14:14
I suggest using an array for the strings and 2 for loops for the printing.
+1
Lu Froz
19 August 2020, 22:14
Hey Lars can you help me with the loop part of this? Thank you.
+1
Roman
21 August 2020, 05:55
Please use the Help section for questions relating to tasks.
0
Laurence Chadwell
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.
+1
Justin Smith
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.
0
anytarali
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
+1
KIN SOCHEAT
8 May 2019, 03:16
Follow the example
+1
Mrunali Punde
6 March 2019, 18:50
Is there any shorter code for this?
+4
dean
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..
0
hidden #10428740
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)....
0
Justin Smith
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.
0