-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathfaro-shuffle.cpp
More file actions
26 lines (20 loc) · 811 Bytes
/
faro-shuffle.cpp
File metadata and controls
26 lines (20 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <bits/stdc++.h>
int main() {
int N, half;
std::cin >> N; std::cin.ignore();
std::vector<std::string> dck(std::istream_iterator<std::string> {std::cin},
std::istream_iterator<std::string> {});
half = std::ceil(std::size(dck) / 2.);
while ( N-- ) {
auto lhs = std::vector<std::string>(std::begin(dck), std::begin(dck) + half);
auto rhs = std::vector<std::string>(std::begin(dck) + half, std::end(dck) );
auto lit{ std::begin(lhs) }, rit{ std::begin(rhs) };
for ( auto i = 0; i < std::size(dck); ++i )
dck[i] = ( 0 == i % 2 ) ? *lit++ : *rit++;
}
std::stringstream ss;
for ( const auto& l : dck ) ss << l << " ";
auto ret = ss.str();
ret.pop_back();
std::cout << ret;
}