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:
Guillaume Pinot 2014-03-08 16:56:07 +01:00
parent 33768c46ec
commit 7956a11df6

View File

@ -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();
}