Pagina precedente | 1 | Pagina successiva
Vota | Stampa | Notifica email    
Autore

permutazioni senza ripetizione ma solo di un elemento

Ultimo Aggiornamento: 18/05/2018 22:22
Post: 150
Registrato il: 04/11/2016
Città: SASSARI
Età: 48
Utente Junior
2010
OFFLINE
17/05/2018 11:04

Salve a tutti ,

come posso visualizza tutte le combinazioni di (n k senza ripetizione)ma solo di un elemento?

ess:

ho 10 lettere da (A a J) vorrei combinare tutte le sestine ma solo con la lette (A)

abcdef abcdeg abcdeh abcdei abcdej abcdfg abcdfh abcdfi abcdfj abcdgh abcdgi abcdgj abcdhi abcdhj abcdij abcefg abcefh abcefi abcefj abcegh abcegi abcegj abcehi abcehj abceij abcfgh abcfgi abcfgj abcfhi abcfhj abcfij abcghi abcghj abcgij abchij abdefg abdefh abdefi abdefj abdegh abdegi abdegj abdehi abdehj abdeij abdfgh abdfgi abdfgj abdfhi abdfhj abdfij abdghi abdghj abdgij abdhij abefgh abefgi abefgj abefhi abefhj abefij abeghi abeghj abegij abehij abfghi abfghj abfgij abfhij abghij acdefg acdefh acdefi acdefj acdegh acdegi acdegj acdehi acdehj acdeij acdfgh acdfgi acdfgj acdfhi acdfhj acdfij acdghi acdghj acdgij acdhij acefgh acefgi acefgj acefhi acefhj acefij aceghi aceghj acegij acehij acfghi acfghj acfgij acfhij acghij adefgh adefgi adefgj adefhi adefhj adefij adeghi adeghj adegij adehij adfghi adfghj adfgij adfhij adghij aefghi aefghj aefgij aefhij aeghij afghij

senza visualizzare il resto delle combo

Vortrei pero' poter sceglere la lettera ,

esempio:

se scelgo (A) (abcdef abcdeg abcdeh abcdei abcdej abcdfg abcdfh abcdfi abcdfj abcdgh abcdgi abcdgj abcdhi abcdhj abcdij abcefg abcefh abcefi abcefj abcegh abcegi abcegj abcehi abcehj abceij abcfgh abcfgi abcfgj abcfhi abcfhj abcfij abcghi abcghj abcgij abchij abdefg abdefh abdefi abdefj abdegh abdegi abdegj abdehi abdehj abdeij abdfgh abdfgi abdfgj abdfhi abdfhj abdfij abdghi abdghj abdgij abdhij abefgh abefgi abefgj abefhi abefhj abefij abeghi abeghj abegij abehij abfghi abfghj abfgij abfhij abghij acdefg acdefh acdefi acdefj acdegh acdegi acdegj acdehi acdehj acdeij acdfgh acdfgi acdfgj acdfhi acdfhj acdfij acdghi acdghj acdgij acdhij acefgh acefgi acefgj acefhi acefhj acefij aceghi aceghj acegij acehij acfghi acfghj acfgij acfhij acghij adefgh adefgi adefgj adefhi adefhj adefij adeghi adeghj adegij adehij adfghi adfghj adfgij adfhij adghij aefghi aefghj aefgij aefhij aeghij afghij)

se scelgo (C) (cdefgh cdefgi cdefgj cdefhi cdefhj cdefij cdeghi cdeghj cdegij cdehij cdfghi cdfghj cdfgij cdfhij cdghij cefghi cefghj cefgij cefhij ceghij cfghij)

e cosi via

spero di essermi spiegato bene
grazie


[Modificato da ema.cab 17/05/2018 11:35]
Post: 2.925
Registrato il: 03/04/2013
Utente Veteran
Excel 2000 - 2013
OFFLINE
17/05/2018 15:51

Buon pomeriggio, ema.cab;
senza un File di riferimento, per me, è veramente difficile proporti una possibile soluzione.

Potrei pensare ad un Codice VBA di poche righe basato suula Funzione "Left", ma, ripeto, senza un File non sono in grado di condurre i miei Test.




Giuseppe

Windows XP - Excel 2000
Windows 10 - Excel 2013
Post: 3.474
Registrato il: 28/06/2011
Città: AGORDO
Età: 70
Utente Master
2013
OFFLINE
17/05/2018 16:44

Ciao a tutti
Celle A1:A10 inserisci i caratteri
vb
Sub stringa()
Dim b, c, d, e, f, Rr
Rr = 1
For b = 2 To 6
    For c = b + 1 To 7
        For d = c + 1 To 8
            For e = d + 1 To 9
                For f = e + 1 To 10
Cells(Rr, 2) = Cells(1, 1) & Cells(b, 1) & Cells(c, 1) & Cells(d, 1) & Cells(e, 1) & Cells(f, 1)
Rr = Rr + 1
                Next
            Next
        Next
    Next
Next
End Sub
Excel 2013
Post: 565
Registrato il: 24/06/2015
Città: CATANIA
Età: 80
Utente Senior
Excel2019
OFFLINE
18/05/2018 22:22

Ciao
Credo che quello che chiedi lo fa la macro seguente ma con alcune precisazioni:
cella scrivi
in C1 lettere
in C2 classe
in C3 lett.scelta
in C4 elenco combinazioni che includono la lettera scelta
intervallo D1:M1 le lettere da combinare.

Importante:
in D2 il numero di "sestine" (come le chiami tu ma puoi indicare un numero compreso tra 2 e 10)
in D3 la lettera da te scelta.

Option Explicit

Sub ProvaComb()
Dim nElem As Integer, nClas As Integer, sLett As String, DimGroup As Integer
Dim i As Long, CombS, r As Long, testo As String, flag As Integer, x As Integer
Dim arrayElementi() As Variant, cn As Long

  nClas = Range("D2").Value
  sLett = Range("D3").Value
  For i = 0 To Cells(1, Columns.Count).End(xlToLeft).Column - 1
    If IsEmpty(Cells(1, i + 4)) Then Exit For
    ReDim Preserve arrayElementi(0 To i)
    arrayElementi(i) = Cells(1, i + 4).Value
    nElem = nElem + 1
  Next i
  Range("D5:M100000").ClearContents
  If nElem = 0 Or nClas = 0 Or nClas > nElem Then Exit Sub
  DimGroup = nClas
  Dim LC As New Collection
  If UBound(arrayElementi) = 0 Then
    Set CombS = LC
  End If
  If DimGroup = 0 Or DimGroup > UBound(arrayElementi) Then
    Set CombS = LC
  End If
  Dim aP() As Integer
  ReDim aP(DimGroup - 1)
  Dim k As Integer
  For k = 0 To UBound(aP)
    aP(k) = k
  Next k
  Dim j As Integer
  Dim c As String
  Dim cnt As Integer
  Do
    c = ""
    For i = 0 To UBound(aP)
      c = c & arrayElementi(aP(i))
    Next i
    LC.Add (c)
    cnt = 0
    For i = UBound(aP) To 0 Step -1
      If aP(i) = UBound(arrayElementi) - cnt Then
        cnt = cnt + 1
        If cnt = UBound(aP) + 1 Then Exit Do
      Else
        aP(i) = aP(i) + 1
        For j = 0 To UBound(aP)
          If i < j Then aP(j) = aP(i) + (j - i)
        Next
        Exit For
      End If
    Next i
  Loop
  Set CombS = LC
  r = 4
  For i = 1 To LC.Count
    testo = LC(i)
    flag = 0
    For x = 1 To Len(testo)
      If Mid(testo, x, 1) = sLett Then flag = 1
    Next x
    If flag = 1 Then
      cn = 4
      r = r + 1
      For j = 1 To Len(testo)
        Cells(r, cn) = Mid(testo, j, 1)
        cn = cn + 1
      Next j
      testo = ""
    End If
  Next i
  Set CombS = Nothing
  Cells(1, 1).Select
End Sub


E' un po' lunga ma fa il suo dovere.
Fai sapere. Ciao,
Mario
Vota:
Amministra Discussione: | Chiudi | Sposta | Cancella | Modifica | Notifica email Pagina precedente | 1 | Pagina successiva
Nuova Discussione
 | 
Rispondi
Cerca nel forum
Tag discussione
Discussioni Simili   [vedi tutte]
Feed | Forum | Bacheca | Album | Utenti | Cerca | Login | Registrati | Amministra
Tutti gli orari sono GMT+01:00. Adesso sono le 16:13. Versione: Stampabile | Mobile | Regolamento | Privacy
FreeForumZone [v.6.1] - Copyright © 2000-2024 FFZ srl - www.freeforumzone.com