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).

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter9: Records (struct)
Section: Chapter Questions
Problem 15SA
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
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning