Guest User

Untitled

a guest
Jun 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #![allow(unused_imports)]
  2. use std::borrow::*;
  3. use std::cmp::*;
  4. use std::collections::*;
  5. use std::iter::*;
  6. use std::mem::*;
  7. use std::*;
  8. fn main() {
  9. // CODEGOLF
  10. use std::io::stdout as o;
  11. use std::io::*;
  12. macro_rules! print{($($a:tt)*)=>{($($a)*)}}
  13. let mut v = vec!["".to_string()];
  14. let mut g = |a| {
  15. v.push(a);
  16. if v.len() == 27 {
  17. let mut s = v.clone();
  18. s.sort();
  19. write!(o(), "[");
  20. for i in 1..v.len() {
  21. if i > 1 {
  22. write!(o(), ",");
  23. }
  24. write!(
  25. o(),
  26. "{:?}",
  27. s[s.iter().position(|x| x == &v[i]).unwrap() - 1]
  28. );
  29. }
  30. write!(o(), "]");
  31. }
  32. ""
  33. };
  34. // ENDCODEGOLF
  35.  
  36. // Test harness.
  37. let arg0 = [
  38. "Beggars can't be choosers",
  39. "Do unto others as you would have them do to you",
  40. ];
  41.  
  42. print!("[");
  43. for i in 0..arg0.len() {
  44. if i > 0 {
  45. print!(",");
  46. }
  47. print!("{:?}", g(arg0[i].to_string()));
  48. }
  49. print!("]");
  50. }
Add Comment
Please, Sign In to add comment