Algorithm - Numbering for TOC (Table of Contents)
- by belisarius
I want to implement a VBA function to number Excel rows based upon the grouping depth of the row.
But I think a general algorithm for generating TOCs is more interesting.
The problem is:
Given a list of "indented" lines such as
One
Two
Three
Four
Five
Six
(the "indentation level" may be assumed to be known and part of the input data)
To generate the following output:
1. One
1.1 Two
1.1.1 Three
1.1.1.1 Four
1.2 Five
2. Six
Of course my code is up and running ... and also hidden under THWoS (The Heavy Weight of Shame)