igorwojda / kotlin-coding-challenges

🧩 Kotlin coding puzzle and solutions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

shorter solution for StepsGenerator

nkiesel opened this issue · comments

Tried to run that in intellj w/o Android but failed to make that happen.

Anyway, looked at one problem and found a (IMHO more elegant) and def. more compact solution

private fun generateSteps(n: Int) = List(n) { i -> "#".repeat(i + 1) + " ".repeat(n - i - 1) }
  1. Nice solution, concise, and elegant - really like it.
    I have added it to repo with small change - removal of explicit lambda parameter because its type can be inferred and it does not really overlap with anything
    private fun generateSteps(n: Int) = List(n) { "#".repeat(it + 1) + " ".repeat(n - it - 1) }

  2. Here is the video that shows how to run the project. Please take look and let me know how if it works for you.
    https://1drv.ms/v/s!AkZ_52b5bWyOgrIstOERkq0ZBPopFg

  3. I have added you to contributors list :-)

Since there is no answer to this. I am closing this issue.
Please reopen it if you still have a problem with running the tests.