tolerantie.clj

1
;; Things left to implement:
2
;; - Check if all points are at least 8/20
3
;; - Check if maximum two points are less than 10/20
4
;; - Check if WEIGHED total is at least 50%
5
;; - If one of the conditions is not fulfilled, display which points need to be
6
;;   changed in order to meet the conditions
7
8
(defn tolerable
9
  [results]
10
  (def weighted_results (reduce + (map * (map :ects results) (map :points results))))
11
  (def failed_courses (set (filter #(< (:points %) 10) results)))
12
  (def failed_weight (reduce + (map * (map :ects failed_courses) (map :points failed_courses))))
13
  (if (<= (/ failed_weight weighted_results) 1/100) true false))
14
15
(defn uhasselt-tolerable
16
  [results]
17
  (def weighted_results (reduce + (map * (map :ects results) (map :points results))))
18
  (println weighted_results)
19
  (def failed_courses (set (filter #(< (:points %) 10) results)))
20
  (println failed_courses)
21
  (def failed_weight (reduce + (map * (map :ects failed_courses) (map :points failed_courses))))
22
  (println failed_weight)
23
  (if (< 2 (count failed_courses)) false
24
    (if (>= weighted_results 580) true false)))
25
26
(defn notweighed
27
  [results]
28
  (def normal_results (reduce + (map :points results)))
29
  (println normal_results)
30
  (println (/ normal_results (* 20 (count results)))))
31
32
33
34
(defn receive-courses
35
  ([] (receive-courses #{}))
36
  ([courses]
37
   (let [name (read-line)
38
         ects (read-line)
39
         points (read-line)]
40
     (if (= name "")
41
       courses
42
       (recur (conj courses {:name name :ects ects :points points}))))))
43
44
;;(print (tolerable (receive-courses)))
45
(def actual_results [
46
                     {:name "Discrete wiskunde 1" :ects 4 :points 10}
47
                     {:name "Wiskunde basistechniek" :ects 3 :points 10}
48
                     {:name "Wiskundige analyse 1" :ects 5 :points 10}
49
                     {:name "Ingenieursproject 1" :ects 6 :points 10}
50
                     {:name "Algemene scheikunde" :ects 6 :points 10}
51
                     {:name "Informatica" :ects 6 :points 10}
52
                     {:name "Natuurkunde 1" :ects 6 :points 10}
53
                     {:name "WenS" :ects 4 :points 10}
54
                     {:name "Bedrijfskunde" :ects 3 :points 10}
55
                     {:name "Wiskundige analyse 2" :ects 4 :points 10}
56
                     {:name "Materiaaltechnologie" :ects 5 :points 10}
57
                     {:name "MeLa" :ects 8 :points 10}])
58
59
(def actual_results [
60
  {:name "caad 1a" :ects 3 :points 12}
61
  {:name "caad 1b" :ects 3 :points 15}
62
  {:name "ontwerpstudio ir en ctheorie" :ects 9 :points 11}
63
  {:name "schetsen 1a" :ects 3 :points 10}
64
  {:name "inleiding arch- en kunstgeesch" :ects 3 :points 1}
65
  {:name "inleiding matleer" :ects 3 :points 8}
66
  {:name "const en matleer 1a" :ects 3 :points 12}
67
  {:name "O&BSMRH" :ects 3 :points 15}
68
  {:name "Menswet 1" :ects 3 :points 10}
69
  {:name "ontwerpstudio wonen" :ects 9 :points 12}
70
  {:name "schetsen 1b" :ects 3 :points 11}
71
  {:name "inleiding arch en kunstgeesch 2" :ects 3 :points 10}
72
  {:name "const. eb matleer 1B" :ects 3 :points 11}
73
  {:name "beelding 1a" :ects 3 :points 16}
74
  {:name "beelding 1b" :ects 3 :points 12}
75
  {:name "comf en energ 1" :ects 3 :points 11}])
76
77
(println (uhasselt-tolerable actual_results))
78
79
(println (notweighed actual_results))
80