So I am trying to create a function that would take in a word when the function is called and then randomly scramble the letters within it and return that new "word" back. I am trying not to use perms, randperm or randsample as I am trying to practice while loops. A friend suggested I try this challenge out but after working on it for many hours without success, I'm trying to see if this is actually possible, and if anyone can actually get a function with an input and output to work. I don't have much to show for the code used so far as a large portion of it I accidentally deleted. I am a self taught learner.
function output = scramble(input) X = size(input); while X > 0 idx = randi([1 X]); A(idx) = A(idx) + 1 ; output = X-1; end
Best Answer