Last active
December 14, 2017 16:27
-
-
Save crevier/2d594378a0bb2fe5367295d123daac58 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input = new Scanner(System.in); | |
r = input.nextInt() | |
l = input.nextInt() | |
c = [[r],[1,r]] | |
(2..l-1).each { | |
List list = c[it - 1] | |
result = [] | |
i = 1 | |
while (i <= list.size()) { | |
count = 1 | |
while (list[i - 1] == list[i]) { | |
count++ | |
i++ | |
} | |
result.add(count) | |
result.add(list[i - 1]) | |
count = 1 | |
i++ | |
} | |
c.add(result) | |
} | |
println(c[l-1].join(" ")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment