In LinkedList Zahl suchen
In LinkedList Zahl suchen
Also ich hab 108 Zahlen zu vergeben, dabei dürfen manche garnicht doppelt rein und manche müssen doppelt sein (kartenspiel).
nun wollt ich mit random die zahlen in die linkedlist einordnen, nur wie mache ich es das nicht eine zahl 4 mal und dafür manche garnicht drin stehen?
diese zahlen müssen vergeben werden:
0
1x2
2x2
3x2
4x2
5x2
6x2
7x2
8x2
9x2
10x2
11x2
12x2
13
14x2
15x2
16x2
17x2
18x2
19x2
20x2
21x2
22x2
23x2
24x2
25x2
26
27x2
28x2
29x2
30x2
31x2
32x2
33x2
34x2
35x2
36x2
37x2
38x2
39
40x2
41x2
42x2
43x2
44x2
45x2
46x2
47x2
48x2
49x2
50x2
51x2
52x4
53x4
nun wollt ich mit random die zahlen in die linkedlist einordnen, nur wie mache ich es das nicht eine zahl 4 mal und dafür manche garnicht drin stehen?
diese zahlen müssen vergeben werden:
0
1x2
2x2
3x2
4x2
5x2
6x2
7x2
8x2
9x2
10x2
11x2
12x2
13
14x2
15x2
16x2
17x2
18x2
19x2
20x2
21x2
22x2
23x2
24x2
25x2
26
27x2
28x2
29x2
30x2
31x2
32x2
33x2
34x2
35x2
36x2
37x2
38x2
39
40x2
41x2
42x2
43x2
44x2
45x2
46x2
47x2
48x2
49x2
50x2
51x2
52x4
53x4

Ein gut gemischtes Kartenspiel:
edit: vom Mischen merkt man erst etwas, wenn er 1 Million mal Karten tauscht.
So sorgfältig mischt kaum jemand
edit2: kleiner Fehler korrigiert, 52 und 53 sind jetzt 4x drinnen.
Code: Alles auswählen
NewList werte.l()
AddElement(werte())
werte()=0
For a=1 To 53
AddElement(werte())
werte()=a
Next
For a=1 To 53
If a<>13 And a<>26 And a<>39
AddElement(werte())
werte()=a
EndIf
Next
for a=1 to 2
AddElement(werte())
werte()=52
AddElement(werte())
werte()=53
next
For a=1 To 10000
SelectElement(werte(),Random(CountList(werte())-1))
*first=@werte()
SelectElement(werte(),Random(CountList(werte())-1))
*sec=@werte()
SwapElements(werte(),*first,*sec)
Next
ForEach werte()
Debug werte()
Next
End
So sorgfältig mischt kaum jemand

edit2: kleiner Fehler korrigiert, 52 und 53 sind jetzt 4x drinnen.