Add a silly program for tolerances
- Author
- Maarten 'Vngngdn' Vangeneugden
- Date
- Aug. 22, 2017, 10:18 p.m.
- Hash
- a8049b649bc380c827789919491470ea4beb0384
- Parent
- 9f1825ef0fadc6bd0c546490f77fcfa417b58828
- Modified file
- tolerantie.clj
tolerantie.clj ¶
39 additions and 0 deletions.
View changes Hide changes
+ |
1 |
;; - Check if all points are at least 8/20 |
+ |
2 |
;; - Check if maximum two points are less than 10/20 |
+ |
3 |
;; - Check if WEIGHED total is at least 50% |
+ |
4 |
;; - If one of the conditions is not fulfilled, display which points need to be |
+ |
5 |
;; changed in order to meet the conditions |
+ |
6 |
|
+ |
7 |
(defn tolerable |
+ |
8 |
[results] |
+ |
9 |
(def weighted_results (reduce + (map * (map :ects results) (map :points results)))) |
+ |
10 |
(def failed_courses (set (filter #(< (:points %) 10) results))) |
+ |
11 |
(def failed_weight (reduce + (map * (map :ects failed_courses) (map :points failed_courses)))) |
+ |
12 |
(if (<= (/ failed_weight weighted_results) 1/100) true false)) |
+ |
13 |
|
+ |
14 |
(defn receive-courses |
+ |
15 |
([] (receive-courses #{})) |
+ |
16 |
([courses] |
+ |
17 |
(let [name (read-line) |
+ |
18 |
ects (read-line) |
+ |
19 |
points (read-line)] |
+ |
20 |
(if (= name "") |
+ |
21 |
courses |
+ |
22 |
(recur (conj courses {:name name :ects ects :points points})))))) |
+ |
23 |
|
+ |
24 |
;;(print (tolerable (receive-courses))) |
+ |
25 |
(def actual_results [ |
+ |
26 |
{:name "Discrete wiskunde 1" :ects 4 :points 10} |
+ |
27 |
{:name "Wiskunde basistechniek" :ects 3 :points 10} |
+ |
28 |
{:name "Wiskundige analyse 1" :ects 5 :points 10} |
+ |
29 |
{:name "Ingenieursproject 1" :ects 6 :points 10} |
+ |
30 |
{:name "Algemene scheikunde" :ects 6 :points 10} |
+ |
31 |
{:name "Informatica" :ects 6 :points 10} |
+ |
32 |
{:name "Natuurkunde 1" :ects 6 :points 10} |
+ |
33 |
{:name "WenS" :ects 4 :points 10} |
+ |
34 |
{:name "Bedrijfskunde" :ects 3 :points 10} |
+ |
35 |
{:name "Wiskundige analyse 2" :ects 4 :points 10} |
+ |
36 |
{:name "Materiaaltechnologie" :ects 5 :points 10} |
+ |
37 |
{:name "MeLa" :ects 8 :points 10}]) |
+ |
38 |
(print (tolerable actual_results)) |
+ |
39 |