comp.lang.ada
 help / color / mirror / Atom feed
* How to shuffle/jumble letters of a given word?
@ 2015-06-28 14:06 Trish Cayetano
  2015-06-28 15:52 ` David Botton
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Trish Cayetano @ 2015-06-28 14:06 UTC (permalink / raw)


I am creating a "text twist game" where you guess the words in a jumbled manner. How do I set the code to shuffle the letters? 

Example: word to be guessed is HELLO

What should be displayed is: LOLEH or LELHO

Thanks in advance!

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-06-28 14:06 How to shuffle/jumble letters of a given word? Trish Cayetano
@ 2015-06-28 15:52 ` David Botton
  2015-06-28 16:01   ` Anh Vo
  2015-06-28 21:07 ` Simon Wright
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: David Botton @ 2015-06-28 15:52 UTC (permalink / raw)


Which part of how do you know already? Code something as close as you can and post it and we would help, but you will learn little if we do it for you.

David Botton

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-06-28 15:52 ` David Botton
@ 2015-06-28 16:01   ` Anh Vo
  0 siblings, 0 replies; 17+ messages in thread
From: Anh Vo @ 2015-06-28 16:01 UTC (permalink / raw)


On Sunday, June 28, 2015 at 8:52:52 AM UTC-7, David Botton wrote:
> Which part of how do you know already? Code something as close as you can and post it and we would help, but you will learn little if we do it for you.
> 

I agree with David entirely. Just a hint, what algorithm is the word shuffle associated with?

Anh Vo


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-06-28 14:06 How to shuffle/jumble letters of a given word? Trish Cayetano
  2015-06-28 15:52 ` David Botton
@ 2015-06-28 21:07 ` Simon Wright
  2015-06-28 21:23   ` Jeffrey R. Carter
  2015-06-29 13:42 ` darkestkhan
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Simon Wright @ 2015-06-28 21:07 UTC (permalink / raw)


Trish Cayetano <trishacayetano@gmail.com> writes:

> I am creating a "text twist game" where you guess the words in a
> jumbled manner. How do I set the code to shuffle the letters?
>
> Example: word to be guessed is HELLO
>
> What should be displayed is: LOLEH or LELHO

You want to take the letters in a random order, so you'll find
Ada.Numerics.Float_Random[1] useful.

You can't just take the random'th character of the original string,
because you mustn't take the same character twice.

One (possibly heavyweight) approach would be to create a new type
containing a float and a character,

   type Item is record
      Key : Float;
      Ch  : Character;
   end record;

and a type for an array of Items, rather like the String you want to
jumble,

   type Elements is array (Positive range <>) of Item;

and then instantiate Ada.Containers.Generic_Array_Sort[2] for Elements.
You'll need a function "<" to compare two Items on the basis of their
Keys, e.g.

   function "<" (L, R : Item) return Boolean is (L.Key < R.Key);

Then, given a String, create an Elements array with each Key a new
random number and each Ch the corresponding character in the String;
sort it (which, since the Keys were random, is effectively a shuffle);
and return a String formed of the Chs in their new order.

[1] http://www.ada-auth.org/standards/12rm/html/RM-A-5-2.html
[2] http://www.ada-auth.org/standards/12rm/html/RM-A-18-26.html#p2

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-06-28 21:07 ` Simon Wright
@ 2015-06-28 21:23   ` Jeffrey R. Carter
  2015-06-29  8:05     ` Simon Wright
  0 siblings, 1 reply; 17+ messages in thread
From: Jeffrey R. Carter @ 2015-06-28 21:23 UTC (permalink / raw)


On 06/28/2015 02:07 PM, Simon Wright wrote:
> 
> Then, given a String, create an Elements array with each Key a new
> random number and each Ch the corresponding character in the String;
> sort it (which, since the Keys were random, is effectively a shuffle);
> and return a String formed of the Chs in their new order.

You could also just sort the String.

-- 
Jeff Carter
"Apart from the sanitation, the medicine, education, wine,
public order, irrigation, roads, the fresh water system,
and public health, what have the Romans ever done for us?"
Monty Python's Life of Brian
80

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-06-28 21:23   ` Jeffrey R. Carter
@ 2015-06-29  8:05     ` Simon Wright
  2015-06-29  8:13       ` Dmitry A. Kazakov
  2015-06-29 18:04       ` Jeffrey R. Carter
  0 siblings, 2 replies; 17+ messages in thread
From: Simon Wright @ 2015-06-29  8:05 UTC (permalink / raw)


"Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> writes:

> On 06/28/2015 02:07 PM, Simon Wright wrote:
>> 
>> Then, given a String, create an Elements array with each Key a new
>> random number and each Ch the corresponding character in the String;
>> sort it (which, since the Keys were random, is effectively a shuffle);
>> and return a String formed of the Chs in their new order.
>
> You could also just sort the String.

I don't see how this would work?

Though I see I made myself less than clear. At the risk of solving even
more of the OP's problem for her than I already have,

      Keyed : Elements (Str'Range);
   begin
      for J in Str'Range loop
         Keyed (J) := (Ada.Numerics.Float_Random.Random (Gen), Str (J));
      end loop;
      Sort (Keyed);

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-06-29  8:05     ` Simon Wright
@ 2015-06-29  8:13       ` Dmitry A. Kazakov
  2015-06-29 18:04       ` Jeffrey R. Carter
  1 sibling, 0 replies; 17+ messages in thread
From: Dmitry A. Kazakov @ 2015-06-29  8:13 UTC (permalink / raw)


On Mon, 29 Jun 2015 09:05:50 +0100, Simon Wright wrote:

> "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> writes:
> 
>> On 06/28/2015 02:07 PM, Simon Wright wrote:
>>> 
>>> Then, given a String, create an Elements array with each Key a new
>>> random number and each Ch the corresponding character in the String;
>>> sort it (which, since the Keys were random, is effectively a shuffle);
>>> and return a String formed of the Chs in their new order.
>>
>> You could also just sort the String.
> 
> I don't see how this would work?
> 
> Though I see I made myself less than clear. At the risk of solving even
> more of the OP's problem for her than I already have,
> 
>       Keyed : Elements (Str'Range);
>    begin
>       for J in Str'Range loop
>          Keyed (J) := (Ada.Numerics.Float_Random.Random (Gen), Str (J));

It should be non-repeating random numbers in this case, provided
"shuffling" meant permutation.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-06-28 14:06 How to shuffle/jumble letters of a given word? Trish Cayetano
  2015-06-28 15:52 ` David Botton
  2015-06-28 21:07 ` Simon Wright
@ 2015-06-29 13:42 ` darkestkhan
  2015-06-29 20:21 ` Austin Obyrne
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: darkestkhan @ 2015-06-29 13:42 UTC (permalink / raw)


On Sunday, June 28, 2015 at 2:06:29 PM UTC, Trish Cayetano wrote:
> I am creating a "text twist game" where you guess the words in a jumbled manner. How do I set the code to shuffle the letters? 
> 
> Example: word to be guessed is HELLO
> 
> What should be displayed is: LOLEH or LELHO
> 
> Thanks in advance!

Take the word to be guessed and permute it... there are some standard algorithms for permutations (like Knuth shuffle), check them up.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-06-29  8:05     ` Simon Wright
  2015-06-29  8:13       ` Dmitry A. Kazakov
@ 2015-06-29 18:04       ` Jeffrey R. Carter
  2015-07-02 20:56         ` Randy Brukardt
  1 sibling, 1 reply; 17+ messages in thread
From: Jeffrey R. Carter @ 2015-06-29 18:04 UTC (permalink / raw)


On 06/29/2015 01:05 AM, Simon Wright wrote:
> "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> writes:
> 
>> You could also just sort the String.
> 
> I don't see how this would work?

"HELLO" sorted would become "EHLLO"; "WATER", "AERTW"; "ART", "ART". All
possible random permutations of the original word.

-- 
Jeff Carter
"I did not rob a bank. If I'd robbed a bank, everything
would be great. I tried to rob a bank, is what happened,
and they got me. I misspelled the note."
Take the Money and Run
140

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-06-28 14:06 How to shuffle/jumble letters of a given word? Trish Cayetano
                   ` (2 preceding siblings ...)
  2015-06-29 13:42 ` darkestkhan
@ 2015-06-29 20:21 ` Austin Obyrne
  2015-06-29 21:45 ` MM
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Austin Obyrne @ 2015-06-29 20:21 UTC (permalink / raw)


On Sunday, June 28, 2015 at 3:06:29 PM UTC+1, Trish Cayetano wrote:
> I am creating a "text twist game" where you guess the words in a jumbled manner. How do I set the code to shuffle the letters? 
> 
> Example: word to be guessed is HELLO
> 
> What should be displayed is: LOLEH or LELHO
> 
> Thanks in advance!

Hi Trish,

This may not be sophisticated enough for what you want but it works.
Try it with the word "Milestone"
Note: You must set the 'wordlength' and the scrambling parameters ('Step' and 'Repeats') to suit - *the product of those must not exceed the 'Wordlength' other wise they will fall off the end of the arrays.

I can do better if you really want to include sentences or groups of letters as words also.

Cheers - Austin

With Ada.Text_IO;
With Ada.Integer_Text_IO;
Procedure Scramble_Letters is
-------------------------------------------------------------------------
--| The program reads in a prescribed word of declared length 
--| from the key board stores the characters and scrambles them.
------------------------------------------------------------------------- 
   X    : Integer;
  Total : Integer;
 
  WordLength: Constant Integer:= 9; -- set the wordlength here
  
  Step    : Constant Integer := 4;
  Repeats : Constant Integer := 2;
  -- Step x Repeats =< WordLength --

  SUBTYPE Index_1 IS Positive RANGE 1 .. 100;
  Type ReadInArray IS ARRAY (Index_1) OF Character;
  NextChar: ReadInArray:= (others => ' ');  -- Stores the plaintext 'NextChar' items being read in.

  SUBTYPE Index_2 IS Positive RANGE 1 .. 100000;
  TYPE UnscrambledNextChars IS ARRAY (Index_2) OF Character;
  Alpha :  UnscrambledNextChars := (others => ' '); -- before scrambling

  SUBTYPE Index_3 IS Positive RANGE 1 .. 100000;
  TYPE ScrambledNextChars_Array IS ARRAY (Index_3) OF Character;
  Beta : ScrambledNextChars_Array := (others => ' '); --after scrambling

          ----------------------------------------------------------

  PROCEDURE Load_n_Scramble_Letters IS
  -- Pre : nil
  -- Post: nil

BEGIN  -- Load_n_Scramble_Letters

  FOR I IN 1 .. Total LOOP
   Alpha(I):= NextChar(I);
   Beta (I):= NextChar(I);
  END LOOP;
  Ada.Text_IO.New_Line(2);
  Ada.Text_IO.Put(Item => "                                Before    After ");--
    X := 0;
  FOR Repeater IN 1 .. Repeats LOOP
  FOR Count IN REVERSE X+1 .. X+Step LOOP
    X:=X+1;
  Beta(X) := Alpha(Count);
  Ada.Text_IO.New_Line(1);  --
  Ada.Text_IO.Put(Item => "                                  ");--
  Ada.Text_IO.Put(Item => Alpha(X));  --
  Ada.Text_IO.Put(Item => "         ");--
  Ada.Text_IO.Put(Item => Beta(X));  --
  END LOOP;
    Ada.Text_IO.New_Line;--
    Ada.Text_IO.Put(item => "                                ---------------");--
  END LOOP;
End Load_n_Scramble_Letters;

              ----------------------------------------------------------------------------

BEGIN  -- Scramble_Letters
    Total:=0;
  FOR I in 1 .. WordLength LOOP
    Total := Total +1;
    Ada.Text_IO.Put(Item => "Enter the character number");
    Ada.Integer_Text_IO.Put(Item => I, Width => 2);
    Ada.Text_IO.Put(Item => " > " );
    Ada.Text_IO.Get(Item => NextChar(Total));
  END LOOP;
    Ada.Text_IO.New_Line;
    Ada.Text_IO.Put(Item => " That's it - the word for scrambling is > ");
  FOR I in 1 .. WordLength LOOP
    Ada.Text_IO.Put(Item => NextChar(I));
  END LOOP;
    Load_n_Scramble_Letters;  -- goes to the scrambling procedure from here
END Scramble_Letters;
            
             ----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-06-28 14:06 How to shuffle/jumble letters of a given word? Trish Cayetano
                   ` (3 preceding siblings ...)
  2015-06-29 20:21 ` Austin Obyrne
@ 2015-06-29 21:45 ` MM
  2015-06-30 12:29 ` Austin Obyrne
  2015-07-11 15:29 ` Trish Cayetano
  6 siblings, 0 replies; 17+ messages in thread
From: MM @ 2015-06-29 21:45 UTC (permalink / raw)


On Sunday, 28 June 2015 15:06:29 UTC+1, Trish Cayetano  wrote:
> I am creating a "text twist game" where you guess the words in a jumbled manner. How do I set the code to shuffle the letters? 
> 
> Example: word to be guessed is HELLO
> 
> What should be displayed is: LOLEH or LELHO
> 
> Thanks in advance!

Here is a rough-and-ready Fisher-Yates shuffle demonstration. This one shuffles whatever line it receives on STDIN (only one line).

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;

procedure Shuffle_String is

	function ShuffleRand (N: in Positive) return Integer is
		subtype Random_Range is Integer range 1 .. N;
		package Random_Shuffle_Integer is new Ada.Numerics.Discrete_Random(Random_Range);
		use Random_Shuffle_Integer;
		Generator : Random_Shuffle_Integer.Generator;
		Retval: Random_Range;
	begin
		Reset(Generator);
		Retval := Random(Generator);
		return Retval;
	end;

	function Shuffle (Item : String) return String is
		Result : String (Item'Range);
		Temp : Character;
		J : Integer;
	begin
		Result := Item;
		for I in reverse Result'first + 1  .. Result'last loop
			J := ShuffleRand (I);
			Temp := Result (I);
			Result (I) := Result (J);
			Result (J) := Temp;
		end loop;
		return Result;
	end Shuffle;

begin
	Put_Line (Shuffle (Get_Line));
end Shuffle_String;

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-06-28 14:06 How to shuffle/jumble letters of a given word? Trish Cayetano
                   ` (4 preceding siblings ...)
  2015-06-29 21:45 ` MM
@ 2015-06-30 12:29 ` Austin Obyrne
  2015-07-01 10:40   ` darkestkhan
  2015-07-11 15:29 ` Trish Cayetano
  6 siblings, 1 reply; 17+ messages in thread
From: Austin Obyrne @ 2015-06-30 12:29 UTC (permalink / raw)


On Sunday, June 28, 2015 at 3:06:29 PM UTC+1, Trish Cayetano wrote:
> I am creating a "text twist game" where you guess the words in a jumbled manner. How do I set the code to shuffle the letters? 
> 
> Example: word to be guessed is HELLO
> 
> What should be displayed is: LOLEH or LELHO
> 
> Thanks in advance!

There are 10 ways of shuffling 'Hello'

In my program source code (posted earlier)the parameters "Step" and "Repeats" may be set as follows'

Step       Repeats
   1                5
   2                2
   3                1
   4                1
   5                1

These have been tested and they all work.
*They may not all be suitable for your purposes on the occasion but they do work technically.

Try them.

The source code I posted earlier will copy 'n paste directly into your AdaGide editor for immediate running.

These results will often need some user-assistance but at least you can see what is available to you for your program.

Also,

Herewith is a program that will calculate the scrambling parameters for you as general options to insert for 'Step' and 'Repeat' in your scrambling program

WITH Ada.Text_IO;
WITH Ada.Integer_Text_IO;
PROCEDURE Find_Scrambling_Parameters IS
-------------------------------------------------------------------------
--| This utility calculates the number of parameters that may be used
--| to scramble a particular number in that many ways.
--| Copyright © 2015 Austin O'Byrne.
--| Last modified April 2015.
-------------------------------------------------------------------------
  SUM    : Integer;
  Number : CONSTANT Integer:= 5; - - Number (Wordlength) for analysing as parameters
  Line_Number: Integer;
  View       : Character;

BEGIN  -- Find_Scrambling_Parameters
    SUM := 0;
    Line_Number:=0;
    Ada.Text_IO.New_Line(2);
    Ada.Text_IO.Put(Item => "                 Step     Times  Parameters space ");
    Ada.Text_IO.New_Line(2);
  FOR I in 1 .. Number LOOP
    Line_Number := Line_Number + 1;
    SUM := SUM + Number / I;
    Ada.Integer_Text_IO.Put(Item => I, Width => 20);
    Ada.Integer_Text_IO.Put(Item => Number/ I, Width => 10);
    Ada.Integer_Text_IO.Put(Item => Sum, Width => 10);
    Ada.Text_IO.New_Line;
    IF Line_Number REM 50 = 0 THEN   --stalls program for viewing
      Ada.Text_IO.Put(Item => "         ");
      Ada.Text_IO.Put(Item => " - press any key/return to continue > ");
      Ada.Text_IO.Get(Item => View);
    END IF;
  END LOOP;

     Ada.Text_IO.Put(Item => " There are ");
     Ada.Integer_Text_IO.Put(Item => Sum, Width => 2);
     Ada.Text_IO.Put(Item => " secret ways of scrambling this string of ciphertext. ");


END Find_Scrambling_Parameters;


(This should copy ' n paste directly into 'AdaGide' also).

Cheers,

Come back if you wish.

Austin


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-06-30 12:29 ` Austin Obyrne
@ 2015-07-01 10:40   ` darkestkhan
  2015-08-09 21:50     ` David Thompson
  0 siblings, 1 reply; 17+ messages in thread
From: darkestkhan @ 2015-07-01 10:40 UTC (permalink / raw)


On Tuesday, June 30, 2015 at 12:29:57 PM UTC, Austin Obyrne wrote:
> On Sunday, June 28, 2015 at 3:06:29 PM UTC+1, Trish Cayetano wrote:
> > I am creating a "text twist game" where you guess the words in a jumbled manner. How do I set the code to shuffle the letters? 
> > 
> > Example: word to be guessed is HELLO
> > 
> > What should be displayed is: LOLEH or LELHO
> > 
> > Thanks in advance!
> 
> There are 10 ways of shuffling 'Hello'
> 

Only 10 ways? I know 7 ways to do it, I suspect that there are many more. And if you meant that there are only "10 possible results of shuffling" then you are way off the target (5! possible shuffles, which is 120)

> The source code I posted earlier will copy 'n paste directly into your AdaGide editor for immediate running.
> 

What if someone doesn't have AdaGide editor? Why even assume that anyone has AdaGide editor?

> These results will often need some user-assistance but at least you can see what is available to you for your program.
>

Like providing different scrambling parameters each time he changes word?
 
> Also,
> 
> Herewith is a program that will calculate the scrambling parameters for you as general options to insert for 'Step' and 'Repeat' in your scrambling program
> 



> WITH Ada.Text_IO;
> WITH Ada.Integer_Text_IO;
> PROCEDURE Find_Scrambling_Parameters IS
> -------------------------------------------------------------------------
> --| This utility calculates the number of parameters that may be used
> --| to scramble a particular number in that many ways.
> --| Copyright © 2015 Austin O'Byrne.
> --| Last modified April 2015.
> -------------------------------------------------------------------------
>   SUM    : Integer;
>   Number : CONSTANT Integer:= 5; - - Number (Wordlength) for analysing as parameters
>   Line_Number: Integer;
>   View       : Character;
> 
> BEGIN  -- Find_Scrambling_Parameters
>     SUM := 0;
>     Line_Number:=0;
>     Ada.Text_IO.New_Line(2);
>     Ada.Text_IO.Put(Item => "                 Step     Times  Parameters space ");
>     Ada.Text_IO.New_Line(2);
>   FOR I in 1 .. Number LOOP
>     Line_Number := Line_Number + 1;
>     SUM := SUM + Number / I;
>     Ada.Integer_Text_IO.Put(Item => I, Width => 20);
>     Ada.Integer_Text_IO.Put(Item => Number/ I, Width => 10);
>     Ada.Integer_Text_IO.Put(Item => Sum, Width => 10);
>     Ada.Text_IO.New_Line;
>     IF Line_Number REM 50 = 0 THEN   --stalls program for viewing
>       Ada.Text_IO.Put(Item => "         ");
>       Ada.Text_IO.Put(Item => " - press any key/return to continue > ");
>       Ada.Text_IO.Get(Item => View);
>     END IF;
>   END LOOP;
> 
>      Ada.Text_IO.Put(Item => " There are ");
>      Ada.Integer_Text_IO.Put(Item => Sum, Width => 2);
>      Ada.Text_IO.Put(Item => " secret ways of scrambling this string of ciphertext. ");
> 
> 
> END Find_Scrambling_Parameters;
> 
> 

I checked this program and can't see what it has to do with shuffling at all.

Here is what your program basically does (after cutting out all the I/O routines)

Number : Integer := 5;
Sum: Integer := 0;
for K in 1 .. Number loop
  Sum := Sum + Number / K;
end loop;

I fail to see how this is even connected to shuffling.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-06-29 18:04       ` Jeffrey R. Carter
@ 2015-07-02 20:56         ` Randy Brukardt
  0 siblings, 0 replies; 17+ messages in thread
From: Randy Brukardt @ 2015-07-02 20:56 UTC (permalink / raw)


"Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> wrote in message 
news:mms19k$gpm$2@dont-email.me...
> On 06/29/2015 01:05 AM, Simon Wright wrote:
>> "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> writes:
>>
>>> You could also just sort the String.
>>
>> I don't see how this would work?
>
> "HELLO" sorted would become "EHLLO"; "WATER", "AERTW"; "ART", "ART". All
> possible random permutations of the original word.

Huh? You sort "HELLO" and get "WATER"? That's quite an amazing sort program. 
I've written programs that did stuff like that, but I don't recall ever 
claiming that I meant to do that. :-)

                                     Randy.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-06-28 14:06 How to shuffle/jumble letters of a given word? Trish Cayetano
                   ` (5 preceding siblings ...)
  2015-06-30 12:29 ` Austin Obyrne
@ 2015-07-11 15:29 ` Trish Cayetano
  6 siblings, 0 replies; 17+ messages in thread
From: Trish Cayetano @ 2015-07-11 15:29 UTC (permalink / raw)


On Sunday, June 28, 2015 at 10:06:29 PM UTC+8, Trish Cayetano wrote:
> I am creating a "text twist game" where you guess the words in a jumbled manner. How do I set the code to shuffle the letters? 
> 
> Example: word to be guessed is HELLO
> 
> What should be displayed is: LOLEH or LELHO
> 
> Thanks in advance!

You are all GREAT! Thanks so much for your inputs!!! Really appreciate it!!!


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-07-01 10:40   ` darkestkhan
@ 2015-08-09 21:50     ` David Thompson
  2015-08-10 15:20       ` darkestkhan
  0 siblings, 1 reply; 17+ messages in thread
From: David Thompson @ 2015-08-09 21:50 UTC (permalink / raw)


On Wed, 1 Jul 2015 03:40:40 -0700 (PDT), darkestkhan
<darkestkhan@gmail.com> wrote:

> On Tuesday, June 30, 2015 at 12:29:57 PM UTC, Austin Obyrne wrote:
<snip>
> > There are 10 ways of shuffling 'Hello'
> > 
> 
> Only 10 ways? I know 7 ways to do it, I suspect that there are many more. 
> And if you meant that there are only "10 possible results of
> shuffling" then you are way off the target (5! possible shuffles,
> which is 120)
> 
Except if the two 'l' (ell) are indistinguishable then 5!/2!=60.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: How to shuffle/jumble letters of a given word?
  2015-08-09 21:50     ` David Thompson
@ 2015-08-10 15:20       ` darkestkhan
  0 siblings, 0 replies; 17+ messages in thread
From: darkestkhan @ 2015-08-10 15:20 UTC (permalink / raw)


On Sunday, August 9, 2015 at 9:50:03 PM UTC, David Thompson wrote:
> On Wed, 1 Jul 2015 03:40:40 -0700 (PDT), darkestkhan
> <darkestkhan@gmail.com> wrote:
> 
> > On Tuesday, June 30, 2015 at 12:29:57 PM UTC, Austin Obyrne wrote:
> <snip>
> > > There are 10 ways of shuffling 'Hello'
> > > 
> > 
> > Only 10 ways? I know 7 ways to do it, I suspect that there are many more. 
> > And if you meant that there are only "10 possible results of
> > shuffling" then you are way off the target (5! possible shuffles,
> > which is 120)
> > 
> Except if the two 'l' (ell) are indistinguishable then 5!/2!=60.

True. I'm not good at combinatorics - still my point stands, as 60 is still more than 10.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2015-08-10 15:20 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-28 14:06 How to shuffle/jumble letters of a given word? Trish Cayetano
2015-06-28 15:52 ` David Botton
2015-06-28 16:01   ` Anh Vo
2015-06-28 21:07 ` Simon Wright
2015-06-28 21:23   ` Jeffrey R. Carter
2015-06-29  8:05     ` Simon Wright
2015-06-29  8:13       ` Dmitry A. Kazakov
2015-06-29 18:04       ` Jeffrey R. Carter
2015-07-02 20:56         ` Randy Brukardt
2015-06-29 13:42 ` darkestkhan
2015-06-29 20:21 ` Austin Obyrne
2015-06-29 21:45 ` MM
2015-06-30 12:29 ` Austin Obyrne
2015-07-01 10:40   ` darkestkhan
2015-08-09 21:50     ` David Thompson
2015-08-10 15:20       ` darkestkhan
2015-07-11 15:29 ` Trish Cayetano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox