Sha256: f0bc872185d4533803d19e3efb2caec51986e987833583516123663b4991c437

Contents?: true

Size: 393 Bytes

Versions: 87

Compression:

Stored size: 393 Bytes

Contents

handshake <- function(n) {
  
  # 1 = wink
  # 10 = double blink
  # 100 = close your eyes
  # 1000 = jump
  # 10000 = reverse
  actions = c("wink", "double blink", "close your eyes", "jump")
  
  bin = intToBits(n)
  
  events = c()
  
  for (i in 1:4){
    if (bin[i] > 0) {
      events = c(events, actions[i])
    }
  }
  
  if (bin[5] > 0) {
    events = rev(events)
  }
  
  events
  
}

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
trackler-2.0.6.41 tracks/r/exercises/secret-handshake/example.R
trackler-2.0.6.40 tracks/r/exercises/secret-handshake/example.R
trackler-2.0.6.39 tracks/r/exercises/secret-handshake/example.R
trackler-2.0.6.38 tracks/r/exercises/secret-handshake/example.R
trackler-2.0.6.37 tracks/r/exercises/secret-handshake/example.R
trackler-2.0.6.36 tracks/r/exercises/secret-handshake/example.R
trackler-2.0.6.35 tracks/r/exercises/secret-handshake/example.R