How to write a program, and shuffles only the inner letter of the word?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How to write a program, and shuffles only the inner letter of the word, but leave the first and last letter of the word alone? Thank you
1 commentaire
Réponse acceptée
Image Analyst
le 29 Jan 2017
Try this:
word = 'abcdefgh'
middleIndexes = randperm(length(word)-2) + 1
newWord = [word(1), word(middleIndexes), word(end)]
Plus de réponses (2)
Stephen23
le 29 Jan 2017
>> str = 'This is really quite easy with regular expressions.';
>> regexprep(str,'(\w)(\w+)(\w)','$1${$2(randperm(numel($2)))}$3')
ans =
Tihs is rlleay qiute esay with rlgaeur esiorsxpens.
Jan
le 29 Jan 2017
Modifié(e) : Jan
le 29 Jan 2017
Acoicdnrg to a stduy of an Enlsigh unitsvreiy the odrer of carartehcs in a wrod deos not prevnet the riatdibaley, as lnog as the fsirt and lsat chetcraar are ccroert. The rset can be ctpemoelly mxeid and nsnneose, but it is sitll rdaleabe. Tihs wrkos, beasuce the wrdos are not raed certcaahr by ccrataher, but iifdnetied in toatl.
2 commentaires
Voir également
Catégories
En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!