Results 1 to 5 of 5
  1. ALToronto's Avatar
    CrackBerry Abuser

    Posts
    329 Posts
    Thread AuthorThread Author   #1  

    Default App request: put a sequence of numbers in random order

    There are lots of random number generators in App World, but what I need is different. Say you have a regular sequence of numbers, from 1 to N. Re-arranging them in random order is the equivalent of writing each number, from 1 to N, on a piece of paper, throwing the pieces of paper in a box and pulling them out one by one. I don't need anything fancy in terms of UI or customization (it's always from 1 to whatever), just something that works. Even Excel doesn't do this.

    Anybody up for a challenge? TIA
  2. #2  
    Last edited by F2; 04-30-2012 at 07:15 PM.
    Thanked by:
    ALToronto (05-06-2012) 
  3. kdna's Avatar
    CrackBerry Abuser

    Posts
    499 Posts
    #3  

    Default

    Quote Originally Posted by ALToronto View Post
    There are lots of random number generators in App World, but what I need is different. Say you have a regular sequence of numbers, from 1 to N. Re-arranging them in random order is the equivalent of writing each number, from 1 to N, on a piece of paper, throwing the pieces of paper in a box and pulling them out one by one. I don't need anything fancy in terms of UI or customization (it's always from 1 to whatever), just something that works. Even Excel doesn't do this.

    Anybody up for a challenge? TIA
    I would like to try this. I'll keep you posted on what I come up with.
    Thanked by:
    ALToronto (05-06-2012) 
  4. GinaWrite's Avatar
    CrackBerry User

    Posts
    36 Posts
    #4  

    Default

    You can do this in BASIC for PlayBook

    constant N 50
    array numbers N

    for a = 1 to N
    numbers(a) = a
    next a

    for a = 1 to N
    b = integer(random(N)) + 1
    t = numbers(b)
    numbers(b) = numbers(a)
    numbers(a) = t
    next a

    ' the array numbers now contains the numbers 1 to N shuffled randomly

    for a = 1 toi N
    print numbers(a)
    next a
    Thanked by:
    ALToronto (05-06-2012) 
  5. polytope's Avatar
    CrackBerry Abuser

    Posts
    331 Posts
    #5  

    Default

    Quote Originally Posted by GinaWrite View Post
    You can do this in BASIC for PlayBook
    BASIC for PlayBook? Wow. Nice. Downloading.

    Now someone should port Haskell to PlayBook. That'd be cool.

Posting Permissions