Advertisement
Guest User

MaskSort Source

a guest
May 18th, 2022
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.66 KB | None | 0 0
  1. Imports System
  2. Imports System.IO
  3. Imports System.Net.Mime.MediaTypeNames
  4. Imports System.Text
  5.  
  6. Module Program
  7.     Sub Main(args As String())
  8.         Dim reader As New StreamReader("Masks.txt", Encoding.Default)
  9.         Dim dictionary As New Dictionary(Of String, Integer)
  10.         Dim a As String
  11.         Do
  12.             a = reader.ReadLine
  13.             If a Is Nothing Then
  14.             Else
  15.                 Try
  16.                     dictionary.Add(a, AddMask(a))
  17.                 Catch ex As Exception
  18.                 End Try
  19.  
  20.             End If
  21.  
  22.         Loop Until a Is Nothing
  23.         reader.Close()
  24.  
  25.         Dim keyList As List(Of String) = (From tPair As KeyValuePair(Of String, Integer) _
  26.                                   In dictionary Order By tPair.Value Ascending
  27.                                           Select tPair.Key).ToList
  28.         Dim FileName As String = System.AppDomain.CurrentDomain.BaseDirectory & "\Masks_New.txt"
  29.         IO.File.WriteAllLines(FileName, keyList)
  30.     End Sub
  31.     Private Function AddMask(ToAdd As String)
  32.         Dim TAD As String = ToAdd
  33.         Try
  34.             TAD = TAD.Replace("d", "2").Replace("l", "3").Replace("u", "3").Replace("s", "4")
  35.         Catch ex As Exception
  36.         End Try
  37.         Dim XX = TAD.Split("?")
  38.         Dim intList() As Integer
  39.         intList = (From str As String In XX
  40.                    Where Integer.TryParse(str, Nothing)
  41.                    Select (Integer.Parse(str))).ToArray
  42.         Dim prod As Long = intList(0)
  43.         For i As Integer = 0 To intList.Length - 1
  44.             prod *= intList(i)
  45.         Next
  46.  
  47.         Return Math.Round(prod / 1000, 2)
  48.     End Function
  49. End Module
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement