Need someone good expert in racket programing

profilenecolas00073
hw7-problem1.rkt

;; The first three lines of this file were inserted by DrRacket. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-intermediate-reader.ss" "lang")((modname hw7-problem1) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f))) (require 2htdp/image) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Problem 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This problem asks you to design several functions that employ the ; following data definitions. The functions that you design *must* use ; list abstraction(s) when appropriate; you MAY NOT use recursion: doing ; so will lead you to get no code credit for the function :( ; ; NOTE #1: Part of the credit for each problem will be based on the choice ; of list abstractions, so make sure that they are a good match for the ; problem. ; ; NOTE #2: For certain problems, you will have to design helper functions ; that do not use list abstractions. You should follow the full design ; recipe (including appropriate use of templates) for all problems. Be sure ; to do this, even if it feels a bit tedious - listen to your templates!! ; ; Data Definitions (do not modify these) ; A Weekday is one of: ; - "Monday" ; - "Tuesday" ; - "Wednesday" ; - "Thursday" ; - "Friday" ; Interpretation: a day that excludes the weekend (define WEEKDAY-M "Monday") (define WEEKDAY-T "Tuesday") (define WEEKDAY-W "Wednesday") (define WEEKDAY-R "Thursday") (define WEEKDAY-F "Friday") (define (weekday-temp w) (... (cond [(string=? w WEEKDAY-M) ...] [(string=? w WEEKDAY-T) ...] [(string=? w WEEKDAY-W) ...] [(string=? w WEEKDAY-R) ...] [(string=? w WEEKDAY-F) ...]))) (define-struct meeting [day bname rnum hstart mstart duration]) ; A ClassMeeting is a (make-meeting Weekday String String PosInt[8, 18] NonNegInt[0, 59] PosInt) ; Interpretation: when a class is scheduled to meet weekly ; - day: which day of the week ; - bname: name of the building ; - rnum: room number ; - hstart: starting hour (24hr) ; - mstart: starting minute ; - duration: length of the class (in minutes) (define CM-FUNDIES-M (make-meeting WEEKDAY-M "WVH" "210A" 10 30 65)) (define CM-FUNDIES-W (make-meeting WEEKDAY-W "WVH" "210A" 10 30 65)) (define CM-FUNDIES-R (make-meeting WEEKDAY-R "WVH" "210A" 10 30 65)) ; (define CM-FUNDIES-LAB (make-meeting WEEKDAY-T "WVH" "212" 8 0 100)) ; (define CM-DISCRETE-T (make-meeting WEEKDAY-T "ISEC" "102" 13 35 100)) (define CM-DISCRETE-F (make-meeting WEEKDAY-F "ISEC" "102" 13 35 100)) ; (define CM-DISCRETE-SEM (make-meeting WEEKDAY-W "Hastings" "110" 16 35 65)) ; (define CM-CREATURES-T (make-meeting WEEKDAY-T "Forbidden Forest" "Hut" 13 0 200)) (define CM-POTIONS-R (make-meeting WEEKDAY-R "Hogwarts" "Dungeon" 13 0 200)) (define (classmeeting-temp cm) (... (weekday-temp (meeting-day cm)) ... (meeting-bname cm) ... (meeting-rnum cm) ... (meeting-hstart cm) ... (meeting-mstart cm) ... (meeting-duration cm) ...)) (define-struct course [prefix num name prof meetings]) ; A Course is a (make-course String String String String [List-of ClassMeeting]) ; Interpretation: a weekly class ; - prefix: the course prefix ; - num: the course number ; - name: the course name ; - prof: name of the professor ; - meetings: weekly meeting times (define COURSE-EASY-A (make-course "SCHED" "101" "Easy A" "Lazy" '())) (define COURSE-FUNDIES-LECTURE (make-course "CS" "2500" "Fundies" "Howdy" (list CM-FUNDIES-M CM-FUNDIES-W CM-FUNDIES-R))) (define COURSE-FUNDIES-LAB (make-course "CS" "2501" "Fundies Lab" "Awesome TAs" (list CM-FUNDIES-LAB))) (define COURSE-DISCRETE-LECTURE (make-course "CS" "1800" "Discrete Structures" "Dr Strange" (list CM-DISCRETE-T CM-DISCRETE-F))) (define COURSE-DISCRETE-SEM (make-course "CS" "1802" "Seminar for CS 1800" "Park" (list CM-DISCRETE-SEM))) (define COURSE-CREATURES (make-course "HPTR" "2000" "Care of Magical Creatures" "Hagrid" (list CM-CREATURES-T))) (define COURSE-POTIONS (make-course "HPTR" "2650" "Potions" "Snape" (list CM-POTIONS-R))) (define (course-temp c) (... (course-prefix c) ... (course-num c) ... (course-name c) ... (course-prof c) ... (locm-temp (course-meetings c)) ...)) ; A CourseSchedule is a [List-of Course] ; Interpretation: a list of weekly courses! (define SCHEDULE-OOPS '()) (define SCHEDULE-KHOURY (list COURSE-FUNDIES-LECTURE COURSE-FUNDIES-LAB COURSE-DISCRETE-LECTURE COURSE-DISCRETE-SEM)) (define SCHEDULE-MAGIC (list COURSE-CREATURES COURSE-POTIONS)) (define SCHEDULE-CS+MAGIC (list COURSE-FUNDIES-LECTURE COURSE-FUNDIES-LAB COURSE-CREATURES COURSE-POTIONS)) ; TODO 1/8: Part of healthy course scheduling is making sure to build in time for ; food, and so you are to design the function lunch-course that produces ; a "Lunch" course! ; ; The function should take in a prefix & number (e.g., "FOOD" "101"), ; a name & professor (e.g., "Exciting Baking" with "Alderton"), as ; well as a list of weekdays. The function will then makes sure that ; déjeuner occurs on all of those days at noon (for one hour) in a ; single location of your choice (e.g., Hogwarts Great Hall). ; ; Note: make sure to test your function on at least two sets of inputs! ; lunch-course: (make-course String String String String [List-of ClassMeeting]) ; produces a lunch course schedule (define LUNCH-course (make-meeting WEEKDAY-M "WVH" "210A" 10 30 65)) ; TODO 2/8: Design the function long-weekend? that determines if a ; course schedule avoids all classes on Mondays & Fridays. ; In the examples above, this is true of OOPS and MAGIC. ; Note: make sure to follow all the templates and ; sufficiently test all your functions! ; TODO 3/8: Design the function only-khoury that takes a course schedule ; and produces a new schedule only containing classes that ; have the prefix "CS", "DS", or "CY". So supplying OOPS and ; KHOURY would result in unaffected schedules, but MAGIC would ; result in an empty schedule and CS+MAGIC would result in a ; schedule with only Fundies :) ; ; Note: since we didn't include any DS/CY courses in the ; examples, make may need to create example courses to properly ; test your helper function(s)! Some course suggestions include ; DS2000 (Programming with Data) and CY2550 (Foundations of ; Cybersecurity). ; TODO 4/8: Design the function time-in-class that calculates total ; time spent in class (in minutes each week) for a supplied ; course schedule. For example, OOPS requires 0 minutes and ; KHOURY is 560. ; TODO 5/8: Design the function bring-water? that takes a course schedule ; and determines if any course has even a single meeting that ; lasts for longer than two hours. For example, this is true ; for either of the magic schedules, but none of the others. ; TODO 6/8: Design the function course->days-abbrev that takes a course ; and produces a single string that has abbreviations of all ; days of the week that course meets. For instance, Fundies ; lecture would produce "MWR", Fundies lab would produce "T", ; Discrete lecture would be "TF", and the "easy A" class would ; produce "" (since the lazy prof never wants to meet!). ; TODO 7/8: Design the functions stack/h and stack/v, to stack a supplied ; list of images horizontally and vertically, with a bit of buffer ; between each image (see the GAP we've defined for you). You have ; been supplied tests for clarity. (define GAP (square 5 "solid" "white")) #| (check-expect (stack/h '()) GAP) (check-expect (stack/h (list (text "A" 5 "black") (text "B" 10 "black") (text "C" 50 "black"))) (beside GAP (text "A" 5 "black") GAP (text "B" 10 "black") GAP (text "C" 50 "black") GAP)) (check-expect (stack/v '()) GAP) (check-expect (stack/v (list (text "A" 5 "black") (text "B" 10 "black") (text "C" 50 "black"))) (above GAP (text "A" 5 "black") GAP (text "B" 10 "black") GAP (text "C" 50 "black") GAP)) |# ; TODO 8/8: Now using your solutions to the previous two parts, design the ; function viz-schedule, which produces a visual representation ; of a supplied course schedule, such that each course is a row ; (with the prefix, num, name, prof, and day abbreviations) and ; the rows are vertically stacked. You have been supplied tests ; for clarity. #| (check-expect (viz-schedule SCHEDULE-OOPS) GAP) (check-expect (viz-schedule SCHEDULE-KHOURY) (above GAP (text "CS 2500 (Fundies, Howdy): MWR" 50 "black") GAP (text "CS 2501 (Fundies Lab, Awesome TAs): T" 50 "black") GAP (text "CS 1800 (Discrete Structures, Dr Strange): TF" 50 "black") GAP (text "CS 1802 (Seminar for CS 1800, Park): W" 50 "black") GAP)) |#