Manafall Daily Quest

Path Finder in a Grid

Function Name: pathFinder

Description

Write a function named pathFinder that finds a path from the top-left corner to the bottom-right corner of a 2D grid. The grid is represented as a matrix of 0s and 1s, where 0 indicates a walkable cell, and 1 indicates an obstacle. The function needs to return a boolean indicating whether a path exists. You should move horizontally or vertically, but not diagonally.

Requirements

  • The function pathFinder should take a 2D array representing the grid as its argument.
  • The grid will only contain 0s (walkable space) and 1s (obstacles).
  • The starting cell will always be top-left (0,0) and the destination cell will always be bottom-right (grid's width-1, grid's height-1).
  • The path must only travel through walkable cells (0s) and cannot pass through obstacles (1s).
  • You should optimize the function for readability and efficiency.

Examples

Example call: pathFinder([[0, 0, 0], [0, 1, 0], [1, 0, 0]])Expected return value: true, since there is a path: right -> right -> down -> down.

Links

https://en.wikipedia.org/wiki/Pathfindinghttps://en.wikipedia.org/wiki/Maze_solving_algorithmhttps://en.wikipedia.org/wiki/Flood_fill

Balanced Brackets

Mon Dec 16 2024

Write a function `isBalanced` that takes a string containing only brackets `()[]{}` and checks if the string is balanced. A string is balanced if all brackets are correctly closed and nested. The function should return `true` if the input string is balanced, otherwise, it should return `false`.

Prev Quest

Magic Square Validator

Wed Dec 18 2024

Write a function that takes a 2D array of integers and determines if the array represents a valid magic square. A magic square is a square grid filled with distinct positive integers such that the sum of the numbers in any horizontal, vertical, or diagonal line is always the same. Your function should return true if the 2D array is a magic square, and false otherwise.

Next Quest