0% found this document useful (0 votes)
102 views10 pages

Input Form Reset

The document describes a VBA program for Excel that calculates all permutations of letters in an input string. It explains the purpose of the program, required software, and provides code snippets to show how it works by recursively building up permutations and outputting the results.

Uploaded by

semczuk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views10 pages

Input Form Reset

The document describes a VBA program for Excel that calculates all permutations of letters in an input string. It explains the purpose of the program, required software, and provides code snippets to show how it works by recursively building up permutations and outputting the results.

Uploaded by

semczuk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
You are on page 1/ 10

Input Form Reset

478548760.xls Summary 06/02/2020

jk_eng.xls (English Edition)

Author: YOSHIDA Hajime


[email protected]

Ver 3.0 for Excel VBA 19 May 2002

Purpose: Shows all of the Permutations/Combinations of input letters


Required software: Microsoft Excel 97 or later
Maximum of output: 65536 (depends on Excel)
Free for educational use
Downloadable from next web site
http://www.ne.jp/asahi/math.edu/ami/myprog/jk_eng.htm

Note: JK stands for Junretsu (permutation) and Kumiawase (combination) in Japanese.


Original edition is written in Japanese.
All rights reserved © YOSHIDA Hajime 2001-2002

2
478548760.xls Summary 06/02/2020

3
Table of n! Table of nPr

n n! n r 0 1 2 3 4 5 6 7 8 9 10
0 1 0 1
1 1 1 1 1
2 2 2 1 2 2
3 6 3 1 3 6 6
4 24 4 1 4 12 24 24
5 120 5 1 5 20 60 120 120
6 720 6 1 6 30 120 360 720 720
7 5040 7 1 7 42 210 840 2520 5040 5040
8 40320 8 1 8 56 336 1680 6720 20160 40320 40320
9 362880 9 1 9 72 504 3024 15120 60480 181440 362880 362880
10 3628800 10 1 10 90 720 5040 30240 151200 604800 1814400 3628800 3628800
Table of nCr

n r 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
0 1
1 1 1
2 1 2 1
3 1 3 3 1
4 1 4 6 4 1
5 1 5 10 10 5 1
6 1 6 15 20 15 6 1
7 1 7 21 35 35 21 7 1
8 1 8 28 56 70 56 28 8 1
9 1 9 36 84 126 126 84 36 9 1
10 1 10 45 120 210 252 210 120 45 10 1
11 1 11 55 165 330 462 462 330 165 55 11 1
12 1 12 66 220 495 792 924 792 495 220 66 12 1
13 1 13 78 286 715 1287 1716 1716 1287 715 286 78 13 1
14 1 14 91 364 1001 2002 3003 3432 3003 2002 1001 364 91 14 1
15 1 15 105 455 1365 3003 5005 6435 6435 5005 3003 1365 455 105 15 1
16 1 16 120 560 1820 4368 8008 11440 12870 11440 8008 4368 1820 560 120 16 1
17 1 17 136 680 2380 6188 12376 19448 24310 24310 19448 12376 6188 2380 680 136 17 1
18 1 18 153 816 3060 8568 18564 31824 43758 48620 43758 31824 18564 8568 3060 816 153 18 1
19 1 19 171 969 3876 11628 27132 50388 75582 92378 92378 75582 50388 27132 11628 3876 969 171 19 1
20 1 20 190 1140 4845 15504 38760 77520 1E+05 2E+05 2E+05 2E+05 1E+05 77520 38760 15504 4845 1140 190 20 1
No Letter appers

Calculation Table
n !/P/C r value

=
=
=
=
=
=

Total 0
Pascal's Triangle

0 1 1
1 1 1 2
2 1 2 1 4
3 1 3 3 1 8
4 1 4 6 4 1 16
5 1 5 10 10 5 1 32
6 1 6 15 20 15 6 1 64
7 1 7 21 35 35 21 7 1 128
8 1 8 28
56 70 56 28 8 1 256
9 1 9 36 84 126 126 84 36 9 1 512
10 1 10 45 120 210 252 210 120 45 10 1 1024
11 1 11 55 165 330 462 462 330 165 55 11 1 2048
12 1 12 66 220 495 792 924 792 495 220 66 12 1 4096
13 1 13 78 286 715 1287 1716 1716 1287 715 286 78 13 1 8192
14 1 14 91 364 1001 2002 3003 3432 3003 2002 1001 364 91 14 1 16384
15 1 15 105 455 1365 3003 5005 6435 6435 5005 3003 1365 455 105 15 1 32768
16 1 16 120 560 1820 4368 8008 ### ### ### 8008 4368 1820 560 120 16 1 65536
Permutations
1 : '----------------------------------------------------------------
2 : ' Permutations of Letters
3 : '
4 : ' The essence of JK for Excel VBA
5 : ' English Edition
6 : ' YOSHIDA Hajime
7 : ' Aug. 23, 2001
8 : '----------------------------------------------------------------
9 : Option Explicit
10 : Public cnt As Integer
11 :
12 : Private Sub CommandButton1_Click()
13 : '
14 : Dim InputStr As String
15 : Dim OutputStr As String
16 :
17 : cnt = 0
18 : OutputStr = ""
19 : Sheet11.Columns(1).ClearContents
20 : InputStr = InputBox("Input Letters")
21 : PermSmpl OutputStr, InputStr
22 : MsgBox cnt & " way(s)."
23 : End Sub
24 :
25 : Private Sub PermSmpl(OutNowStr As String, InNowStr As String)
26 : '
27 : Dim k As Integer 'length of the input letters
28 : Dim i As Integer
29 : Dim OutNextStr As String
30 : Dim InNextStr As String
31 :
32 : If InNowStr = "" Then
33 : cnt = cnt + 1
34 : Sheet11.Cells(cnt, 1).Value = OutNowStr
35 :
36 : Else
37 : k = Len(InNowStr)
38 : For i = 1 To k
39 : OutNextStr = OutNowStr & Mid(InNowStr, i, 1)
40 : InNextStr = Mid(InNowStr, 1, i - 1) & Mid(InNowStr, i + 1, k -
41 : PermSmpl OutNextStr, InNextStr
42 : Next i
43 : End If
44 : End Sub
45 :
46 : Next i
47 : End If
48 : End Sub

-11-
---------

---------

ring)

, i + 1, k - i)

-11-

You might also like