elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Curso de javascript por TickTack


  Mostrar Mensajes
Páginas: 1 ... 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [28] 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 ... 55
271  Programación / .NET (C#, VB.NET, ASP) / Re: formar combinaciones de 7 y 8 numeros con 25 numeros en: 31 Octubre 2014, 17:48 pm
Gracias Elektro , no creas que ya no resuelvo algunas cosas por mi mismo :) y eso es gracias a ti en este lenguaje, pero aprendo muy despacio jejej y ademas cambiar de  programación a esta edad me confunde mucho


Luis
272  Programación / .NET (C#, VB.NET, ASP) / Re: formar combinaciones de 7 y 8 numeros con 25 numeros en: 31 Octubre 2014, 15:58 pm

List(Of T).Sort Method - MSDN

Nota: Es un método, no una función, por lo tanto debes asignar la lista a una variable, la ordenas utilizando el método indicado, y ya puedes agregar la lista ordenada a la colección de listas.

Saludos


Probando me da este error no se si te entendi bien pero te muestro el codigo

Excepción del tipo 'System.OutOfMemoryException' en System.Core.dll





Código
  1.  
  2.          ' Do Until count = (constantValues.Count - length - skipStart)
  3.            Do Until skipStart = (constantValues.Count - length)
  4.  
  5.                combinations.Add(values.Concat(constantValues.Skip(skipStart + length + count).Take(1)).ToList)
  6.  
  7.                '  Debug.WriteLine(String.Join(", ", values.Concat(constantValues.Skip(skipStart + length + count).Take(1)).ToArray))
  8.  
  9.                count += 1
  10.  
  11.            Loop ' count = (constantValues.Count - length)
  12.  
  13.            skipStart += 1
  14.  
  15.  
  16.        Loop ' skipStart = (constantValues.Count - length)
  17.  
  18.  
  19.        combinations.ForEach(Sub(combination As List(Of Integer))
  20.                                 ListBox2.Items.Add(String.Join(", ", From value As Integer In combination
  21.                                                                      Select If(value.ToString.Length = 1I,
  22.                                                                                value.ToString.Insert(0I, "0"c),
  23.                                                                                value.ToString)))
  24.  
  25.  
  26.  
  27.                             End Sub)



Luis
273  Programación / .NET (C#, VB.NET, ASP) / Re: formar combinaciones de 7 y 8 numeros con 25 numeros en: 31 Octubre 2014, 14:56 pm
Otro rollo jeje

este codigo me entrega los numeros ordenados de menor a mayor funciona bien,pero depues de modificarlo me entrega los combinaciones desordenadas,he probado con ordenar la variable y el listbox pero no se que mas ,

Código
  1. codigo original
  2.  
  3. Public Class Form1
  4.    Dim combinations As Integer
  5.    Dim seta As Integer
  6.  
  7.    ReadOnly constantValues As New List(Of Integer) From
  8.        {
  9.            2, 3, 5I, 6I, 7I, 8I, 9I,
  10. 11, 13, 14, 17, 18, 19,
  11. 20, 21, 24, 25, 26, 29,
  12. 30, 31, 33, 44, 48
  13.        }
  14.  
  15.    Private Shadows Sub Load() Handles MyBase.Load
  16.  
  17.        Dim combinations As New List(Of List(Of Integer))
  18.        Dim length As Integer = 9
  19.        Dim skipStart As Integer = 0
  20.  
  21.        Do Until skipStart = (constantValues.Count - length)
  22.  
  23.            Dim values As List(Of Integer) = constantValues.GetRange(skipStart, length)
  24.            Dim count As Integer = 0
  25.  
  26.            Do Until count = (constantValues.Count - length - skipStart)
  27.  
  28.                combinations.Add(values.Concat(constantValues.Skip(skipStart + length + count).Take(1)).ToList)
  29.  
  30.                Debug.WriteLine(String.Join(", ", values.Concat(constantValues.Skip(skipStart + length + count).Take(1)).ToArray))
  31.  
  32.                count += 1
  33.  
  34.            Loop ' count = (constantValues.Count - length)
  35.  
  36.            skipStart += 1
  37.  
  38.        Loop ' skipStart = (constantValues.Count - length)
  39.        combinations.ForEach(Sub(combination As List(Of Integer))
  40.                                 ListBox1.Items.Add(String.Join(", ", From value As Integer In combination
  41.                                                                      Select If(value.ToString.Length = 1I,
  42.                                                                                value.ToString.Insert(0I, "0"c),
  43.                                                                                value.ToString)))
  44.                             End Sub)
  45.  
  46.  
  47.  
  48.    End Sub
  49.  



ahora como he modificado la variable " constantValues "  por constantValues.AddRange(Resultss.ToArray()) para usar
los numeros de " resultss " y estos numeros cambian no son fijos


Código
  1. codigo modificado
  2.  
  3. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  4.  
  5.  
  6.        Dim combinations As New List(Of List(Of Integer))
  7.        Dim length As Integer = 9
  8.        Dim skipStart As Integer = 0
  9.  
  10.  
  11.        Do Until skipStart = (constantValues.Count - length)
  12.  
  13.            Dim values As List(Of Integer) = constantValues.GetRange(skipStart, length)
  14.            Dim count As Integer = 0
  15.  
  16.            Do Until count = (constantValues.Count - length - skipStart)
  17.  
  18.                combinations.Add(values.Concat(constantValues.Skip(skipStart + length + count).Take(1)).ToList)
  19.  
  20.                '  Debug.WriteLine(String.Join(", ", values.Concat(constantValues.Skip(skipStart + length + count).Take(1)).ToArray))
  21.  
  22.                count += 1
  23.  
  24.            Loop ' count = (constantValues.Count - length)
  25.  
  26.            skipStart += 1
  27.  
  28.  
  29.        Loop ' skipStart = (constantValues.Count - length)
  30.  
  31.  
  32.        combinations.ForEach(Sub(combination As List(Of Integer))
  33.                                 ListBox2.Items.Add(String.Join(", ", From value As Integer In combination
  34.                                                                      Select If(value.ToString.Length = 1I,
  35.                                                                                value.ToString.Insert(0I, "0"c),
  36.                                                                                value.ToString)))
  37.  
  38.  
  39.  
  40.                             End Sub)
  41.  
  42.  
  43. y me entrega las combinaciones desordenadas de esta forma
  44.  
  45.  
  46. 03, 05, 12, 13, 30, 08, 27, 28, 14, 26
  47. 03, 05, 12, 13, 30, 08, 27, 28, 14, 31
  48. 03, 05, 12, 13, 30, 08, 27, 28, 14, 32
  49. 03, 05, 12, 13, 30, 08, 27, 28, 14, 11
  50. 03, 05, 12, 13, 30, 08, 27, 28, 14, 17
  51. 03, 05, 12, 13, 30, 08, 27, 28, 14, 33
  52. 03, 05, 12, 13, 30, 08, 27, 28, 14, 37
  53. 03, 05, 12, 13, 30, 08, 27, 28, 14, 38
  54.  
  55.  
  56.  
  57.  


Luis




274  Programación / .NET (C#, VB.NET, ASP) / Re: formar combinaciones de 7 y 8 numeros con 25 numeros en: 28 Octubre 2014, 18:29 pm
Buaaaaaaaaaa


luis
275  Programación / .NET (C#, VB.NET, ASP) / Re: formar combinaciones de 7 y 8 numeros con 25 numeros en: 28 Octubre 2014, 10:25 am

Tu tienes esto:
Código:
Lista
    · Sub-Lista
       · {2, 9}
    · Sub-Lista
       · {10, 15}

Y lo que quieres conseguir es esto (aparentemente, ya que no está muy claro lo que has dicho) :
Código:
Lista
    · {2, 9, 10, 15}


¿Qué tienes que hacer?, unir las sub-listas en una sola lista.

¿Cómo hacerlo?, puedes hacerlo con el método que te mostré, JoinEnumerables, el cual desarrollé para que realizase esa tarea en específico.


Saludos!


Hola asta ahora no he podido ver nada ( catarrazooo)  me podrias enseñar algun ejemplo con mayores detalles :)

luis

276  Programación / .NET (C#, VB.NET, ASP) / Re: formar combinaciones de 7 y 8 numeros con 25 numeros en: 24 Octubre 2014, 19:45 pm
jejej de nuevo al ataque

ahora funciona y ya he probado a modificar algunas cosillas como por ejemplo el orden en

Código
  1.  .First = items(0),
  2. .Second = items(2)

lo que no entiendo es como hacer que en ves de dos,me muestre combinaciones de mas de dos números por ejemplo  " 02 09 10 15 " , ahora solo me saca en la ventana " 02 09 " y en otra  " 10 15 " y en otra  "21 28 "  etc. en una sola ventana,
277  Programación / .NET (C#, VB.NET, ASP) / Re: formar combinaciones de 7 y 8 numeros con 25 numeros en: 24 Octubre 2014, 19:20 pm

1) Por cierto, no quiero ver marranadas, ya me estás separando 'Luislibrary' de la Class 'Form1', crea un archivo de Class individual en el projecto y ahí copias y pegas el namespace 'LuisLibrary' y vas añadiendo tus distintas "utilidades" para usarlas en el futuro.


estoy en pruebas ya me haré mi archivo de rutinas :)

Saludos.
278  Programación / .NET (C#, VB.NET, ASP) / Re: formar combinaciones de 7 y 8 numeros con 25 numeros en: 24 Octubre 2014, 14:59 pm
Me voy a suicidar :(


Un valor de tipo 'System.Collections.Generic.List(Of WindowsApplication1.LuisLibrary.Group)' no se puede convertir en 'System.Collections.Generic.List(Of System.Text.RegularExpressions.Group)'.

Un valor de tipo 'System.Text.RegularExpressions.Group' no se puede convertir en 'WindowsApplication1.LuisLibrary.Group'.




Código
  1. Imports System.Text.RegularExpressions
  2. Namespace LuisLibrary
  3.  
  4.    Friend NotInheritable Class Group
  5.  
  6.        Protected Friend Property First As Integer = 0I
  7.        Protected Friend Property Second As Integer = 0I
  8.  
  9.    End Class
  10.  
  11. End Namespace
  12. Public Class Form1
  13.  
  14.    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  15.        Dim values As New List(Of Integer) From
  16.    {
  17.        2, 8, 9, 10, 11, 15, 21, 22, 28, 50, 55, 58
  18.    }
  19.  
  20.        Dim groupedValues As List(Of Group) =
  21.            (From i As Integer In values
  22.            Group By i.ToString("00").First
  23.            Into items = Group Select New LuisLibrary.Group With {
  24.                .First = items(0),
  25.                .Second = items(1)
  26.            }).ToList
  27.  
  28.        For Each g As LuisLibrary.Group In groupedValues
  29.  
  30.            Dim str As String = String.Format("{0:00}, {1:00}",
  31.                                              g.First,
  32.                                              g.Second)
  33.  
  34.            MessageBox.Show(str)
  35.  
  36.        Next g
  37.    End Sub
  38. End Class
  39.  

 
279  Programación / .NET (C#, VB.NET, ASP) / Re: formar combinaciones de 7 y 8 numeros con 25 numeros en: 24 Octubre 2014, 14:25 pm
me explicas este error ? cada dia hay algo jejeje ,estoy probando este codigo y me dice:

" El tipo 'LuisLibrary.Group' no está definido "

Código
  1. Imports System.Text.RegularExpressions
  2.  
  3. Public Class Form1
  4.  
  5.    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6.        Dim values As New List(Of Integer) From
  7.    {
  8.        2, 8, 9, 10, 11, 15, 21, 22, 28, 50, 55, 58
  9.    }
  10.  
  11.        Dim groupedValues As List(Of Group) =
  12.            (From i As Integer In values
  13.            Group By i.ToString("00").First
  14.            Into items = Group Select New LuisLibrary.Group With {
  15.                .First = items(0),
  16.                .Second = items(1)
  17.            }).ToList
  18.  
  19.        For Each g As LuisLibrary.Group In groupedValues
  20.  
  21.            Dim str As String = String.Format("{0:00}, {1:00}",
  22.                                              g.First,
  23.                                              g.Second)
  24.  
  25.            MessageBox.Show(str)
  26.  
  27.        Next g
  28.    End Sub
  29. End Class
  30.  
280  Programación / .NET (C#, VB.NET, ASP) / Re: formar combinaciones de 7 y 8 numeros con 25 numeros en: 23 Octubre 2014, 19:08 pm
Luis, estoy muy harto de verte cometer el mismo fallo en el mismo punto crítico después de habertelo explicado y resuelto decenas de veces ya :-/

¿Por qué no practicas un poco todo lo referente a colecciones genéricas y LINQ?.

Código
  1.    ' Join Enumerables
  2.    ' ( By Elektro )
  3.    '
  4.    ' Examples :
  5.    '
  6.    ' Dim listA As New List(Of String) From {"a", "b"}
  7.    ' Dim listB As New List(Of String) From {"c", "d"}
  8.    ' Dim newlist As List(Of String) = JoinEnumerables(Of String)({listA, listB}).ToList ' Result: {"a", "b", "c", "d"}
  9.  
  10.    ''' <summary>
  11.    ''' Joins the specified <see cref="IEnumerable"/> colecctions into a single <see cref="IEnumerable"/>.
  12.    ''' </summary>
  13.    ''' <typeparam name="T"></typeparam>
  14.    ''' <param name="enumerables">The <see cref="IEnumerable"/> collections to join.</param>
  15.    ''' <returns>IEnumerable(Of T).</returns>
  16.    Friend Function JoinEnumerables(Of T)(ByVal enumerables As IEnumerable(Of T)()) As IEnumerable(Of T)
  17.  
  18.        Return enumerables.SelectMany(Function(enumerable As IEnumerable(Of T)) enumerable)
  19.  
  20.    End Function

Código
  1.        Dim joinedGroups As List(Of Integer) =
  2.            JoinEnumerables(Of Integer)(
  3.                           (From group As List(Of Integer) In groupedValues
  4.                            Select group).ToArray
  5.            ).ToList
  6.  
  7.        ListBox1.Items.Add(String.Join(", ", joinedGroups))
  8.  

Espero que eso te ayude a entender un poco más, aunque se que por el momento no vas a entender el parámetro de Type (T), pero bueno xD.

Saludos


Como ya sabes voy a pasos, si me dices que hace cada cosa lo entendería mejor :) ya que tengo que ir a preguntar por todo jejej y lo que hago es enredarme mas

luis




Páginas: 1 ... 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [28] 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 ... 55
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines