skendrick
10/03/2019, 2:55 PMsomeLetter
··A··
·B·B·
C···C
·B·B·
··A··
The problem description & the solution: https://gist.github.com/adnauseum/4a7c9762d57f3b82b1dd18b1204af3cb
If you want to review it, 1) thanks, 2) leave a comment in a thread or on the gist—whatever is easiest for you. 🙇 THANK YOU! Actually, the fact that anybody would leave a comment is mind-blowing, so thanks for even reading and putting in the effort!Timmy
10/03/2019, 7:02 PMleftOfMiddleIndex, rightOfMiddleIndex -> letter
- Skipped some variable definitions (leftOfMiddleIndex and rightOfMiddleIndex) and just inlined them to where they are used (not that important)
- I used an imperative approach to constructing the lines with stringBuilder (repeat(numLettersPerRow) {append(...)}
). Might be more performant than constructing a list then joining it, but at this scale it doesn't matter. Actually I like your approach better.
- Used a + instead of .plus()
- I didn't use a separate function makeRow and just had that in the lambda. If you want to keep your makeRow function, use a method reference (lettersUsedInDiamond.mapIndexed(::makeRow)
)skendrick
10/03/2019, 7:07 PMbjonnh
10/08/2019, 11:21 PM