Skip to content

Instantly share code, notes, and snippets.

View llaryssa's full-sized avatar

Laryssa Seabra llaryssa

  • Olinda, Brasil
View GitHub Profile
import React from 'react'
import {
StyleSheet,
View,
Text,
TouchableHighlight,
Image,
TextInput
} from 'react-native'
const pathBetweenPoints = (list, start, end, currPath = []) => {
const node = list.find(({ name }) => name === start);
currPath = [...currPath, start];
if (node.connections.some((element) => element === end)) {
console.log([...currPath, end].join(" -> "));
return; // Hopefully this will break in the shortest path
} else {
node.connections?.forEach((name) => {
if (!currPath.find((element) => element === name)) {