Imports System.Collections.Generic
Imports System.Linq
Public Class LINQPermutation
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dtTemp As New DataTable()
dtTemp.Columns.Add("StringNum", GetType(String))
dtTemp.Columns.Add("ListNo", GetType(Integer))
dtTemp.Rows.Add(New Object() {"001", 0})
dtTemp.Rows.Add(New Object() {"002", 1})
dtTemp.Rows.Add(New Object() {"003", 2})
dtTemp.Rows.Add(New Object() {"004", 3})
dtTemp.Rows.Add(New Object() {"005", 4})
dtTemp.Rows.Add(New Object() {"006", 5})
dtTemp.Rows.Add(New Object() {"007", 6})
dtTemp.Rows.Add(New Object() {"008", 7})
dtTemp.Rows.Add(New Object() {"009", 8})
dtTemp.Rows.Add(New Object() {"010", 9})
Dim xxx = dtTemp.Rows(0).Field(Of Integer)("ListNo")
Dim xxxx = Convert.ToInt32((System.Math.Floor(((xxx + 1) / 2) - 1) Mod 2) + 1)
Dim query0 = From a In dtTemp Where a.Field(Of Integer)("ListNo") Mod 3 = 0
Join b In dtTemp
On a.Item("ListNo") Equals b.Item("ListNo") Where a.Item("ListNo") Mod 3 = 1
Dim query1 = From a In dtTemp
Where a.Field(Of Integer)("ListNo") Mod 3 = 0
From b In dtTemp
Where b.Field(Of Integer)("ListNo") Mod 3 = 1
From c In dtTemp
Where c.Field(Of Integer)("ListNo") Mod 3 = 2
Dim xyz = query1.Distinct
Dim query2 = From a In dtTemp
Where a.Item("ListNo") Mod 3 = 1
Dim query3 = From a In dtTemp
Where a.Item("ListNo") Mod 3 = 2
Dim query = From a In query1
From b In query2
From c In query3
'Where x.Item("ListNo") Mod 2 = 1
' From b In dtTemp
' Where (System.Math.Floor(((b.Field(Of Integer)("ListNo") + 1) / 2) - 1) Mod 2) + 1 = 2
Dim querz = From a In dtTemp.AsEnumerable
Where (System.Math.Floor(((a.Item("ListNo") + 2) / 2) - 1) Mod 2) + 1 = 1
Dim querb = From a In dtTemp.AsEnumerable
Where ((((a.Item("ListNo") + 2) / 2) - 1) Mod 2) + 1 = 1
'MsgBox("xxx " & System.Math.Floor(51 / 50) Mod 50)
'MsgBox(System.Math.Floor((49 / 50) Mod 50))
'MsgBox(System.Math.Floor((50 / 50) Mod 50))
'MsgBox(System.Math.Floor((99 / 50) Mod 50))
'MsgBox(System.Math.Floor((100 / 50) Mod 50))
'MsgBox(System.Math.Floor((249 / 50) Mod 50))
'MsgBox(((((1 - 1) / 28) + 1) - 1) Mod 13)
'Dim b = GetPermutationsXXX("987")
End Sub
Public Shared Function GetPermutationsXXX(ByVal s As String) As IEnumerable(Of String)
If s.Length > 1 Then
Return (From ch In s
From p In GetPermutationXXX(s.Remove(s.IndexOf(ch), 1))
Select String.Format("{0}{1}", ch, p))
Else
Return New String() {s}
End If
End Function
End Class