2023-05-25 17:47:19 +02:00
|
|
|
# Lösung: Arrays
|
|
|
|
|
2023-05-25 17:49:42 +02:00
|
|
|
|
|
|
|
```ruby
|
2023-05-25 17:47:19 +02:00
|
|
|
stapel = []
|
|
|
|
|
|
|
|
for farbe in %w{P X H K}
|
|
|
|
for wert in %w{7 8 9 0 B D K A}
|
|
|
|
stapel << (farbe + wert).to_sym
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Mischen
|
|
|
|
stapel.shuffle!
|
|
|
|
|
|
|
|
# Karten abnehmen
|
|
|
|
neu = stapel[0..4]
|
|
|
|
neu << stapel[-5..-1]
|
|
|
|
stapel -= neu
|
|
|
|
|
|
|
|
# Karten mischen
|
|
|
|
neu.shuffle!
|
|
|
|
|
|
|
|
# Karten wieder auf den Stapel legen
|
|
|
|
stapel << neu
|
|
|
|
|
|
|
|
puts neu
|
|
|
|
puts stapel
|
|
|
|
```
|