Perfect shuffle: Difference between revisions

m
→‎{{header|R}}: Syntax highlighting.
(Added solution for Action!)
m (→‎{{header|R}}: Syntax highlighting.)
Line 2,189:
=={{header|R}}==
===Matrix solution===
<lang Rrsplus>wave.shuffle <- function(n) {
deck <- 1:n ## create the original deck
new.deck <- c(matrix(data = deck, ncol = 2, byrow = TRUE)) ## shuffle the deck once
Line 2,211:
===Sequence solution===
The previous solution exploits R's matrix construction; This solution exploits its array indexing.
<lang Rrsplus>#A strict reading of the task description says that we need a function that does exactly one shuffle.
pShuffle<-function(deck)
{
331

edits