Algorithm - Numbering for TOC (Table of Contents)
Posted
by belisarius
on Stack Overflow
See other posts from Stack Overflow
or by belisarius
Published on 2010-05-31T23:20:25Z
Indexed on
2010/05/31
23:23 UTC
Read the original article
Hit count: 399
algorithm
|pseudocode
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)
© Stack Overflow or respective owner