fork download
  1. ; your code goes here
  2. (defun newList (&optional(n 100))
  3. (loop for i from (- n 1) downto 0 collect i))
  4.  
  5.  
  6. (defun board (l &optional(n 10))
  7. (cond
  8. ((null l) nil)
  9. (t (cons (subseq l 0 n) (board (subseq l n) n)))))
  10.  
  11.  
  12. (defun show-board (board)
  13. (format T "~%")
  14. (mapcar (lambda (x) (format T " ~A ~%" x)) board)
  15. (format nil "")
  16. )
  17.  
  18. (defun remove-duplicate (pred l)
  19. (cond ((null l) NIL)
  20. ((funcall pred (car l)) (remove-duplicate pred (cdr l)))
  21. (T (cons (car l) (remove-duplicate pred (cdr l))))))
  22.  
  23. (defun shuffle-list (l)
  24. ;;iterate 99
  25. (dotimes (i (- (length l) 1))
  26. ;;store random number to n
  27. (let ((n (nth (random (length l)) l)))
  28. ;;print value of n
  29. (format t "~% ~A" n)
  30. (cond
  31. ((null l) nil)
  32. ;;I have this but it´s not show the new list
  33. (t (remove-duplicate #'(lambda (x) (= x n)) l))))))
  34.  
  35. ;;print board
  36. (print "--- INICIAL BOARD ---")
  37. (show-board (board (newList)))
  38.  
  39. ;; should print board with random number
  40. (print "--- should create final BOARD with random number")
  41. (show-board (board (shuffle-list (newList))))
Success #stdin #stdout 0.03s 10040KB
stdin
Standard input is empty
stdout
"--- INICIAL BOARD ---" 
	(99 98 97 96 95 94 93 92 91 90) 
	(89 88 87 86 85 84 83 82 81 80) 
	(79 78 77 76 75 74 73 72 71 70) 
	(69 68 67 66 65 64 63 62 61 60) 
	(59 58 57 56 55 54 53 52 51 50) 
	(49 48 47 46 45 44 43 42 41 40) 
	(39 38 37 36 35 34 33 32 31 30) 
	(29 28 27 26 25 24 23 22 21 20) 
	(19 18 17 16 15 14 13 12 11 10) 
	(9 8 7 6 5 4 3 2 1 0) 

"--- should create final BOARD with random number" 
 66
 88
 68
 56
 76
 36
 49
 7
 50
 38
 52
 56
 26
 95
 51
 62
 84
 43
 18
 6
 69
 1
 59
 86
 16
 31
 2
 17
 88
 40
 66
 65
 87
 92
 42
 20
 26
 68
 89
 12
 91
 40
 83
 51
 85
 63
 73
 35
 60
 42
 65
 95
 78
 29
 23
 48
 35
 40
 49
 21
 41
 19
 80
 36
 5
 23
 89
 62
 57
 27
 54
 3
 35
 24
 66
 24
 1
 13
 80
 67
 7
 11
 52
 46
 7
 30
 72
 44
 45
 71
 81
 83
 43
 52
 95
 44
 35
 79
 49