Skip to content

Commit

Permalink
Fix filenames (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmheim authored May 23, 2024
1 parent b3fb910 commit 80ae14b
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 53 deletions.
13 changes: 5 additions & 8 deletions exams/balanced-tree/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,10 @@ For your convenience, you are provided with the functions
tree)
))
```


where `is-leaf?` determines whether a node is empty, and `show-tree` prints tree in a human readable format.

Your task is to be called `task3.rkt` and must provide the `build-heap` and `is-leaf?` functions and
the `node` structure.
Hence, the head of your file should read
Your task is to be called `balanced-tree.rkt` and must provide the `build-heap` and `is-leaf?` functions and
the `node` structure. Hence, the head of your file should read
```scheme
#lang racket
(provide node node-v node-left node-right is-leaf? build-heap)
Expand Down Expand Up @@ -242,11 +239,11 @@ instance (Show a) => Show (Tree a) where
show tree = tostr tree 0
```

Your task is to be called `Task4.rkt` and must export the `buildHeap` function and the `Tree` data type.
Your task is to be called `BalancedTree.hs` and must export the `buildHeap` function and the `Tree` data type.
Hence, the head of your file should read

```haskell
module Task4 ( Tree (..), buildHeap) where
module BalancedTree ( Tree (..), buildHeap) where
data Tree a = Leaf | Node a (Tree a) (Tree a)
```

Expand Down Expand Up @@ -283,7 +280,7 @@ buildHeap [1,1,2,3,5,8,13,21,34,55]

::: details
```haskell
module Task4 ( Tree (..), build_heap) where
module BalancedTree ( Tree (..), build_heap) where

data Tree a = Leaf | Node a (Tree a) (Tree a)

Expand Down
6 changes: 3 additions & 3 deletions exams/building-trees/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ For example,
(node 1 (list (leaf 3) (node 2 (list (leaf 4))))) ; not correct
```

Your file should be called `task3.rkt` and should export the `add-edge` and
Your file should be called `building-trees.rkt` and should export the `add-edge` and
`build-tree` functions and the structures `node` and `leaf`.
```scheme
#lang racket
Expand Down Expand Up @@ -191,11 +191,11 @@ the typeclass `Ord`. For example,
Node {val = 2, kids = [Leaf {val = 4}]}]} -- not correct
```

Your file should be called `Task4.hs` and should export the `buildTree`,
Your file should be called `BuildingTrees.hs` and should export the `buildTree`,
`addEdge` functions and the type `Tree`.

```haskell
module Task4 (addEdge, buildTree, Tree(..)) where
module BuildingTrees (addEdge, buildTree, Tree(..)) where
import Data.List

data Tree a = Leaf { val :: a }
Expand Down
11 changes: 5 additions & 6 deletions exams/cheap-flights/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ traveling along the edge.
Below you can see an exemplary graph with 5 nodes. The cost to travel along an edge is written next to the
corresponding edge.

<img src="/img/cheap-flights-graph.svg" style="width: 50%; margin-left: auto; margin-right: auto;"
class="inverting-image"/>
<img src="/img/cheap-flights-graph.svg" style="width: 50%; margin-left: auto; margin-right: auto;" class="inverting-image"/>


## Racket
Expand Down Expand Up @@ -48,7 +47,7 @@ Write a function `(cheapflight a b gr)` which takes a starting node `a`, a desti
graph `gr`, and returns a list containing the cheapest path from start to destination, as well as the
total cost. If there is no path from `a` to `b` return `#f`

Your solution must be in a file called `task2.rkt` and has to `provide` the `cheapflight` function.
Your solution must be in a file called in `cheapflights.rkt` and has to `provide` the `cheapflight` function.
Your file should therefore start like this:
```scheme
#lang racket
Expand Down Expand Up @@ -227,11 +226,11 @@ p3 = [2,5,4,3] -- cost: 6
Write a function `cheapflight :: Node -> Node -> Graph -> Maybe (Path,Cost)` which takes a starting
`Node`, a destination `Node`, a `Graph`, and returns the cheapest path from start to destination, as
well as the total cost.
Your solution must be in a module called `Task3.hs` and export the defined
Your solution must be in a module called `CheapFlights.hs` and export the defined
types as well was the `cheapflight` function. Your file should therefore start like this:

```haskell
module Task3 (cheapflight,Node,Cost,Edge,Graph,Path) where
module CheapFlights (cheapflight,Node,Cost,Edge,Graph,Path) where
import Data.List -- needed for sorting (see hints)

-- ... your code goes here ...
Expand Down Expand Up @@ -272,7 +271,7 @@ sortBy lowcost [([1,3],2.0) ([1,2,3],0.3)]

::: details Solution
```haskell
module Task3 (cheapflight,Node,Cost,Edge,Graph,Path) where
module CheapFlights (cheapflight,Node,Cost,Edge,Graph,Path) where
import Data.List

type Node = Int
Expand Down
4 changes: 3 additions & 1 deletion exams/filetree/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ already in the tree with the function
(exists file tree)
```

Your file should be called `filetree.rkt` and `provide` the `parse` and `exists` functions.

### Hints

Expand Down Expand Up @@ -174,7 +175,7 @@ already in the tree with the function
exists :: String -> FTree String -> Bool
```

Your filename has to end in `.hs`.
Your file should be called `Filetree.hs`, contain a module of the same name, and export the `parse` and `exists` functions.

### Example

Expand Down Expand Up @@ -226,6 +227,7 @@ In the `_exists` function if we find `x` in the current tree level, we want to r
**Full solution**

```haskell
module Filetree (parse, exists) where
import Data.Maybe
import Data.Map (Map)
import qualified Data.Map as Map
Expand Down
6 changes: 6 additions & 0 deletions exams/justify/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ Constraints:

## Racket


Your file should be called `justify.rkt`, and `provide` the `justify` function.

::: details Solution
```scheme
#lang racket
Expand Down Expand Up @@ -232,8 +235,11 @@ Constraints:

## Haskell

Your file should be called `Justify.hs`, contain a module of the same name, and export the `justify` function.

::: details Solution
```haskell
module Justify (justify) where
import Data.List (intercalate)

pad :: [String] -> Int -> String
Expand Down
6 changes: 3 additions & 3 deletions exams/least-common-ancestor/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ For example,
'(1 3 7)
```

Your file should be called \texttt{task3.rkt} and should export the `find-path` and
Your file should be called `ancestor.rkt` and should export the `find-path` and
`common-ancestor` functions and the structures `node` and `leaf`.
```scheme
#lang racket
Expand Down Expand Up @@ -161,11 +161,11 @@ tree = Node 1 (Node 2 (Leaf 5) (Leaf 6)) (Node 3 (Leaf 4) (Leaf 7))
[1,3,7]
```

Your file should be called `Task4.hs` and should export the `commonAncestor`,
Your file should be called `Ancestor.hs` and should export the `commonAncestor`,
`findPath` functions and the type `Tree`.

```haskell
module Task4 (findPath, commonAncestor, Tree(..)) where
module Ancestor (findPath, commonAncestor, Tree(..)) where

data Tree a = Leaf a
| Node a (Tree a) (Tree a) deriving (Eq,Show)
Expand Down
9 changes: 5 additions & 4 deletions exams/manhattan-distance/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $$

In Racket, write a function (grid points) that accepts a list of named points and computes the
nearest neighbour grid. The output should be a list of strings where each string represents one row
in the grid.
in the grid. Your file should be called `manhattan.rkt`

```scheme
#lang racket
Expand Down Expand Up @@ -144,10 +144,11 @@ To construct a string from a list of characters `list->string`.
## Haskell Implementation
In Haskell, write a function `grid :: [(Char,Int,Int)] -> [[Char]]` that computes the nearest
neighbour grid. The output should be a list of strings where each string represents one row in the
grid.
grid. You file should be called `Manhattan.hs`, contain a module of the same name, and export the
`grid` function:

```haskell
module Task4 (grid) where
module Manhattan (grid) where
import Data.Char
import Data.List

Expand Down Expand Up @@ -192,7 +193,7 @@ From the library `Data.List` you can use your favourite sorting function like `s

::: details Solution
```haskell
module Task4 (grid) where
module Manhattan (grid) where
import Data.List
import Data.Char (toLower)

Expand Down
4 changes: 2 additions & 2 deletions exams/minesweeper/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ $$

## Racket

Your file should have the extension `.rkt`. You may assume the input is rectangular and non-empty.
Your file should be called `minesweeper.rkt`. You may assume the input is rectangular and non-empty.
The functions `string->list` and `string-split` might be useful to parse the output of the function
`port-lines` which reads from stdin. You can use the following skeleton.
```scheme
Expand Down Expand Up @@ -121,7 +121,7 @@ ghci> readInput
["...","...","..."] <-- this is the function output
```

Your file should have the extension `.hs`.
Your file should have the extension `Minesweeper.hs`.

```haskell
-- for converting ints to chars
Expand Down
10 changes: 4 additions & 6 deletions exams/minimum-spanning-tree/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ edges are represented by the following structures:
(struct graph (nodes edges) #:transparent)
```

Your file has to be called `task3.rkt` and must provide the function
`minimum-spanning-tree` and the above structures so
it should start like this:
Your file has to be called `spanning-tree.rkt`, provide the function
`minimum-spanning-tree` and the above structures so it should start like this:
```scheme
#lang racket
(provide minimum-spanning-tree (struct-out edge) graph)
Expand Down Expand Up @@ -156,8 +155,7 @@ allowing sorting w.r.t. a given comparing function, e.g.,

# Haskell

In Haskell, we represent the weighted graph and edges by the following
types:
In Haskell, we represent the weighted graph and edges by the following types:
```haskell
data Edge a b = Edge { u :: a,
v :: a,
Expand Down Expand Up @@ -197,7 +195,7 @@ The returned list of edges might be ordered arbitrarily. Each edge might be ord
well. For instance, it does not matter if your output contains `Edge {u='C', v='F', weight=5}` or
`Edge {u='F', v='C', weight=5}`. However, do not include both variants in your output.

Your file has to be called `Task4.hs` and must export the function
Your file has to be called `SpanningTree.hs` and must export the function
`minSpanningTree` and the data types `Graph a b`,
`Edge a b` so it should start like this:
```haskell
Expand Down
6 changes: 5 additions & 1 deletion exams/n2-knights/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ In Racket, implement the function

where `board` is a list of lists representing an arbitrarily sized board containing binary values,
where 1 denotes a knight and 0 an empty cell; The function returns `#t` if and only if no knight
threatens another one.
threatens another one. Your file should be called `knights.rkt` and `provide` the `is_valid?`
function.

### Examples
```scheme
Expand Down Expand Up @@ -122,6 +123,8 @@ where

and the function returns `True` if and only if no knight threatens another one.

Your file should be called `Knights.hs`, contain a module of the same name, and export the `is_valid` function.

### Examples

```haskell
Expand All @@ -140,6 +143,7 @@ False

::: details Solution
```haskell
module Knights (is_valid) where
data Piece = Nil | Knight deriving Show

enumerate :: [a] -> [(Int, a)]
Expand Down
6 changes: 3 additions & 3 deletions exams/photo-skyscraper/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ four symbols: `'N`, `'S`, `'E`, and `'N`. The result should be a pair of the for
'(W . 7)
```

Your file should be called `task3.rkt` and should `provide` the `best-view` function.
Your file should be called `photo-skyscraper.rkt` and should `provide` the `best-view` function.
```scheme
#lang racket
Expand Down Expand Up @@ -113,9 +113,9 @@ city = [[3, 3, 3],
bestView city -- ('W', 7)
```

Your file should be called `Task4.hs` and should export the `bestView` function.
Your file should be called `PhotoSkyscraper.hs` and should export the `bestView` function.
```haskell
module Task4 (bestView) where
module PhotoSkyscraper (bestView) where

bestView :: [[Int]] -> (Char, Int)
bestView city = ... -- Implement me!
Expand Down
5 changes: 4 additions & 1 deletion exams/rock-paper-scissors/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Throws will be represented as the symbols `'r`, `'p` and `'s`.
```
You can use the `remove-duplicates` function to remove duplicate throws and `sort` with `symbol<?` to order throws.

Your file is to be called `rps.rkt` and must provide the function `rps`.

### Examples

Alice wins in the second round. Charlie loses immediately.
Expand Down Expand Up @@ -123,8 +125,9 @@ First two rounds are stalemates (stalemate, stalemate, win).
## Haskell

For simplicity, throws will be represented as the characters `'r'`, `'p'` and `'s'`.
Your task is to be called `RPS.hs` and must export the `rps` function.
```haskell
module Task4 (rps) where
module RPS (rps) where
import Data.List

isFinished xs = null xs || any null xs
Expand Down
2 changes: 2 additions & 0 deletions exams/sierpinski-carpet/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Enter row1 row2 col1 col2:
_Make sure your program outputs the messages as in the examples_ (i.e. `Enter n:`, etc). Otherwise
the automatic evaluation will fail.

Your file has to be called `Sierpinsky.hs`.

## Hints

To join the boxes represented as lists of strings in the top figure you may find the function
Expand Down
10 changes: 5 additions & 5 deletions exams/spiral-matrix/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ A matrix is represented as a list of its rows, e.g. $\mathbf{S}_3$ is represente
(7 6 5))
```

Your file is to be called `task3.rkt` and must provide the function `spiral-matrix`.
Your file is to be called `spiral-matrix.rkt` and must provide the function `spiral-matrix`.
Hence, the head of your file should start with
```scheme
#lang racket
Expand Down Expand Up @@ -134,15 +134,15 @@ A matrix is represented as a list of its rows by data type
```


Your task is to be called `Task4.rkt` and must export the `spiralMatrix`
Your task is to be called `SpiralMatrix.rkt` and must export the `spiralMatrix`
function.
Hence, the head of your file should read

```haskell
module Task4 ( spiralMatrix ) where
type Matrix = [[Int]]
module SpiralMatrix ( spiralMatrix ) where
type Matrix = [[Int]]

-- your code goes here
-- your code goes here
```

### Hint
Expand Down
7 changes: 3 additions & 4 deletions exams/square-code/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $c$ is the smallest natural number greater than or equal to $\sqrt{n}$.

In Racket, implement a function `(encode str)` that accepts a string
and returns the encoded string as described above.
Your file is to be called \texttt{task3.rkt} and must provide the function `encode`.
Your file is to be called `square-code.rkt` and must provide the function `encode`.
Hence, the head of your file should start with
```scheme
#lang racket
Expand Down Expand Up @@ -104,12 +104,11 @@ The following shows the behaviour of the `encode` function.

In Haskell, implement a function `encode :: String -> String` that accepts a string
and returns the encoded string as described above.
Your task is to be called \texttt{Task4.rkt} and must export the `encode`
function.
Your task is to be called `SquareCode.hs` and must export the `encode` function.
Hence, the head of your file should read

```haskell
module Task4 ( encode ) where
module SquareCode ( encode ) where
import Data.Char

-- your code goes here
Expand Down
Loading

0 comments on commit 80ae14b

Please sign in to comment.