21 lines
357 B
Rust
21 lines
357 B
Rust
|
fn main() {
|
||
|
let s: String = "ABAABBAA".chars()
|
||
|
.filter(|c| {
|
||
|
if *c == 'A' {
|
||
|
true
|
||
|
}
|
||
|
else {
|
||
|
false
|
||
|
}
|
||
|
})
|
||
|
.map(|c| -> char {
|
||
|
if c == 'A' {
|
||
|
'0'
|
||
|
} else {
|
||
|
'1'
|
||
|
}
|
||
|
}).collect();
|
||
|
|
||
|
println!("{}", s);
|
||
|
}
|