jhylands

an attempt at automating D1 in 20 mins

Mar 7th, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.74 KB | None | 0 0
  1. Module Module1
  2.  
  3.     Sub Main()
  4.         Console.WriteLine("Please enter your list seperated by commars: e.g 12,4,3,")
  5.         Dim strInput As String
  6.         strInput = Console.ReadLine()
  7.         Dim listOfNumbers() As String
  8.         listOfNumbers = Split(strInput, ",")
  9.         Console.WriteLine("Would you to sort, search or pack the list?")
  10.         Select Case Console.ReadLine
  11.             Case 1
  12.  
  13.         End Select
  14.     End Sub
  15.     Function binarySearch(needle, haystack)
  16.         Dim found As Boolean = False
  17.         Dim n As Integer = haystack.getlength(0)
  18.         Do Until found
  19.         Loop
  20.     End Function
  21.     Function bubbleSort(ByVal list)
  22.         Dim change As Boolean = True
  23.         While change = True
  24.             change = False
  25.             For i As Integer = 0 To list.getlenth(0) - 2
  26.                 If (list(i) > list(i + 1)) Then
  27.                     Dim holder As Integer
  28.                     holder = list(i)
  29.                     list(i) = list(i + 1)
  30.                     list(i + 1) = holder
  31.                     change = True
  32.                 End If
  33.  
  34.             Next
  35.         End While
  36.         Return list
  37.     End Function
  38.     Function quickSort(ByVal list)
  39.         If list.getlength(0) = 1 Then
  40.             Return list
  41.         Else
  42.             Dim pivot As Integer = list(0)
  43.             Dim lower() As Integer
  44.             Dim higher() As Integer
  45.             For i As Integer = 0 To list.getlength(0)
  46.                 If (list(i) > pivot) Then
  47.                     higher(higher.GetLength(0)) = list(i)
  48.                 Else
  49.                     lower(lower.GetLength(0)) = list(i)
  50.                 End If
  51.             Next
  52.             Return "a" 'merge lower+pivot+higher
  53.  
  54.         End If
  55.     End Function
  56.  
  57. End Module
Advertisement
Add Comment
Please, Sign In to add comment