CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 17:47:05 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=9762bb7508d4fde396343cc08fdb73cfd5e630bd74025825b87f85345fc3069ba%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22iMByJJ46YTphvNl8baTBrSDkP65bBQ6s%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d02e3a9be55917-BLR
(define (itinerary flights) ;function to get the best matching pair accordi - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (itinerary flights)
- ;function to get the best matching pair according to string conditions
- (define (getBestPair start lst [pair '()])
- (if (empty? lst)
- pair
- ;if element we are expecting is a match
- (if (equal? start (car (car lst)))
- (cond
- ;case for getting first pair
- [(empty? pair) (getBestPair start (cdr lst) (car lst))]
- ;best pair condition
- [(string<? (cdr (car lst)) (cdr pair)) (getBestPair start (cdr lst) (car lst))]
- ;else skip pair
- [else (getBestPair start (cdr lst) pair)])
- ;skip pair
- (getBestPair start (cdr lst) pair))
- )
- )
- ;get list of all possible best pairs
- (define (getBestPairs start lst [res '()])
- (define pair (getBestPair start lst))
- (if (empty? pair)
- res
- (getBestPairs start (remove pair lst) (append res (list pair)))
- )
- )
- ;inspect all possible routes according to best pairs
- (define (getBestRoute start inspectList pairs [res '()])
- ;if no elements to inspect
- (if (empty? inspectList)
- ;add start because path gets appended before calling function for next pair to examine
- (append res (list start))
- (let ()
- ;if there are no pairs to inspect
- (if (empty? pairs)
- ;no such path
- #f
- (let ()
- (define pair (car pairs))
- (define newList (remove pair inspectList))
- (define newStart (cdr pair))
- ;get rest of the path (new arguments)
- (define newRes (getBestRoute newStart newList (getBestPairs newStart newList) (append res (list (car pair)))))
- ;catch the false state
- (if (eq? newRes #f)
- ;revert old arguments and remove inspected pair
- (getBestRoute start inspectList (remove pair pairs) res)
- ;return result
- newRes
- )
- )
- )
- )
- )
- )
- (λ (start)
- (if (empty? (getBestPair start flights))
- ;if there is no best pair
- (error "No such itinerary!")
- (let ()
- (define pairs (getBestPairs start flights))
- (define route (getBestRoute start flights pairs))
- (if (eq? route #f)
- (error "No such itinerary!")
- route
- )
- )
- )
- )
- )
- ;((itinerary '(("A" . "C") ("C" . "A") ("A" . "B"))) "A")
- (equal? ((itinerary '(("A" . "C") ("C" . "A") ("A" . "B"))) "A") '("A" "C" "A" "B"))
- (equal? ((itinerary '(("G" . "E") ("E" . "F") ("A" . "G") ("D" . "E") ("B" . "C") ("E" . "C") ("A" . "B") ("C" . "D") ("F" . "A") ("C" . "A"))) "A")
- '("A" "B" "C" "A" "G" "E" "C" "D" "E" "F" "A"))
- (equal? ((itinerary '(("SFO" . "HKO") ("YYZ" . "SFO") ("YUL" . "YYZ") ("HKO" . "ORD"))) "YUL") '("YUL" "YYZ" "SFO" "HKO" "ORD"))
- ;this line has to throw error
- ;((itinerary '(("SFO" . "COM") ("COM" . "YYZ"))) "COM")
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 2 sec ago | 0.24 KB
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 3 sec ago | 0.24 KB
-
⭐⭐Exchange Exploit⭐⭐ 4
JavaScript | 6 sec ago | 0.24 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ N
JavaScript | 11 sec ago | 0.24 KB
-
✅⭐ Make $2500 in 15 minutes ✅ NEVER SEEN BEFO...
JavaScript | 13 sec ago | 0.24 KB
-
✅⭐ Make huge profits on trading ⭐⭐ W
JavaScript | 15 sec ago | 0.24 KB
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ J
JavaScript | 19 sec ago | 0.24 KB
-
⭐⭐⭐MAKE $500 IN 15 MIN⭐⭐
Java | 21 sec ago | 0.10 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand