Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
Like Tree1Thanks

Thread: Some Calculators

  1. #16
    MHF Contributor
    Joined
    Feb 2015
    From
    Ottawa Ontario
    Posts
    1,374
    Thanks
    254

    Re: Some Calculators

    Well: The Denis card shuffler(!), using UBasic:

    DIM A(52), B(52) [set up 2 arrays size 52]

    w = 52 [used to indicate number of cards left]

    LOOP u FROM 1 TO 52 : B(u) = u : NEXT u [fill array B]

    LOOP v FROM 1 TO 52
    p = INT(RND * w)+1 [p(ick) a number from 1 to w at random]
    A(v) = B(p) [enter picked card in shuffled array A]
    SWAP B(w),B(p) [switch last value in array B with picked value]
    w = w - 1 [update number of cards left]
    NEXT v

    Array A now contains the shuffled deck.
    Follow Math Help Forum on Facebook and Google+

  2. #17
    Newbie
    Joined
    Feb 2016
    From
    USA
    Posts
    14

    Re: Some Calculators

    Quote Originally Posted by DenisB View Post
    Well: The Denis card shuffler(!), using UBasic:

    DIM A(52), B(52) [set up 2 arrays size 52]

    w = 52 [used to indicate number of cards left]

    LOOP u FROM 1 TO 52 : B(u) = u : NEXT u [fill array B]

    LOOP v FROM 1 TO 52
    p = INT(RND * w)+1 [p(ick) a number from 1 to w at random]
    A(v) = B(p) [enter picked card in shuffled array A]
    SWAP B(w),B(p) [switch last value in array B with picked value]
    w = w - 1 [update number of cards left]
    NEXT v

    Array A now contains the shuffled deck.
    Mersenne Twister algorithm will give you much better results.
    Follow Math Help Forum on Facebook and Google+

Page 2 of 2 FirstFirst 12

Similar Math Help Forum Discussions

  1. fractional exponents - without calculators
    Posted in the Algebra Forum
    Replies: 12
    Last Post: Apr 16th 2016, 06:55 PM
  2. basic and scientific calculators
    Posted in the New Users Forum
    Replies: 0
    Last Post: Aug 31st 2012, 08:39 AM
  3. Im Looking to Buy Used Calculators
    Posted in the Calculators Forum
    Replies: 0
    Last Post: Jul 5th 2011, 12:06 PM
  4. Anyone know anything about TI calculators...?
    Posted in the Calculators Forum
    Replies: 1
    Last Post: Dec 10th 2008, 11:16 AM
  5. Casio Calculators
    Posted in the Calculators Forum
    Replies: 7
    Last Post: Aug 25th 2006, 12:42 AM

Search Tags


/mathhelpforum @mathhelpforum