Skip to content

Instantly share code, notes, and snippets.

View markormesher's full-sized avatar
🚀

Mark Ormesher markormesher

🚀
View GitHub Profile
@markormesher
markormesher / skew-algorithm.md
Last active June 6, 2024 00:08
The Skew (Linear Time) Algorithm for Suffix Array Construction

The Skew (Linear Time) Algorithm for Suffix Array Construction

I'll use x = "processing" as an example. Throughout the example * represents the null character, which sorts before any other character (i.e. * < a < b < c < ...).

We start by creating three groups of suffixes - S0, S1 and S2 - so that each suffix in the group Sk starts at the index 3q + k for some value of q. In plain English:

  • S0 suffixes start at positions 0, 3, 6, etc.
  • S1 suffixes start at positions 1, 4, 7, etc.
  • S2 suffixes start at positions 2, 5, 8, etc.
# input: startingNode
openList = [] # nodes we have discovered but haven't visited yet
closedList = [] # nodes we have already visited, store so we don't go back to them
# if the open list is a stack, we have DFS
# if the open list is a queue, we have BFS
# if the open list is a min/max-heap that uses some function of node properties, we have heuristic search
# the closed list can be a simple set; order is not important
@markormesher
markormesher / heating.rules
Created July 28, 2022 12:57
OpenHAB Heating Rule
import org.openhab.core.model.script.ScriptServiceUtil
val heatingZones = newArrayList(
"livingRoom",
"bathroom",
"masterBedroom",
"spareBedroom",
"office",
// etc...
)