#lang racket
(require csc151)
(require plot)
(require rackunit)
(require rackunit/text-ui)

;;; File:
;;;   000000.rkt
;;; Authors:
;;;   The student currently referred to as 000000
;;;   Titus Klinge
;;;   Samuel A. Rebelsky
;;; Contents:
;;;   Code and solutions for Exam 2 2018S
;;; Citations:
;;;

;; +---------+--------------------------------------------------------
;; | Grading |
;; +---------+

;; This section is for the grader's use.

;; Problem 1: 
;; Problem 2:
;; Problem 3:
;; Problem 4:
;; Problem 5:
;; Problem 6:
;;           ----
;;     Total:

;;    Scaled:
;;    Errors:
;;     Times:
;;          :
;;          :
;;          :
;;           ----
;;     Total:

;; +----------+-------------------------------------------------------
;; | Prologue |
;; +----------+

; Time Log:
;   Date        Start   Finish  Elapsed Activity

; Time Spent: 

;; +-----------+------------------------------------------------------
;; | Problem 1 |
;; +-----------+

; Time Log:
;   Date        Start   Finish  Elapsed Activity

; Time Spent: 

; Citations:

; Solution:

;;; Procedure:
;;;   evens-between
;;; Parameters:
;;;   lower, 
;;;   upper, 
;;; Purpose:
;;;   
;;; Produces:
;;;   
;;; Preconditions:
;;;   
;;; Postconditions:
;;;   
(define evens-between
  (lambda (lower upper)
    null)) ; STUB

; Examples/Tests:


;; +-----------+------------------------------------------------------
;; | Problem 2 |
;; +-----------+

; Time Log:
;   Date        Start   Finish  Elapsed Activity

; Time Spent: 

; Citations:

; Solution:

(define tests-evens-between
  (let ([check-error
         (lambda (proc)
           (check-exn (conjoin exn:fail? (negate exn:fail:contract?))
                      proc))])
    (test-suite
     "Tests of the evens-between procedure"
     (test-case
      "Lower and upper are both even"
      (check-equal? (evens-between 0 10)
                    '(0 2 4 6 8 10)))
     (test-case
      "Preconditions are not met"
      (check-error (lambda () (evens-between "a" "b")))))))

; Examples/Tests:


;; +-----------+------------------------------------------------------
;; | Problem 3 |
;; +-----------+

; Time Log:
;   Date        Start   Finish  Elapsed Activity

; Time Spent: 

; Citations:

; Solution:

;;; Procedure:
;;;   extract-unique
;;; Parameters:
;;;   table, a list of lists
;;;   column, a non-negative integer
;;; Purpose:
;;;   Extract the unique values in the given column of the table.
;;; Produces:
;;;   unique, a list
;;; Preconditions:
;;;   * column names a valid column in each entry of table.  That is,
;;;     `(< column (reduce min (map length table)))`
;;; Postconditions:
;;;   * Every element of the given column of table appears in unique.
;;;   * No value appears twice in unique
;;;   * Every element in unique appears in the given column of table
(define extract-unique
  (lambda (table column)
    null)) ; STUB

; Examples/Tests:


;; +-----------+------------------------------------------------------
;; | Problem 4 |
;; +-----------+

; Time Log:
;   Date        Start   Finish  Elapsed Activity

; Time Spent: 

; Citations:

; Solution:

;;; Procedure:
;;;   describe-file
;;; Parameters:
;;;   fname, a string
;;; Purpose:
;;;   Provide some text to describe a file
;;; Produces:
;;;   description, a string
;;; Preconditions:
;;;   fname names an existing text file for which we have read permission.
;;; Postconditions:
;;;   * If the file contains no characters, description is "empty".
;;;   * If the file contains fewer than 1000 words, description
;;;     begins with the phrase "a short file".
;;;   * If the file contains at least 1000 words but fewer than 10,000, 
;;;     description begins with the phrase "a medium-length file".
;;;   * If the file contains at least 10,000 words but fewer than 100,000, the
;;;     description begins with the phrase "a large file".
;;;   * If the file contains at least 100,000 words, the description 
;;;     begins with the phrase "a very large file".
;;;   * If the average line length is less than twenty characters,
;;;     description includes the phrase "containing mostly short lines".
;;;   * If at least 1/3 of the words in the file are under five characters,
;;;     the description include the phrase "with many short words".
;;;   * If at least 1/3 of the words in the file are over eight characters,
;;;     the description includes the phrase "with many long words".
;;;   * If any of conditions above are not met, description does not include 
;;;     the corresponding phrase.
(define describe-file
  (lambda (fname)
    "indescribable")) ; STUB

; Examples/Tests:


;; +-----------+------------------------------------------------------
;; | Problem 5 |
;; +-----------+

; Time Log:
;   Date        Start   Finish  Elapsed Activity

; Time Spent: 

; Citations:

; Solution:

(define visualize-speeches
  (lambda (speeches)
    (plot (points (list (list 1 1)))))) ; STUB

(define visualize-speeches-prime
  (lambda (speeches speakers colors)
    (plot (points (list (list 1 1)))))) ; STUB

(define speech-histogram
  (lambda (speeches)
    (plot (discrete-histogram (list (list "Joe" 2)))))) ; STUB

; Examples/Tests:

;; +-----------+------------------------------------------------------
;; | Problem 6 |
;; +-----------+

; Time Log:
;   Date        Start   Finish  Elapsed Activity

; Time Spent: 

; Citations:

; Supplied code

; Solution:

;;; Procedure:
;;;   
;;; Parameters:
;;;   
;;; Purpose:
;;;   
;;; Produces:
;;;   
;;; Preconditions:
;;;   
;;; Postconditions:
;;;   
(define helper1
  (let ([helper1 (o positive? string-length)]
        [helper2 (o car string->list)])
    (let ([helper3 #\A]
          [helper4 #\M])
      (let* ([helper3 (section char-ci<=? helper3 <> helper4)]
             [helper4 (o helper3 helper2)])
        (section filter (conjoin helper1 helper4) <>)))))

; Examples/Tests:

