Codegolf challenge Hexagon
- FORM h USING s. "ABAP subroutine
- DO s * 2 - 1 TIMES. "basically a simple for loop; loop over each line top to bottom
- WRITE /''. "Newline. No effect on first line for some reason. *shrug*
- "Also, WRITE /. works, too, but outputs TWO line feeds here. Ugh.
- DATA(y) = sy-index. "Save current index in loop to Y
- DO s * 2 - 1 TIMES. "Loop for each character left to right
- IF sy-index > s - y "Check if we need to write a '*'
- AND sy-index > y - s. "by subtracting size from current line and vice versa
- WRITE'*'. "Print the '*'. WRITE has an implicit space after the output!
- WRITE ``. "Empty literal. CANNOT be '' or ' ' because then we don't get any output.
- ENDIF. "Yeah, WRITE is odd. Don't ask.
- ENDDO. "End of inner loop
- ENDDO. "End of outer loop
- ENDFORM. "End of subroutine
RAW Paste Data