• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How to Rearrange numbers?

Status
Not open for further replies.
Level 11
Joined
Oct 20, 2007
Messages
342
If there are given 9 number that is 1~9 (1,2,3,4,5,6,7,8,9)
It will generate random 3 number in a set. (e.g. 135, 253, 785, 223, 444, 661)
And i want it to rearrange it in ascending order.
for example:
Given 153 Output 135
Given 881 Output 188
Given 753 Output 357
Given 584 Output 458
Given 792 Output 279
Given 333 Output 333
Given 877 Output 778

How to rearrange those number?
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
dont you mean?

Given 153 Output 351
Given 881 Output 188
Given 753 Output 357
Given 584 Output 485
Given 792 Output 297
Given 333 Output 333
Given 877 Output 778

Well, if you wanted to know like this, i made a testmap for you.

The Trick is, to rearrange the numbers, using Substrings!
I included a Way to find out, if the number is in the correct format.

The important thing is:

  • Set String_Number1 = (Substring((Entered chat string), 1, 1))
  • Set String_Number2 = (Substring((Entered chat string), 2, 2))
  • Set String_Number3 = (Substring((Entered chat string), 3, 3))
  • Set Output_String = ((String_Number3 + String_Number2) + String_Number1)
If you do not refer to a chat event, u just have to fill in where [Substring((Entered chat string)] stands, your string variable, in which you saved the number before.
TestMap

Greets
 
Last edited:
Level 11
Joined
Oct 20, 2007
Messages
342
nono, not invert it.
is ascending the number in order.
for example:
given 536 , there got 3 number (5,3,6)
ascend it like 3,5,6 because 3 less then 5 and 6, 6 higher than 5 and 3
Output 356
more example:
758 -> 578
964 -> 469
283 -> 238
565 -> 556
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
ah ok, then u have to include an integer-Comparisson, ill update the testmap and insert it here with edit )

Here is the new TestMap: Link

Now it works as u want.
It uses an array now, the trigger compares all three substring numbers and sets them in the order :)

Greets
 
Status
Not open for further replies.
Top