Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Scala
Checking the sample code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import scala.io.StdIn._
object Main extends App {
// val m = readLine
val m = "CG"
val c = List("00", "0")
var b = ""
for (i <- 0 until m.length) {
b += m.charAt(i).toBinaryString.reverse.padTo(7, '0').reverse
}
var a = ""
a += c(b.charAt(0) - '0'.toInt) + " 0"
for (i <- 1 until b.length) {
if (b.charAt(i) == b.charAt(i - 1)) {
a += "0"
} else {
a += " " + c(b.charAt(i) - '0'.toInt) + " 0"
}
}
// Console.err.println("Debug messages...")
println(a)
}
Enter to Rename, Shift+Enter to Preview
Looking at the syntax
- TODO
Other characteristics
- TODO
Resources to check
Coming next...
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content