Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion exercises/practice/change/.meta/Example.vb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Public Module Change
fewestCoins(0) = Array.Empty(Of Integer)()

For amount = 1 To target
Dim change As IEnumerable(Of Integer) = coins.Where(Function(coin) coin <= amount).[Select](Function(coin) fewestCoins(amount - coin).Append(coin)).OrderBy(Function(x) x.Count()).FirstOrDefault(Function(y) y.Sum() = amount)
Dim currentAmount = amount
Dim change As IEnumerable(Of Integer) = coins.Where(Function(coin) coin <= currentAmount).[Select](Function(coin) fewestCoins(currentAmount - coin).Append(coin)).OrderBy(Function(x) x.Count()).FirstOrDefault(Function(y) y.Sum() = currentAmount)

If change Is Nothing Then
fewestCoins(amount) = New List(Of Integer)().ToArray()
Expand Down
10 changes: 1 addition & 9 deletions exercises/practice/circular-buffer/.meta/Example.vb
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ Public Class CircularBuffer(Of T)
End Sub

Private Sub DequeueHead()
CSharpImpl.__Assign(items, items.Skip(1).ToList())
items = items.Skip(1).ToList()
End Sub

Private Class CSharpImpl
<Obsolete("Please refactor calling code to use normal Visual Basic assignment")>
Shared Function __Assign(Of T)(ByRef target As T, value As T) As T
target = value
Return value
End Function
End Class
End Class
11 changes: 2 additions & 9 deletions exercises/practice/list-ops/.meta/Example.vb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Public Module ListOps
Dim sublist As List(Of T) = Nothing

For Each list In input
If CSharpImpl.__Assign(sublist, TryCast(list, List(Of T))) IsNot Nothing Then concatenated = Append(concatenated, sublist)
sublist = TryCast(list, List(Of T))
If sublist IsNot Nothing Then concatenated = Append(concatenated, sublist)
Next


Expand All @@ -67,12 +68,4 @@ Public Module ListOps

Return appended.ToList()
End Function

Private Class CSharpImpl
<Obsolete("Please refactor calling code to use normal Visual Basic assignment")>
Shared Function __Assign(Of T)(ByRef target As T, value As T) As T
target = value
Return value
End Function
End Class
End Module
6 changes: 4 additions & 2 deletions exercises/practice/nth-prime/.meta/Example.vb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Public Module NthPrime
Public Function Prime(ByVal number As Integer)
Public Function Prime(ByVal number As Integer) As Integer
If number < 1 Then
Throw New ArgumentOutOfRangeException(nameof(number), "There are no negative nth primes")
End If
Expand All @@ -16,9 +16,11 @@ Public Module NthPrime
End If
candidate += 1
End While

Throw New InvalidOperationException("unreachable")
End Function

Private Function IsPrime(ByVal num As Integer)
Private Function IsPrime(ByVal num As Integer) As Boolean
If num <= 1 Then
Return False
End If
Expand Down
19 changes: 10 additions & 9 deletions exercises/practice/ocr-numbers/.meta/Example.vb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,19 @@ Public Module OcrNumbers
End Function

Private Function Cols(ByVal lines As String()) As Integer
Return If(lines(0).Length Mod CharacterWidth = 0, lines(0).Length / CharacterWidth, CSharpImpl.__Throw(Of Integer)(New ArgumentException()))
If lines(0).Length Mod CharacterWidth <> 0 Then
Throw New ArgumentException()
End If

Return lines(0).Length / CharacterWidth
End Function

Private Function Rows(ByVal lines As String()) As Integer
Return If(lines.Length Mod CharacterHeight = 0, lines.Length / CharacterHeight, CSharpImpl.__Throw(Of Integer)(New ArgumentException()))
If lines.Length Mod CharacterHeight <> 0 Then
Throw New ArgumentException()
End If

Return lines.Length / CharacterHeight
End Function

Private Function IsEmptyLine(ByVal line As String) As Boolean
Expand Down Expand Up @@ -82,11 +90,4 @@ Public Module OcrNumbers
{" _ " & "|_|" & " _|" & " ", "9"c},
{" " & " " & " ," & " ", ","c}
}

Private Class CSharpImpl
<Obsolete("Please refactor calling code to use normal throw statements")>
Shared Function __Throw(Of T)(ByVal e As Exception) As T
Throw e
End Function
End Class
End Module
Loading