pieguy
searching PlanetScale…
- 1.▲
- 2.▲
- 3.▲
- 4.▲
- 5.▲
- 6.▲
5 ms·
- 1.▲
- 2.▲
- 3.▲
- 4.▲
- 5.▲
- 6.▲
- 7.▲
- 8.▲
- 9.▲
- 10.▲
- 11.▲
- 12.▲
- 13.▲
- 14.▲
- 15.▲
- 16.▲
- 17.▲
- 18.▲
- 19.▲
- 20.▲
- 21.▲
- 22.▲
- 23.▲
- 24.▲
Here's an iterative solution which is shorter and 3 times as fast: void iterative(int n)
{
int from[2][3] = {{0,1,2},{0,2,1}};
int to[2][3] = {{1,2,0},{2,1,0}};
for(int i=1; i<1<<n; i++)
{ - 25.▲
- 26.▲
- 27.▲
- 28.▲