Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Notas de lectura

Problem Set 11 - UBC 2023 - CPSC 110

Puntuación
2.0
(4)
Vendido
27
Páginas
6
Subido en
20-12-2022
Escrito en
2022/2023

Completed file for problem set 11. Remember to copy the pdf file to Dr Racket for a better view. This file should be exactly identical except that the file has answers for each problems.

Institución
Grado

Vista previa del contenido

;; DO NOT PUT ANYTHING PERSONALLY IDENTIFYING BEYOND YOUR
CWL IN THIS FILE.
;; YOUR CWLs WILL BE SUFFICIENT TO IDENTIFY YOU AND, IF YOU HAVE
ONE, YOUR
;; PARTNER.
;;
(require spd/tags)

(@assignment psets/pset-11); Do not edit or remove this tag

;; Replace the first set of '???'s with your cwl.
;; If you have a partner, replace the second set of '???'s with their cwl.
;;
(@cwl ??? ???)

(@problem 1)
;;
;; In this problem set you will be working with a simple representation of a
;; secret castle. Unsurpringly, the rooms and doors in this castle form a
;; graph. The figure in:
;; https://cs110.students.cs.ubc.ca/psets/pset-11-image.png
;; shows a small castle with 5 rooms named A, B, C, D, and E. A has exits
;; that lead to rooms B, D and E. B has a single exit that leads to C, and
;; so on. The ovals (long circles) are locks; the number in the oval is the
;; number of the key required to open that lock. The underlined numbers are
;; keys.
;;
;; E has a lock that requires key # 1 to open. The lock at room D requires key
;; # 2 to open it. After you enter a room you automatically pickup any keys
;; that are there. So after you get into room B you automatically pickup key 2.
;; After you get into room C you automatically pickup key 1.
;;
;; Note that in general a door might have multiple locks, and a room might
;; provide multiple keys.
;;
;; Here are the data definitions we use.

;; Data definitions:

(@htdd Room)
(define-struct room (name locks keys exits))

, ;; Room is (make-room String (listof Natural) (listof Natural) (listof String))
;; interp. each room has
;; - a Name
;; - locks that require a key of the same number to open
;; - keys that open locks of the same number
;; - doors to other rooms, these are represented as a list
;; of strings where each string is the name of a room
;;
;; NOTE: The keys can be for any rooms in the castle, they do not have
;; to be for one of the rooms in exits.
;;
;; This is a generative graph problem. Note that a room has a list of the names
;; of the rooms it has exits to -- the names not the actual rooms. Therefore a
;; generative step has to take the name and generate the actual Room. To do
;; that we add a new opaque data definition for a type called Map. When
;; we say that Map is opaque we mean that you should not try to look inside
;; of it. It is a secret map of the castle. Instead we are providing a
;;function
;; called get-room that given a room name and a castle will generate the room.
;;

(@htdd Map)
;; Map is ???
;; interp. an opaque data type that represents a map from room names to rooms.
;; Only the provided function get-room knows how to work with a map.
;;

#|
Here is a partially blended template. It includes the Room and (listof String)
functions, as well as the generative step of calling get-room to get a
room from
a room name. But it doesn't include the trivial? test to terminate the
generative recursion or anything to prevent going in cycles. You must complete
the blending for your own purposes.

(define (fn-for-castle start castle)
(local [(define (fn-for-room r)
(... (room-name r)
(room-locks r)
(room-keys r)
(fn-for-los (room-exits r))))

Escuela, estudio y materia

Institución
Estudio
Grado

Información del documento

Subido en
20 de diciembre de 2022
Número de páginas
6
Escrito en
2022/2023
Tipo
NOTAS DE LECTURA
Profesor(es)
Gregor kiczales
Contiene
Todas las clases

Temas

$7.99
Accede al documento completo:
Comprado por 27 estudiantes

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF


Documento también disponible en un lote

Reseñas de compradores verificados

Se muestran los 4 comentarios
3 meses hace

1 año hace

missing a question

2 año hace

does not even include the full problem set/ assignment. I want my money back

2 año hace

oh, maybe they change the assignment for each year, sorry about that. Maybe you should tell Gregor to keep the assignment the same for every year :D

2 año hace

2 año hace

Sorry for any problem with the product, I wonder you can tell me what's wrong with the problem set

2 año hace

The code does not work for me. It doesn’t contain the generate-room function or follow the format of function definition given above

2.0

4 reseñas

5
0
4
1
3
0
2
1
1
2
Reseñas confiables sobre Stuvia

Todas las reseñas las realizan usuarios reales de Stuvia después de compras verificadas.

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
tranghane Alfa-college
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
84
Miembro desde
3 año
Número de seguidores
57
Documentos
24
Última venta
3 meses hace

2.4

7 reseñas

5
1
4
1
3
1
2
1
1
3

Documentos populares

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes