Skip to content

Commit 7956a11

Browse files
committed
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.
1 parent 33768c4 commit 7956a11

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/test/bench/shootout-reverse-complement.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// ignore-android doesn't terminate?
12+
// ignore-pretty
1213

1314
use std::iter::range_step;
1415
use std::io::{stdin, stdout, File};
@@ -73,10 +74,11 @@ fn main() {
7374
*front = complements[*back];
7475
*back = tmp;
7576
}
77+
(Some(last), None) => *last = complements[*last], // last element
7678
_ => break // vector exhausted.
7779
}
7880
}
7981
}
8082

81-
stdout().write(data);
83+
stdout().write(data).unwrap();
8284
}

0 commit comments

Comments
 (0)