//直接模拟七个起点,然后把结果按字典序排序后放到集合,因为集合不能重复,所以集合的size就是结果
import java.util.Arrays;
import java.util.HashSet;
public class 七段码 {
static HashSet<String> hs = new HashSet<>();
//以a为起点
//从res过来,当前的队伍状况:list
static void dfs(String res,String list) {
//list就是一种方案
if(list.length() <=7) {
//放到set
hs.add(sort(list));
}
//如果是从a过来
if(res.equals("a")) {
// f b
//list没有f才可以走f
if(list.indexOf("f") == -1) {
//没有f
dfs("f",list + "f");
}
if(list.indexOf("b") == -1) {
//没有b
dfs("b",list + "b");
}
}
if(res.equals("b")) {
if(list.indexOf("a") == -1) {
dfs("a",list + "a");
}
if(list.indexOf("g") == -1) {
dfs("g",list + "g");
}
if(list.indexOf("c") == -1) {
dfs("c",list + "c");
}
}
if(res.equals("f")) {
if(list.indexOf("a") == -1) {
dfs("a",list + "a");
}
if(list.indexOf("g") == -1) {
dfs("g",list + "g");
}
if(list.indexOf("e") == -1) {
dfs("e",list + "e");
}
}
if(res.equals("g")) {
if(list.indexOf("f") == -1) {
dfs("f",list + "f");
}
if(list.indexOf("b") == -1) {
dfs("b",list+ "b");
}
if(list.indexOf("e") == -1) {
dfs("e",list + "e");
}
if(list.indexOf("c") == -1) {
dfs("c",list + "c");
}
}
if(res.equals("e")) {
if(list.indexOf("f") == -1) {
dfs("f",list + "f");
}
if(list.indexOf("g") == -1) {
dfs("g",list + "g");
}
if(list.indexOf("d") == -1) {
dfs("d",list+ "d");
}
}
if(res.equals("d")) {
if(list.indexOf("e") == -1) {
dfs("e",list + "e");
}
if(list.indexOf("c") == -1) {
dfs("c",list + "c");
}
}
if(res.equals("c")) {
if(list.indexOf("g") == -1) {
dfs("g",list + "g");
}
if(list.indexOf("b") == -1) {
dfs("b",list + "b");
}
if(list.indexOf("d") == -1) {
dfs("d",list + "d");
}
}
}
public static void main(String[] args) {
//以a为起点
dfs("a","a");
//
dfs("b","b");
//
dfs("c","c");
dfs("d","d");
dfs("e","e");
dfs("f","f");
dfs("g","g");
System.out.println(hs.size());
}
static String sort(String s) {
char c[] = s.toCharArray();
Arrays.sort(c);
//c已经按字典序排号
String res = "";
for(int i = 0;i<c.length;i++) {
res += String.valueOf(c[i]);
}
return res;
}
}