Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Groovy
Checking the sample code
Note: my solution is almost Java. A more idiomatic Groovy-like solution is needed here to show...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
inp = new Scanner(System.in)
m = inp.nextLine()
c = ["00", "0"]
b = ""
for (char w : m)
b = b.concat(Integer.toBinaryString((int)w).padLeft(7,'0'))
a = c[(int)b.charAt(0) - (int)'0'] + " 0"
for (i = 1; i < b.length(); i++)
if (b.charAt(i) == b.charAt(i - 1))
a = a.concat("0")
else
a = a.concat(" " + c[(int)b.charAt(i) - (int)'0'] + " 0")
println(a.toString())
Enter to Rename, Shift+Enter to Preview
Looking at the syntax
- TODO
Other characteristics
- TODO
Resources to check
Coming next...
Suggested playgrounds
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content