arghasen
9/19/2018 - 3:31 PM

Recursive tetrahedron

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int> vertices{1,2,3,4};
int getSteps(int N, int src, int dest)
{
    if(N==0)
        return 0;
    if(N==1)
        return 1;
    auto remaining_vertices = vertices;
    remaining_vertices.erase(remove_if(remaining_vertices.begin(), remaining_vertices.end(),[src](auto i){return i==src;}), remaining_vertices.end());
    copy(remaining_vertices.begin(), remaining_vertices.end(),ostream_iterator<int>(cout," "));
    
    return getSteps(N-1, remaining_vertices[0],dest) + getSteps(N-1, remaining_vertices[1],dest) +getSteps(N-1, remaining_vertices[2],dest);
}
int main() {
	int N=4;
	cout<<getSteps(N, 4,4);
	return 0;
}