Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unused_imports)]
- use std::borrow::*;
- use std::cmp::*;
- use std::collections::*;
- use std::iter::*;
- use std::mem::*;
- use std::*;
- fn main() {
- // CODEGOLF
- use std::io::stdout as o;
- use std::io::*;
- macro_rules! print{($($a:tt)*)=>{($($a)*)}}
- let mut v = vec!["".to_string()];
- let mut g = |a| {
- v.push(a);
- if v.len() == 27 {
- let mut s = v.clone();
- s.sort();
- write!(o(), "[");
- for i in 1..v.len() {
- if i > 1 {
- write!(o(), ",");
- }
- write!(
- o(),
- "{:?}",
- s[s.iter().position(|x| x == &v[i]).unwrap() - 1]
- );
- }
- write!(o(), "]");
- }
- ""
- };
- // ENDCODEGOLF
- // Test harness.
- let arg0 = [
- "Beggars can't be choosers",
- "Do unto others as you would have them do to you",
- ];
- print!("[");
- for i in 0..arg0.len() {
- if i > 0 {
- print!(",");
- }
- print!("{:?}", g(arg0[i].to_string()));
- }
- print!("]");
- }
Add Comment
Please, Sign In to add comment