fun

Add Clojure script for UGent tolerances

Author
Maarten 'Vngngdn' Vangeneugden
Date
Oct. 1, 2017, 4:31 p.m.
Hash
46f629cb608fa34fb7a82a17edab14a0a99f65f1
Parent
a8049b649bc380c827789919491470ea4beb0384
Modified file
tolerantie.clj

tolerantie.clj

41 additions and 1 deletion.

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