Programming language: Haskell
1) Given a square grid, each word appears as a sequence of characters. Find all the words in every possible direction: vertically up or down, horizontally left or right, diagonally up-left, up-right, down-left, or down right. Write a function that returns all words from the grid in this manner [(“MYWORD1”,Just((7,0),Back), “MYWORD2”, Just ((2,1), Up)], having as types: type Grid = [[Char]], placement = (Position, Orientation), Position = (Int, Int) representing a (col, row) beginning at 0 and data Orientation = Forward | Back | Up | Down | UpForward | UpBack | DownForward | DownBack deriving (Eq,Ord,Show,Read)
2) Create a random puzzle
Given a list of words and a value which represents the density of the puzzle, write a function that returns a grid in which the given words are hidden exactly once. The function should choose random positions and orientations for all the words hidden in the grid. Make sure that the other characters in the grid are drawn randomly only from the set of characters appearing in the given input list. The density of the grid represents the ratio of the number of characters within the grid that form the hidden words to the total number of characters within the grid. The density of a grid is always between 0 and 1. The final The output grid must be sufficiently large so that the density of the output grid is less than the given maximum density but no larger