Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2018-06-09 18:48:12

Amartyanil
Member
From: Universe
Registered: 2013-05-27
Posts: 82

String Permutations

Hi;

Is it possible rearrange the words in a string in every possible way. If yes, how to do it?


"Every place is the center of the universe. And every moment is the most important moment. And everything is the meaning of life." ~ Dan Harmon

Offline

#2 2018-06-20 05:19:57

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: String Permutations

Yes, it is definitely possible. You do it using recursion.

First, you try to answer the question, how do you do it if the string is empty. Then, you try to answer how to permute a string of length (n+1) if you knew how to permute a string of length n.


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

Board footer

Powered by FluxBB