Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Rust
Checking the sample code
1
2
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//use std::io;
//macro_rules! parse_input {
fn main() {
// let mut input_line = String::new();
// io::stdin().read_line(&mut input_line).unwrap();
// let m = input_line.trim_matches('\n').to_string();
let m = "CG";
let c = ["00", "0"];
let mut b = "".to_string();
for ch in m.chars() {
let g = format!("{:0>7b}", ch as u8);
b.push_str(&g);
}
let l: u8 = b.as_bytes()[0];
let mut a = c[(l - b'0') as usize].to_string();
a.push_str(&" 0".to_string());
for i in 1..b.len() as usize {
if b.as_bytes()[i] == b.as_bytes()[i - 1] {
a.push_str(&"0".to_string());
} else {
a.push_str(&" ".to_string());
a.push_str(&c[(b.as_bytes()[i] - b'0') as usize].to_string());
a.push_str(&" 0".to_string());
}
}
// eprintln!("Debug message...");
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