The TransCompilator

Solved LeetCode program · 876 of 1,000

#1192 · Critical Connections in a Network

Hard Depth-First Search chunk-18.md

Original English source

Keep a shared adjacency as an empty list of whole numbers. Keep a shared disc as an empty list of whole numbers. Keep a shared low as an empty list of whole numbers. Keep a shared parent as an empty list of whole numbers. Keep a shared bridges as an empty list of whole numbers. Keep a shared timer of 0.

For every spot from 0 to 15.
Place 0 into adjacency.

For every spot from 0 to 3.
Place 0 into disc. Place 0 into low. Place 0 into parent.

To visit from node (a whole number) with next (a whole number). Set item next of parent to node. Explore from next. The lownext is item next of low. If lownext is less than item node of low, set item node of low to lownext. If lownext is more than item node of disc, Place node into bridges, Place next into bridges.

To revisit from node (a whole number) with next (a whole number). If next is item node of parent, return. If item next of disc is less than item node of low, set item node of low to item next of disc.

To explore from node (a whole number). Add 1 to timer. Set item node of disc to timer. Set item node of low to timer.
For every next from 0 to 3.
If item (node times 4 plus next) of adjacency is 1.
If item next of disc is 0, Visit from node with next, otherwise Revisit from node with next.

The edges is a list of 0, 1, 1, 2, 2, 0, and 1, 3.
For every edge from 0 to 3.
The origin is item (edge times 2) of edges. The target is item (edge times 2 plus 1) of edges. Set item (origin times 4 plus target) of adjacency to 1. Set item (target times 4 plus origin) of adjacency to 1.

Explore from 0.

The last is the last position of bridges.
For every spot from 0 to last by 2.
The line is empty text. The first is item spot of bridges. The second is item (spot plus 1) of bridges. The word is format whole number first as text. Place word into line. Place "," into line. The other is format whole number second as text. Place other into line. Show line.

Open in Playground Browse all 1,000 problems

Expected stdout

1,3