Jump to content
Sign in to follow this  
ChrisL

Making some Strings aa, ab, ac etc

Recommended Posts

ChrisL

I want to make an array 10000 elements long

it needs to go

aa

ab

ac

ad etc etc

then

aaa

aba

aca

ada etc etc

aab

abb

acb

adb etc etc

I can't get my head around what I need to do... any ideas?

#include <Array.au3>

$alphabet = "abcdefghijklmnopqrstuvwxyz"
$aLeters = StringSplit($alphabet,"")
Local $aStrings[10001]=[0]


$iLoop = 0
$iLoopCnt = 0

For $l = 1 to 10000
    For $i = 1 to $aLeters[0]
        For $iT = 1 to $aLeters[0]
            $aStrings[0] +=1
            If $aStrings[0] > 10000 then Exitloop(3)        
            $aStrings[$aStrings[0]] = $aLeters[$i] & StringRight($aLeters[$iT],1)
        Next
        $aLeters[$i] &= StringRight($aLeters[$i],1)
    Next
Next

_ArraySort($aStrings)
_ArrayDisplay($aStrings)

Share this post


Link to post
Share on other sites
martin

I want to make an array 10000 elements long

it needs to go

aa

ab

ac

ad etc etc

then

aaa

aba

aca

ada etc etc

aab

abb

acb

adb etc etc

I can't get my head around what I need to do... any ideas?

#include <Array.au3>
    
    $alphabet = "abcdefghijklmnopqrstuvwxyz"
    $aLeters = StringSplit($alphabet,"")
    Local $aStrings[10001]=[0]
    
    
    $iLoop = 0
    $iLoopCnt = 0
    
    For $l = 1 to 10000
        For $i = 1 to $aLeters[0]
            For $iT = 1 to $aLeters[0]
                $aStrings[0] +=1
                If $aStrings[0] > 10000 then Exitloop(3)        
                $aStrings[$aStrings[0]] = $aLeters[$i] & StringRight($aLeters[$iT],1)
            Next
            $aLeters[$i] &= StringRight($aLeters[$i],1)
        Next
    Next
    
    _ArraySort($aStrings)
    _ArrayDisplay($aStrings)
Does this work?

#include <Array.au3>
  
  $alphabet = "abcdefghijklmnopqrstuvwxyz"
  $aLeters = StringSplit($alphabet,"")
  Local $aStrings[10001]
  $aStrings[0] = 0
  $iLoop = 0
  $iLoopCnt = 0
  
  For $l = 1 to 10000/25
          For $iT = 1 to $aLeters[0]
              $aStrings[0] +=1
              If $aStrings[0] > 10000 then Exitloop(2)      
              if $aStrings[0] > 26 Then
              $aStrings[$aStrings[0]] = $aStrings[($aStrings[0]-1)/26 ] & $aLeters[$iT]
          Else
              $aStrings[$aStrings[0]] =  $aLeters[$iT]
              
              EndIf
          Next
  Next
  
;_ArraySort($aStrings)
  _ArrayDisplay($aStrings)

EDIT: Sorry ChrisL, I see it doesn't, I was aiming for the wrong thing. I'll look again.

EDIT2: Maybe it is if its like this

#include <Array.au3>

$alphabet = "abcdefghijklmnopqrstuvwxyz"
$aLeters = StringSplit($alphabet,"")
Local $aStrings[10001]
$aStrings[0] = 0
$iLoop = 0
$iLoopCnt = 0

For $l = 1 to 10000/25
        For $iT = 1 to $aLeters[0]
            $aStrings[0] +=1
            If $aStrings[0] > 10000 then Exitloop(2)        
            if $aStrings[0] > 26 Then
            $aStrings[$aStrings[0]] = $aStrings[($aStrings[0]-1)/26 ] & $aLeters[$iT]
        Else
            $aStrings[$aStrings[0]] =  "a" & $aLeters[$iT]
            
            EndIf
        Next
Next

;_ArraySort($aStrings)
_ArrayDisplay($aStrings)
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
ChrisL

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.