day 5 awk add some comments
This commit is contained in:
		
							parent
							
								
									29b20e27fc
								
							
						
					
					
						commit
						bc646722df
					
				@ -1,15 +1,17 @@
 | 
			
		||||
# run me with awk -f sol.awk < input
 | 
			
		||||
 | 
			
		||||
/\[/ {
 | 
			
		||||
    gsub("^   ", "[ ]")
 | 
			
		||||
    gsub(" {4}", " [ ]")
 | 
			
		||||
    gsub("^\\[|\\] \\[|\\]$", "")
 | 
			
		||||
/\[/ {                            # "    [A]     [B] [C]    "
 | 
			
		||||
    gsub("^   ", "[ ]")           # "[ ] [A]     [B] [C]    "
 | 
			
		||||
    gsub(" {4}", " [ ]")          # "[ ] [A] [ ] [B] [C] [ ]"
 | 
			
		||||
    gsub("^\\[|\\] \\[|\\]$", "") # " A BC "
 | 
			
		||||
    lines[nlines++] = $0
 | 
			
		||||
    if (nstacks < length())
 | 
			
		||||
        nstacks = length()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/^$/ {
 | 
			
		||||
    # transpose lines[j][i] -> stack[i][-j]
 | 
			
		||||
    # and strip trailing spaces
 | 
			
		||||
    for (i = 1; i <= nstacks; i++) {
 | 
			
		||||
        s = ""
 | 
			
		||||
        for (j = nlines-1; j >= 0; j--) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user