getleaks pl ;; 1}}} === - : (int * int) list = [(1, 0); (1, 2); (3, 5); (1, 5)] getleaks p2 ;; ל ל י =H - : (int * int) list = [(3, 3); (2, 2); (1, 1); (2, 3); (0, 2)] 1 Pipe matrix You are given the type type pipe= LeftRight | UpDown | DownRight | DownLeft Up Right UpDownRight | DownLeftRight;; Each of the cases represent one of the following characters (in the same order): let chars=[ |"\u{02550}";"\u{02551}";"\u{0255 4}";"\u{02557}";"\u{0255A}"; "\u{02560}"; "\u{02566}"|]; ; Note that these wont print via print_string in older OCaml versions, but they work in https://try.ocamlpro.com/. a. Write a function \(\verb+getleaks: pipe array array -> (int * int) list = +\) whose input is a rectangular pipe matrix. The pipe at (0,0) has flow and spreads it through the neighboring pipes if the corresponding pipes match / characters visually match. Note that the lack of an "UpLeft" piece implies there are no cycles and the flow can essentially only move right or down, however it can split into multiple streams. The functions should print the original matrix via the corresponding characters, followed by printing the pipes with flow, replacing pipes without flow with \(\verb+"\u{2588}"+\). A leak happens at (i,j), if a pipe at (i,j) has flow and attempts to spread it to a neighboring pipe that cannot receive flow from such direction (disregarding pipes that exit the matrix). Return the locations of leaks as a list of pairs (in any order).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Ocaml i need help
getleaks pl ;;
1}}}
===
- : (int * int) list = [(1, 0); (1, 2); (3, 5);
(1, 5)]
getleaks p2 ;;
ל ל י
=H
- : (int * int) list = [(3, 3); (2, 2); (1, 1);
(2, 3); (0, 2)]
Transcribed Image Text:getleaks pl ;; 1}}} === - : (int * int) list = [(1, 0); (1, 2); (3, 5); (1, 5)] getleaks p2 ;; ל ל י =H - : (int * int) list = [(3, 3); (2, 2); (1, 1); (2, 3); (0, 2)]
1 Pipe matrix
You are given the type
type pipe=
LeftRight | UpDown | DownRight | DownLeft Up
Right UpDownRight | DownLeftRight;;
Each of the cases represent one of the following characters (in
the same order):
let chars=[ |"\u{02550}";"\u{02551}";"\u{0255
4}";"\u{02557}";"\u{0255A}";
"\u{02560}"; "\u{02566}"|]; ;
Note that these wont print via print_string in older OCaml
versions, but they work in https://try.ocamlpro.com/.
a. Write a function \(\verb+getleaks: pipe array array -> (int
*
int) list = <fun>+\) whose input is a rectangular pipe
matrix. The pipe at (0,0) has flow and spreads it through
the neighboring pipes if the corresponding pipes match /
characters visually match. Note that the lack of an
"UpLeft" piece implies there are no cycles and the flow
can essentially only move right or down, however it can
split into multiple streams. The functions should print the
original matrix via the corresponding characters, followed
by printing the pipes with flow, replacing pipes without
flow with \(\verb+"\u{2588}"+\). A leak happens at (i,j), if a
pipe at (i,j) has flow and attempts to spread it to a
neighboring pipe that cannot receive flow from such
direction (disregarding pipes that exit the matrix). Return
the locations of leaks as a list of pairs (in any order).
Transcribed Image Text:1 Pipe matrix You are given the type type pipe= LeftRight | UpDown | DownRight | DownLeft Up Right UpDownRight | DownLeftRight;; Each of the cases represent one of the following characters (in the same order): let chars=[ |"\u{02550}";"\u{02551}";"\u{0255 4}";"\u{02557}";"\u{0255A}"; "\u{02560}"; "\u{02566}"|]; ; Note that these wont print via print_string in older OCaml versions, but they work in https://try.ocamlpro.com/. a. Write a function \(\verb+getleaks: pipe array array -> (int * int) list = <fun>+\) whose input is a rectangular pipe matrix. The pipe at (0,0) has flow and spreads it through the neighboring pipes if the corresponding pipes match / characters visually match. Note that the lack of an "UpLeft" piece implies there are no cycles and the flow can essentially only move right or down, however it can split into multiple streams. The functions should print the original matrix via the corresponding characters, followed by printing the pipes with flow, replacing pipes without flow with \(\verb+"\u{2588}"+\). A leak happens at (i,j), if a pipe at (i,j) has flow and attempts to spread it to a neighboring pipe that cannot receive flow from such direction (disregarding pipes that exit the matrix). Return the locations of leaks as a list of pairs (in any order).
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education