趣味编程:静夜思(Rust版)
extern crate itertools; use itertools::Itertools; fn main() { let text = "床前明月光疑是地上霜举头望明月低头思故乡"; let offset = 5; let v = text.chars().enumerate().sorted_by_key(|x| x.0 % offset).collect_vec(); for (_, group) in &v.into_iter().group_by(|x| x.0 % offset) { let s: String = group.map(|x| x.1).collect_vec().into_iter().rev().intersperse(‘|‘).collect(); println!("{}", s); } } /* 低|举|疑|床 头|头|是|前 思|望|地|明 故|明|上|月 乡|月|霜|光 */
相关推荐
zhangxiafll 2020-11-13
svap 2020-11-09
viplinux 2020-10-28
Justhavefun 2020-10-22
lousir 2020-10-21
longzhiwen 2020-10-16
Justhavefun 2020-09-25
归去来兮 2020-09-18
zhouxiaojie 2020-09-16
gamedevd 2020-09-04
tkernel 2020-09-03
Trustport 2020-09-01
svap 2020-08-25
tkernel 2020-08-18
lihn 2020-08-18
归去来兮 2020-07-28
TianlangStudio 2020-07-18
iammjun 2020-07-07
Colourful 2020-07-03