Hoán vị quay lui python

Xin chào các bạn, trong bài viết này chúng ta sẽ khám phá cách tìm giải pháp cho Backtracking Python trong lập trình

def permutation[list, start, end]:
    '''This prints all the permutations of a given list
       it takes the list,the starting and ending indices as input'''
    if [start == end]:
        print list
    else:
        for i in range[start, end + 1]:
            list[start], list[i] = list[i], list[start]  # The swapping
            permutation[list, start + 1, end]
            list[start], list[i] = list[i], list[start]  # Backtracking
permutation[[1, 2, 3], 0, 2]  # The first index of a list is zero

Chúng tôi đã trình bày rất nhiều ví dụ minh họa để chỉ ra cách giải quyết vấn đề Backtracking Python và chúng tôi cũng đã giải thích cách thực hiện

Quay lui trong mã hóa là gì?

Thuật toán quay lui là thuật toán giải quyết vấn đề sử dụng cách tiếp cận mạnh mẽ để tìm đầu ra mong muốn. Phương pháp Brute force thử tất cả các giải pháp khả thi và chọn giải pháp mong muốn/tốt nhất

backtracking là gì đưa ra một ví dụ?

Quay lui là một loại thuật toán để tìm lời giải cho một số bài toán tính toán, đáng chú ý là các bài toán thỏa mãn ràng buộc, giúp xây dựng dần dần các ứng viên cho lời giải và loại bỏ một ứng viên ["quay lui"] ngay khi nó xác định rằng ứng viên đó không thể được hoàn thành cho một

Quay lui so với đệ quy là gì?

Sự khác biệt giữa đệ quy và quay lui. Trong đệ quy, hàm gọi chính nó cho đến khi gặp trường hợp cơ sở. Trong quay lui, chúng tôi sử dụng đệ quy để khám phá tất cả các khả năng cho đến khi chúng tôi nhận được kết quả tốt nhất cho vấn đề. 14-Tháng 9-2022

Backtracking và DFS có giống nhau không?

DFS là một 'thuật toán' đệ quy đặc biệt, trong khi Quay lui là 'ý tưởng' [thực ra là ràng buộc] được áp dụng cho bất kỳ thuật toán đệ quy nào

Backtracking là DFS hay BFS?

Backtracking đi qua cây không gian trạng thái theo cách DFS [Depth First Search]. Branch-and-Bound đi qua cây theo bất kỳ cách nào, DFS hoặc BFS. 13-Jun-2022

Quay lui trong Sudoku là gì?

Một Sudoku [trên cùng] đang được giải bằng cách quay lui. Mỗi ô được kiểm tra để tìm một số hợp lệ, di chuyển "quay lại" khi có vi phạm và di chuyển về phía trước một lần nữa cho đến khi câu đố được giải quyết

Khi nào tôi nên sử dụng quay lui?

Nó được sử dụng để giải quyết một loạt các vấn đề. Ví dụ, bạn có thể sử dụng nó để tìm một giải pháp khả thi cho một vấn đề quyết định. Các thuật toán quay lui cũng được phát hiện là rất hiệu quả để giải quyết các vấn đề tối ưu hóa. Trong một số trường hợp, nó được sử dụng để tìm tất cả các giải pháp khả thi cho bài toán liệt kê. 16-Aug-2022

Tìm kiếm quay lui trong AI là gì?

tìm kiếm quay lui. Tìm kiếm chuyên sâu chọn các giá trị cho một biến tại một thời điểm và quay lại khi một biến không còn giá trị pháp lý nào để gán. Thuật toán quay lui liên tục chọn một biến chưa được gán, sau đó lần lượt thử tất cả các giá trị trong miền của biến đó, cố gắng tìm giải pháp. 24-Dec-2017

Backtracking là gì giải thích nó với vấn đề 4 quân hậu?

Bài toán 4 quân hậu[1] bao gồm việc đặt bốn quân hậu trên một bàn cờ 4 x 4 sao cho không có hai quân hậu nào có thể bắt được nhau. Tức là không được phép xếp 2 quân hậu cùng hàng, cùng cột, cùng đường chéo. 31-Aug-2019

Tại sao nó được gọi là quay lui?

Vì ban đầu bạn kiểm tra các ngăn kéo ở phòng đầu tiên nhưng không thấy nên bạn quay ra khỏi phòng đầu tiên để kiểm tra các ngăn kéo ở phòng bên cạnh. Nó còn được gọi là Thử & Lỗi. 23-Jun-2014

Hoán vị còn được gọi là “số sắp xếp” hoặc “thứ tự”, là sự sắp xếp lại các phần tử của danh sách có thứ tự S thành một tương ứng một đối một với chính S. Xâu có độ dài N có N. hoán vị.  

ví dụ

Đầu vào. S = “ABC”
Đầu ra. “ABC”, “ACB”, “BAC”, “BCA”, “CBA”, “CAB”

Đầu vào. S = “XY”
Đầu ra. “XY”, “YX”

Đề nghị thực hành

Hoán vị của một chuỗi đã cho

Thử nó

In các hoán vị của một chuỗi đã cho bằng cách sử dụng quay lui

Thực hiện theo các bước đã cho để giải quyết vấn đề

  • Tạo hàm permute[] với các tham số là chuỗi đầu vào, chỉ số đầu chuỗi, chỉ số kết thúc chuỗi
  • Gọi hàm này với các giá trị chuỗi đầu vào, 0, kích thước của chuỗi – 1
    • Trong hàm này, nếu giá trị của  L và R giống nhau thì in ra cùng một chuỗi
      • Khác chạy vòng lặp for từ L đến R và hoán đổi phần tử hiện tại trong vòng lặp for với inputString[L]
      • Sau đó gọi lại hàm này bằng cách tăng giá trị của L lên 1
      • Sau đó, hoán đổi lại các giá trị đã hoán đổi trước đó để bắt đầu quay lui

Dưới đây là việc thực hiện các phương pháp trên

C++14




All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
10

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
11

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
12

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
13
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
14
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
15

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
16

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
17

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
0

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
2

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
3
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
4
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
6_______15
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
8

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
101

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
103
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
104

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
106

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
108
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
111

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
113
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
114
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
116

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
118

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
120

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
122

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
124

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
126

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
120

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
134

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
136

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
139
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
140
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
144

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
146

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
148

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
150
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
151

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
153

C




All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
154

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
155

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
156

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
157

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
158

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
3
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
160____2161
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
162
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
161
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
164

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
161
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
168

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
170

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
172

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
174

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
176

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
177

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
178

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
179

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
00

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
3
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
02
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
161
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
04
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
6
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
8

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
12

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
103
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
104

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
17____2114
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
19
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
20

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
108
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
113
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
26

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
28

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
124

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
28
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
126

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
39

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
136

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
161
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
45______2140
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
50
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
51
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
52

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
148

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
150
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
151

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

Java




All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
59

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
60

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
61
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
62
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
63

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
146

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
61
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
68
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
3
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
70

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
74
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
140
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
79

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
81
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
82
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
83

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
85
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
86
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
87
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
88
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
93

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
95

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
97

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
99

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1001

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1003

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1005
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
3
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1007
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
6
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
8

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
103
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
104

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1018

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
108
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
113
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
114
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
116

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1027
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1028

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1027
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1030
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
88
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1032

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1027
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1028

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
93

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1044

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1046

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1048

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1050

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1052

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1003

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
61
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1057
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1059
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1061

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
161
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
168

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
161____21069

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1071

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1073

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1075

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
150
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1078

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1082

Python3




All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1083

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1084

 

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1085
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1086
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1087
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1088

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
150
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1091
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1087
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1093

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1094

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1095

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1096

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1097

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1098

 

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1085
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1100

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
103
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1103
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1106

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1108
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1109

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
108
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1112

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
113
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1115
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1116
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1118

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1120
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1122

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1124
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1125
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
88
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1127

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1120
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1131
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1132

 

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1133

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1134
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
140

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1137
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1139
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1140

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1141
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1143
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1140

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1145

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1146
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
86
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1148

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1149

C#




All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1150

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1151

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
13
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1153

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
62
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1155

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
93

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
95

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1161

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1163

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
99

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1001

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1003

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1005
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
68
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
3
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1007
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
6
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
8

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
103
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
104

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1185

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
108
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
113
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
114
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
116

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1027
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1028

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1027____21197

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1027
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1028

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
93

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1044

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1046

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1048

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1050

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1052

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1003

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
61
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
68
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1057
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1059
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1061

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
161
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
168

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
161____21235

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1071

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1073

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1075

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1134
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1244
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
82
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1134
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1247

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
150
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1250

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
134

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
61
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
68
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
3
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1259

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
74
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
140
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1268

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
148

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1274

PHP




All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1275

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1276

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1151

 

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
93

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
95

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1161

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1281

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
99

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1001

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1003

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1285
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
02
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1287
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1288
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1289
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1288
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1291
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1093

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
103
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
114
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1289
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1298
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1291
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1093

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1302
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1287____21304
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1305
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
108

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
113
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
114
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1314
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1289
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1314
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1319
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1291
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1314
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1323

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1287
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1328
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1287
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1288
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1289
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1288
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1314
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
02
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1287
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1288
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1289
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1340
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1291
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1287
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1328
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1287
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1288
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1289
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1288
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1314
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
93

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1044

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1046

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1048

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1050

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1052

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1003

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1285
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
160____21366
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1288
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1314
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1288
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1370
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1093

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1374
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1377
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1379
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
114
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1366
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1374
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1377
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1387
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1314
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1389

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1377
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1387
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1314
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1394
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1377
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1387
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1370
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1398

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1377
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1387
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1370
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1394____21374
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
150
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1408
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1377
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
134

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1287
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
140
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1417
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
51____2114
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1287
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
02
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1287
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1425
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1417
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1427

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1428

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1429

Javascript




All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1430

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1431

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
60

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1285
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1434

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
103
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
104

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1440
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1441
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
108

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
113
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1449

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1027
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1028

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1027____21197

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1027
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1028

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1285
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1464

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1467

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1468
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1469
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1471

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1073

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1075

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
150
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1475____21469
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1479
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
140
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1482

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1483

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1484

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1485

Đầu ra

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
54

Độ phức tạp về thời gian. O[N * N. ] Lưu ý rằng có N. hoán vị và nó yêu cầu thời gian O[N] để in một hoán vị.
Không gian phụ. O[R – L]

Ghi chú. Giải pháp trên in các hoán vị trùng lặp nếu có các ký tự lặp lại trong chuỗi đầu vào. Vui lòng xem liên kết bên dưới để biết giải pháp chỉ in các hoán vị riêng biệt ngay cả khi có các bản sao trong đầu vào

  • In tất cả các hoán vị riêng biệt của một chuỗi đã cho với các bản sao.  
  • Hoán vị của một chuỗi đã cho bằng STL

Một cách tiếp cận khác bằng cách nối các chuỗi con.  

Thực hiện theo ý tưởng dưới đây

  • Tạo một hàm đệ quy và chuyển chuỗi đầu vào và một chuỗi lưu trữ hoán vị [ban đầu là emptu khi được gọi từ hàm chính]
  • Nếu độ dài của chuỗi là 0, hãy in hoán vị
  • Nếu không, hãy chạy một vòng lặp từ i = 0 đến N
    • Coi S[i], là một phần của hoán vị
    • Xóa phần này khỏi chuỗi hiện tại và nối nó vào cuối hoán vị
    • Gọi hàm đệ quy với chuỗi hiện tại không chứa S[i] và hoán vị hiện tại

Dưới đây là việc thực hiện phương pháp này

C++




All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1486

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
12

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
13
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
14
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
15

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
3
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1492

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
103
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1496

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1498
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1499
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
150
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
113
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
114
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1510

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
161
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1513

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1515

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1517

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1519

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1521

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1525

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
136

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1530
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
140
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1534
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1469
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1538
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1539
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1542

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
150
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
151

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

Java




All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1547
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1548

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
62
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1155

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
68
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
3
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1554

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
103
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1559
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
86
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1561

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1563____21499
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
150____2141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
113
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
114
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1575
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
86
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1577

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
161
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1580

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1582
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
86
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1584

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1586
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
88
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1590

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1521

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1525

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
61
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
68
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
3
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1603

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1607____182
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1609

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1611____2140
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1615
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1469
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1619
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1539
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1542

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1627

Python3




All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1085
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1629

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
103
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
114
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1139
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1634
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
86
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1088

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1108
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1641
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1499____21093

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
150

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
113
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1115
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1116
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
114
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1139
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1654

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1656
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1658

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1660____21104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1662
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
86
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1664

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1666______21104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1668
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1125
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
88
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1671

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1673____21104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1660
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1125
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1666

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1679____21125
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1681

 

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1682

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1683
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1469

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1686
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1104
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
140

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1108
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
114
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1691
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1093

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1693

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1694

C#




All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
13
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1153

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
61
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
62
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1155

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
68
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
3
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1554

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
103
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1708

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1710
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1499
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
150____2141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
113
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
114
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
5
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1722

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
161
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1513

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1727

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1729

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1590

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
117
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1521

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1525

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
61
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
68
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
3
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1744

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1611____2140
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1615
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1469
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
141

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1756
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1539
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1542

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1764

Javascript




All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1430

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1767

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1769

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1285
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1771

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1772

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
103
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1775

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1779____21499
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
89

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
113
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1787

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
9

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1791

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1793

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1795

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1797

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
105
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1521

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
130

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
004

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
006
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
007

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
009
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
007

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
013
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
014
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
015

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
94

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
013
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
019

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
100
All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1542

 

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
022

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  
1485

Đầu ra

All possible strings are : ABC  ACB  BAC  BCA  CAB  CBA  

Độ phức tạp về thời gian. O[N * N. ] tôi. e. có N. hoán vị và nó yêu cầu thời gian O[N] để in một hoán vị.
Không gian phụ. Ô[. S. ]

Vui lòng viết nhận xét nếu bạn thấy các mã/thuật toán trên không chính xác hoặc tìm các cách khác để giải quyết vấn đề tương tự

Chủ Đề