File tree Expand file tree Collapse file tree 4 files changed +54
-1
lines changed Expand file tree Collapse file tree 4 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 1+ Module Anagrams
2+ Sub GeneratePermutations( ByVal a As Char (), ByVal n as Integer )
3+ If (n <= 0 ) Then
4+ Console.WriteLine( new String (a))
5+ Else
6+ For i = 0 To n - 1
7+ GeneratePermutations(a, n - 1 )
8+ Dim j as Integer = If (n MOD 2 = 0 , 0 , i)
9+ Dim temp as Char = a(j)
10+ a(j) = a(n)
11+ a(n) = temp
12+ Next
13+ GeneratePermutations(a, n - 1 )
14+ End If
15+ End Sub
16+
17+ Sub Main(args As String ())
18+ If (args.Length <> 1 ) Then
19+ Throw New System.Exception( "ERROR: There must be exactly 1 argument." )
20+ End If
21+ Dim letters as Char () = args( 0 ).ToCharArray()
22+ GeneratePermutations(letters, letters.Length - 1 )
23+ End Sub
24+ End Module
Original file line number Diff line number Diff line change 1- Module Clockhands
1+ Module Hello
22 Sub Main()
33 Console.WriteLine( "Hello, World!" )
44 End Sub
Original file line number Diff line number Diff line change 1+ Module Permutations
2+ Sub PrintPermutations( ByVal a As String (), ByVal n as Integer )
3+ If (n <= 0 ) Then
4+ Console.WriteLine( String .Join(vbTab, a))
5+ Else
6+ For i = 0 To n - 1
7+ PrintPermutations(a, n - 1 )
8+ Dim j as Integer = If (n MOD 2 = 0 , 0 , i)
9+ Dim temp as String = a(j)
10+ a(j) = a(n)
11+ a(n) = temp
12+ Next
13+ PrintPermutations(a, n - 1 )
14+ End If
15+ End Sub
16+
17+ Sub Main(args As String ())
18+ If (args.Length < 1 ) Then
19+ Throw New System.Exception( "ERROR: There must be at least 1 argument." )
20+ End If
21+ PrintPermutations(args, args.Length - 1 )
22+ End Sub
23+ End Module
Original file line number Diff line number Diff line change @@ -20,10 +20,16 @@ function Initialize-File {
2020$project = " $PSScriptRoot \project"
2121
2222$Error.clear ()
23+ Initialize-File (" Anagrams.vb" ) && dotnet run -- project $project rats |
24+ Compare-Object (Get-Content " $PSScriptRoot \..\test\rats_heap_expected" ) |
25+ Assert-MatchTests &&
2326 Initialize-File (" Clockhands.vb" ) && dotnet run -- project $project |
2427 Compare-Object (Get-Content " $PSScriptRoot \..\test\clockhands_expected" ) |
2528 Assert-MatchTests &&
2629 Initialize-File (" Hello.vb" ) && dotnet run -- project $project &&
30+ Initialize-File (" Permutations.vb" ) && dotnet run -- project $project I like carrots |
31+ Compare-Object (Get-Content " $PSScriptRoot \..\test\carrots_expected" ) |
32+ Assert-MatchTests &&
2733 Initialize-File (" Triple.vb" ) && dotnet run -- project $project |
2834 Compare-Object (Get-Content " $PSScriptRoot \..\test\triple_expected" ) |
2935 Assert-MatchTests &&
You can’t perform that action at this time.
0 commit comments