Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;LISP Autograder;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; by Austin Takechi;;;;;;;;;;
- ;; November 17, 2015;;;;;;;;;;
- ;; austintakechi@gmail.com;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;Use this to grade assignments easily.;;;;;;;;;
- ;;;;; Copy and paste this code into the ;;;;;;;;;
- ;;;;; student's code. Modify the tests and;;;;;;;;;
- ;;;;; answers if you update them. ;;;;;;;;;
- ;;;;;The final grade is out of 50, but ;;;;;;;;;
- ;;;;; there are only 3 tests per case, so ;;;;;;;;;
- ;;;;; while the tests say 2/3, they really;;;;;;;;;
- ;;;;; mean 66% of 1/6th of 50 points, as ;;;;;;;;;
- ;;;;; there are 6 tests. ;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;; Cheers! ;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;A function that will tell whether two things are the same, regardless of if they are atoms or lists.
- (define (_eq A B)
- (if (and (null? A) (null? B)) #t
- (if (and (list? A) (list? B) (= (car A) (car B)) (_eq (cdr A) (cdr B))) #t
- (if (equal? A B) #t #f))))
- ;Sample boolean Functions used later
- (define (_multOf3 x) (= (modulo x 3) 0))
- (define (_singleDigit x) (and (> x -1) (< x 10)))
- ;Defining some makeCutters to use later
- (define _F4 (makeCutter 4))
- (define _F3 (makeCutter 3))
- (define _F5 (makeCutter 5))
- (let(
- (A1q (buildLR 12345 67890)) ;Test #1 for A
- (A2q (buildLR 12345 60000)) ;Test #2 for A
- (A3q (buildLR 1 60000)) ;Test #3 for A
- (A1a '1290) ;Answer for Test #1 for A
- (A2a '1200) ;Answer for Test #2 for A
- (A3a '-1) ;Answer for Test #3 for A
- (B1q (listMins '(2 8 7) '(5 4 4)))
- (B2q (listMins '(3 -1 7) '(1 0 1)))
- (B3q (listMins '(0 1 0) '(1 0 1)))
- (B1a '(2 4 4))
- (B2a '(1 -1 1))
- (B3a '(0 0 0))
- (C1q (unwind '(7 8 2 9 5 6)))
- (C2q (unwind '(7 8 2 9 5)))
- (C3q (unwind '(1 2 3 4 5 6 7 8)))
- (C1a '(2 9 8 5 7 6))
- (C2a '(2 8 9 7 5))
- (C3a '(4 5 3 6 2 7 1 8))
- (D1q (functionWinner _multOf3 _singleDigit '(10 20 3 4 5 6)))
- (D2q (functionWinner _singleDigit _multOf3 '(10 20 3 4 5 6)))
- (D3q (functionWinner _multOf3 _multOf3 '(10 20 3 4 5 6)))
- (D1a 2)
- (D2a 1)
- (D3a 0)
- (E1q (getNestedCount '(()()()(()))))
- (E2q (getNestedCount '(1 2 (3 4 (5)))))
- (E3q (getNestedCount '(1 2 3 4 5 (6 (7 (8 ) ) ) ( ( ( ( 9 ) ( (0 ))))))))
- (E1a 0)
- (E2a 5)
- (E3a 10)
- (F1q (_F4 '(9 8 7 6 5 4 3 2 1 0)))
- (F2q (_F3 '(9 8 7 6 5 4 3 2 1 0)))
- (F3q (_F5 '(9 8 7 6 5 4 3 2 1 0)))
- (F1a '(9 8 7 6))
- (F2a '(9 8 7))
- (F3a '(9 8 7 6 5))
- )
- ;Check to see if the Test and the Answer are the same!
- (print 'Total::)
- (print (* (/ (+
- (if (_eq A1q A1a) 1 0)
- (if (_eq A2q A2a) 1 0)
- (if (_eq A3q A3a) 1 0)
- (if (_eq B1q B1a) 1 0)
- (if (_eq B2q B2a) 1 0)
- (if (_eq B3q B3a) 1 0)
- (if (_eq C1q C1a) 1 0)
- (if (_eq C2q C2a) 1 0)
- (if (_eq C3q C3a) 1 0)
- (if (_eq D1q D1a) 1 0)
- (if (_eq D2q D2a) 1 0)
- (if (_eq D3q D3a) 1 0)
- (if (_eq E1q E1a) 1 0)
- (if (_eq E2q E2a) 1 0)
- (if (_eq E3q E3a) 1 0)
- (if (_eq F1q F1a) 1 0)
- (if (_eq F2q F2a) 1 0)
- (if (_eq F3q F3a) 1 0)
- ) 18) 50))
- (writeln '/50)
- (writeln '~~~~~~~~~~~~~~~~)
- (writeln '~~~~~~~~~~~~~~~~)
- ;This was an afterthought, but let's redo the testing for each individual problem
- ; so that students can see where they messed up, if they did.
- ; You can optimize this code but it was auto generated and it works, so whatever.
- (print 'A_buildLR::)
- (print (+
- (if (_eq A1q A1a) 1 0)
- (if (_eq A2q A2a) 1 0)
- (if (_eq A3q A3a) 1 0)))
- (writeln '/3)
- (writeln '~~~~~~~~~~~~~~~~)
- (print 'B_listMins::)
- (print (+
- (if (_eq B1q B1a) 1 0)
- (if (_eq B2q B2a) 1 0)
- (if (_eq B3q B3a) 1 0)))
- (writeln '/3)
- (writeln '~~~~~~~~~~~~~~~~)
- (print 'C_unwind::)
- (print (+
- (if (_eq C1q C1a) 1 0)
- (if (_eq C2q C2a) 1 0)
- (if (_eq C3q C3a) 1 0)))
- (writeln '/3)
- (writeln '~~~~~~~~~~~~~~~~)
- (print 'D_functionWinner::)
- (print (+
- (if (_eq D1q D1a) 1 0)
- (if (_eq D2q D2a) 1 0)
- (if (_eq D3q D3a) 1 0)))
- (writeln '/3)
- (writeln '~~~~~~~~~~~~~~~~)
- (print 'E_getNestedCount::)
- (print (+
- (if (_eq E1q E1a) 1 0)
- (if (_eq E2q E2a) 1 0)
- (if (_eq E3q E3a) 1 0)))
- (writeln '/3)
- (writeln '~~~~~~~~~~~~~~~~)
- (print 'F_makeCutter::)
- (print (+
- (if (_eq F1q F1a) 1 0)
- (if (_eq F2q F2a) 1 0)
- (if (_eq F3q F3a) 1 0)))
- (writeln '/3)
- (writeln '~~~~~~~~~~~~~~~~)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement