Skip to content

Commit dec15bc

Browse files
authored
Fixing cheaper?
Function cheaper? is wrongly defined for current input. It compares (2 3) with (2 1 3) instead of 2.0 with 1.5.
1 parent 0b94664 commit dec15bc

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

exams/cheap-flights/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ partial solutions to extend the cheapest path.
7878
In Scheme you can `sort` a list with the help of a predicate function taking two arguments. In case
7979
of a list of lists (containing cost and path) you could do the following:
8080
```racket
81-
> (define (cheaper? x y) (< (car x) (car y)))
81+
> (define (cheaper? x y) (< (cadr x) (cadr y)))
8282
> (sort '(((2 3) 2.0) ((2 1 3) 1.5)) cheaper?)
8383
'(((2 1 3) 1.5) ((2 3) 2.0))
8484
```

0 commit comments

Comments
 (0)