fork download
  1. (define (get-blue lst)
  2. (define (bd lst mask)
  3. (if (null? lst) 0
  4. (logior (if (= (logand mask (car lst)) mask) mask 0)
  5. (bd (cdr lst) (ash mask 1)))))
  6. (bd lst 1))
  7.  
  8. (define (get-red lst)
  9. (define (rd lst mask)
  10. (if (null? lst) 0
  11. (logior (if (= (logand mask (car lst)) mask) mask 0)
  12. (rd (cdr lst) (if (< mask 32) (ash mask 1) 1)))))
  13. (let ((p (rd lst 8)))
  14. (logior (ash (logand p 7) 3)
  15. (ash p -3))))
  16.  
  17. (define (nth str n)
  18. (if (zero? n) (car str)
  19. (nth (cdr str) (- n 1))))
  20.  
  21. (define (read-strings n)
  22. (if (zero? n) '()
  23. (let ((str (map char->integer
  24. (string->list (let ((cnd (read)))
  25. ((if (number? cnd) number->string symbol->string) cnd))))))
  26. (cons (get-blue str) (cons (get-red str) (read-strings (- n 1)))))))
  27.  
  28. (define (decode data codeline)
  29. (if (null? data) '()
  30. (begin (display (nth codeline (car data)))
  31. (decode (cdr data) codeline))))
  32.  
  33. (define (read-test)
  34. (let ((data (read-strings (read)))
  35. (codeline (string->list (symbol->string (read)))))
  36. (decode data codeline)))
  37.  
  38. (define (read-tests n)
  39. (if (zero? n) '() (begin (read-test) (newline) (read-tests (- n 1)))))
  40.  
  41. ((lambda () (read-tests (read))))
  42.  
  43. (exit)
  44.  
Success #stdin #stdout 0.02s 11144KB
stdin
2
2
qwe345 rf3Arg
XSBSRasdew9873465hkldsfsalndfvnfq489uqovkLKJHaeDaae555Sk5asdpASD

3
2S4J5K 111111 lrtb2A
isimgsow45ipfgisd56wfgngdfcdkgc7kKKKkuuJJgfstdygQdWORQADFSLKF2K8
stdout
keep
coding