Hello everybody, I need your help due to a problem with the AUGMENT command: I am making a blackjack and I'm trying to create a working deck, so that when a card is extracted it can't extracted again.
This is the code:

52→dim(L₆
Fill(0,L₆

seq(X,X,0,51)→L₆
Disp L₆

5→C

51→dim(L₆
Fill(0,L₆

For(A,0,dim(L₆),1)
If A=C
Then
Wait 2
Else
Disp A
augment(L₆,{A})→L₆
SortA(L₆
Disp L₆
End
End
Disp L₆

The Disp that I've put are going to me removed it's just for me to check if the counter is going. The problem is that after the list is created and than filled with zero (the second fill), when I run the for loop it doesn't work. It should create a new list containing the previous list value exept the extracted one. Though that doesn't happen and it just stay filled with zeros.
If you know why your help would be grateful.
Thank you for your attention
If you just want to put the numbers 0..51 in a random order with no duplicates (& assuming TI's built-in random number generator is good enough for your purposes), you should be able to replace all your code with this:
Code:
randIntNoRep(0,51)→L₆


Then to deal from it, you can use consecutive entries from the list & keep track of how many cards you have dealt to use as the list index.
Here's the demo I promised you SGTMM:

Code:
randIntNoRep(1,52->L6
For(I,0,51
   Disp L6(1)
   If dim(L6)>1
      DeltaList(cumSum(L6))->L6
End
Hi Zeroko and Firepup, as you’ve given me help, do you want me to feature you in the project?
Firepup650 wrote:
Here's the demo I promised you SGTMM:

Code:
randIntNoRep(1,52->L6
For(I,0,51
   Disp L6(1)
   If dim(L6)>1
      DeltaList(cumSum(L6))->L6
End
What about this…
Code:
randIntNoRep(1,52->L6
For(I,52,1,~1
   Disp L6(I
   dim(L6
   Ans-(1<Ans->dim(L6
End
Or even use the loop variable if it will only repeat this specific number of times…
Code:
randIntNoRep(1,52->L6
For(I,52,1,~1
   I->dim(L6
   Disp L6(I
End
Or just don't touch the dimension at all…
Code:
randIntNoRep(1,52->C
For(I,1,52
   Disp |LC(I
End

hides
Alright let's answer these one by one.
Also first and foremost: It was a demo, it wasn't ment to be optimised.
LogicalJoe wrote:
What about this…
Code:
randIntNoRep(1,52->L6
For(I,52,1,~1
   Disp L6(I
   dim(L6
   Ans-(1<Ans->dim(L6
End
I feel like I understand what mine's doing better than this, but it's probably up to personal preference.
LogicalJoe wrote:
Or even use the loop variable if it will only repeat this specific number of times…
Code:
randIntNoRep(1,52->L6
For(I,52,1,~1
   I->dim(L6
   Disp L6(I
End
So, you're shortening the list here, and then displaying an element out of the shortened list? To me this looks like it wouldn't work, but I'll test and see later.
LogicalJoe wrote:
Or just don't touch the dimension at all…
Code:
randIntNoRep(1,52->C
For(I,1,52
   Disp |LC(I
End
Back to what SGTMM asked for:
SGTMM wrote:
create a new list containing the previous list value exept the extracted one.
SGTMM asked for elements to be removed, so that's why.
Ok, next order of business:
SGTMM wrote:
Hi Zeroko and Firepup, as you’ve given me help, do you want me to feature you in the project?
Sure!
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement