Re: combinations of 4

From: martin f krafft (madduck@madduck.net)
Date: Sun Apr 07 2002 - 16:09:14 EDT


also sprach KF <dotslash@snosoft.com> [2002.04.07.0301 +0200]:
> I am in the process of archiving power pc instructions that do not
> contain null... I have come to the decision that if I could generate a
> list of all possible unique 4 char combinations for a given list of
> alpha numeric chars then I could quickly sort the rest out in gdb...
>
> My question is does anyone know how to programatically do this? Do i
> need to make use of bit shifting or something? I need only a program to
> print the list to the screen or something simple. Example output would
> be ...
>
> AAAA
> BBBBB
> ....
> AAAB
> AAAC
> ...
> and so on but ONLY unique posibilities.

uhm, since you are talking combinations:

  #!/bin/sh
  CHARS="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
  for q in "$CHARS"; do
    for r in "$CHARS"; do
      for s in "$CHARS"; do
        for t in "$CHARS"; do
          echo $q$r$s$t
        done
      done
    done
  done

permutations are harder. maybe i am also confusing the two. but for
permutations, the c++ standard template library provides algorithms...

and best of all, it's already sorted ;)

-- 
martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck
  
prepBut nI vrbLike adjHungarian! qWhat's artThe adjBig nProblem?
                                               -- alec flett @netscape




This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:28:03 EDT