mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 20:54:13 +00:00
fix a bug in shootout-reverse-complement, official tests should pass with it
In the "reverse-complement" loop, if there is an odd number of element, we forget to complement the element in the middle. For example, if the input is "ggg", the result before the fix is "CgC" instead of "CCC". This is because of this bug that the official shootout says that the rust version is in "Bad Output". This commit should fix this error.
This commit is contained in:
parent
33768c46ec
commit
7956a11df6
@ -9,6 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
// ignore-android doesn't terminate?
|
||||
// ignore-pretty
|
||||
|
||||
use std::iter::range_step;
|
||||
use std::io::{stdin, stdout, File};
|
||||
@ -73,10 +74,11 @@ fn main() {
|
||||
*front = complements[*back];
|
||||
*back = tmp;
|
||||
}
|
||||
(Some(last), None) => *last = complements[*last], // last element
|
||||
_ => break // vector exhausted.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stdout().write(data);
|
||||
stdout().write(data).unwrap();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user