Generating a set of chars

I had a bad migraine yesterday and am still feeling pretty beat up, so I can't wrap my head around this simple problem. I need to generate all possible char[] of length x, where each char[ i ] can equal 1, x, y, or z. I then need to do something to this char[]. Ex:static final char AI = '1';
static final char AX = 'x';
static final char AY = 'y';
static final char AZ = 'z';
static final char[] A = { AI, AX, AY, AZ };
public void driver(int x) {
  char[] k = new char[x];
  do {
    // generate a char[]
    // ex for x = 4: 1111
    process(k);
    // the next k would then equal 111x, then 111y, etc.....
  } while(somethingIsTrue); // or somesuch.  just using do loop for example
public void process(char[] k) {
  // do something
}Thanks in advance,
m

Never mind. I figured it out.
m

Similar Messages

  • Strings generator from a set of chars

    Hi everybody,
    I need a strings generator that given a set of chars (i.e. S = {a, b, c}) and a variable k = n , gives in output all possible strings whose lenght is 1, 2, 3, until n.
    i. e. S = {a, b , c} ; k = 10
    s1 = a
    s2 = b
    s3 = c
    s4= aa
    s5= ab
    s6 = ac
    ... and so on!
    Bye!
    JAGO

    public class PermGen {
         public static void main(String[] args) {
              String[] s = new String[] { "a", "b", "c", "d" };
              int n = 5;
              for (int i = 1; i < n; i++) {
                   int[] c = new int;
                   print(c, s.length - 1, s);
         public static void print(int[] c, int n, String[] s) {
              if (c.length == 0) return;
              while (true) {
                   for (int j = 0; j < c.length; j++)
                        System.out.print(s[c[j]] + " ");
                   System.out.println();
                   int i = 0;
                   for (; i < c.length; i++)
                        if (c[i] < n) break;
                   if (i == c.length) break;
                   i = c.length - 1;
                   while (true) {
                        if (c[i] == n) {
                             c[i] = 0;
                             i--;
                        else {
                             c[i]++;
                             break;

  • How to generate a set of date type records

    How to generate a set of date-type records, with a fixed interval, starting from a date like 2008-01-01.

    Some thing like this
    SQL> select to_char(to_date('2008-01-01','yyyy-mm-dd') + (level - 1),'DD-MON-YYYY') my_date
      2    from dual
      3  connect by level <= 10
      4  /
    MY_DATE
    01-JAN-2008
    02-JAN-2008
    03-JAN-2008
    04-JAN-2008
    05-JAN-2008
    06-JAN-2008
    07-JAN-2008
    08-JAN-2008
    09-JAN-2008
    10-JAN-2008
    10 rows selected.

  • How can we generate result set report?

    how can we generate result set report ?means the out put of one query be the input of another query?how it is?

    Hi
    You have to use APD ( analysis process designer) to use results of one query as the input for the other queries.
    Check this link
    http://help.sap.com/saphelp_nw70/helpdata/en/49/7e960481916448b20134d471d36a6b/frameset.htm
    Regards

  • Can PowerShell allow the key F9 to generate a set of characters anytime it is pressed ?

    can a PowerShell scriot be installed that allows the key F9 to generate a set of characters anytime it is pressed ?

    Hi Larry,
    Do you mean it will display a set of characters in powershell form when the key F9 is pressed?
    To create shorcut keys in powershell, and execute pre-existing operation when press the shortcut key, this module may be helpful for you:
    http://pseventing.codeplex.com/releases/view/66587
    And the samples below is for your reference:
    import-module pseventingplus
    # kill all jobs
    register-hotkeyevent "ctrl+shift+j" -action { get-job | stop-job -verbose }
    Refer to:
    Use CTRL + D to exit and CTRL + L to cls in Powershell console
    If there is anything else regarding this issue, please feel free to post back.
    If you have any feedback on our support, please
    click here.
    Best Regards,
    Anna Wang
    TechNet Community Support

  • JAXB is not generating the setter method for my tag

    Hi,
    I am generating java classes form my .xsd file using JAXB.
    The xsd definition has defnes a Form as a sequence of FormElement, where FormElement is a choice of graphical components like text etc. Form can have 0 or unbounded elements of typeFormElement
    Example
    <xs:element ref="sswfm:FormElement" minOccurs="0" maxOccurs="unbounded"/>
    It is creating the getter method for this tag like this-
    java.util.List getFormElement();
    but does not create setter method, namely, setFormElements which I would like to use when marshalling from swing to XML.
    If i remove the maxOccurs="unbounded, it is creating the setter method for this tag.But i want to keep this tag as it it and needs the setter method also.
    What should i do? Has one tried this before. HELP if you can
    Thank you in advance.

    Hi RavindraKshirsagar,
    We have a problem like you faced. Our requirement is that, we need to generate dynamically the PERSON element in our javabean.
    <xs:element name='SERVICE_REQUESTER'>
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref='ORGANIZATION' />
                        <xs:element ref='PERSON' maxOccurs='unbounded' />
                   </xs:sequence>
              </xs:complexType>
         </xs:element>For this maxOccurs, as JAXB is not generating any Setter Method. As we need to get data dynamically from external application. If you could help us in handling this case dynamically, it will be well and good.
    Please send us the script / code asap.

  • Creating new String using only specific set of chars from another String

    I've performance troubles doing this task:
    I have a very long String A (up to 1 million character length)
    This String contains different characters.
    I need to create a String B containing only specific characthers (with a defined character code)
    An example:
    String A: [80]='P' [65]='A' [71]='G' [69]='E'For example I want to extract only character 65 and 71
    String B: [65]='A' [71]='G'I already did the code to do this, (it's quite simple) but I think I have some very big performance issues, and I suppose I can do this task much more quickly!!
    String out = "";
              for (counter = 0; counter < text.length(); counter++) {
                   char currentchar = text.charAt(counter);
                   int currentvalue = (new Integer(currentchar)).intValue();
                   switch (currentvalue) {
                   case 65:
                        char[] newstring = new char[1];
                        newstring[0] = currentchar;
                        out += new String(newstring);
                        break;
                   case 71: //
                        break;
                   // other cases
                   default:
                        // nothing to do...
              }Can you suggest me something to improve the performances?
    Thank you!

    If you've got a number of characters in your acceptance set I'd use indexOf, and I'd probably use StringCharacterIterator. Mind you, with a million characters I'd probably not load them all at once anyway, but process them as streams.
    StringBuffer out = new StringBuffer(s.length() / 5); // allocate plenty
    StringCharacterIterator it = new StringCharacterIterator(s);
    for(char c = it.first(); c != CharacterIterator.DONE; c = it.next())
      if("AG".indexOf(c) >= 0)
          out.append(c);
    return c.toString();

  • How to generate Attribute Sets Automatically?

    it show in Oracle Application Framework Developer’s Guide Release 12.1.2 December 2009 as follow:
    /jdevbin/<SelectedJDevBuild>/build attributesets APPS APPS
    appsdbs.us.oracle.com 1521 devdb /home/jfrost/jdevhome/jdev/myprojects PO
    What is build? how to get it? or How to get Attribute Set Generator?
    Edited by: Kevin on 2010/12/7 下午 6:57

    AFAIK, there's no template for generating web.xml.
    Navigate to <TomcatInstallDir>/webapps/
    You would find lot of directories - each one being a web application.
    Navigate to any one, say ROOT and then to the WEB-INF directory
    under that.
    You would find a web.xml.
    Copy it into your <web-application-dir>/WEB-INF folder and make necessary changes
    cheers,
    ram.

  • Generated Code - Setter Style Issue

    Suggestion -- rather than generate setter code like this:
       public void setFacultyRowSet(JdbcRowSetXImpl jrsxi) {
            this.facultyRowSet = jrsxi;
        }Use this pattern:
      public void setFacultyRowSet(JdbcRowSetXImpl facultyRowSet ) {
            this.facultyRowSet = facultyRowSet;
        }It's more than just a style issue. It's also an issue of clarity. When using code completion and jrsxi appears, it looks like a mistake. Having facultyRowSet appear instead is more comfortable looking because it reinforces what the setter is all about.

    Hello James,
    I have noticed some strange looking variable names too in the generated code. Taking your suggestion into consideration I have filed an RFE for the same.
    Thank you very much for the feed back. Please do continue to share your experiences and giving your feedback to us.
    Cheers :-)

  • Why did TB set the char encoding for a reply to charset=UTF-16LE ?

    I got a message from Google AdWords in HTML format and wrote a reply. When I sent it I got a timeout trying to send it. I use AVG antivirus to scan outgoing messages using a "local server" at address 127.0.0.1.
    Note that this was my second reply to such a message from AdWords. The only thing I could see that was different was a longer subject line (ending with three periods or dots) and a longer HTML message to which I was replying.
    I tried many things to fix the problem and I cannot remember them, sorry.
    Finally, I got success after truncating the message and the long subject line. The reply was sent instantly, as usual, instead of timing out.
    But it wasn't really success. When I looked at the sent message, the characters in my reply (only) were in Chinese. Looking at the raw (source) message, I see that the charset was set as follows: Content-Type: text/plain; charset=UTF-16LE; format=flowed .
    This seems like a strange charset; nowhere in my settings do I specify anything other than Western (ISO-8859-1).
    I finally was able to send the message successfully (I think) by using Options > Character Encoding > Western (ISO-8859-1), which seems to force the message to be sent using this standard encoding instead of Little Endian.
    What caused this problem to happen? Is there a TB overflow bug for long subject lines?
    I realize that TB is an old and unsupported product, but it seems to be the only good email client to use with Windows 8, so I'm just hoping someone knows something about this.

    Originally posted by: warren.tang.nospam.com
    Warren Tang wrote:
    > Warren Tang wrote:
    >> Warren Tang wrote:
    >>> Hi everybody,
    >>>
    >>> I've been trying to set the default encoding of new files as UTF-8.
    >>> Here are the two settings I've set:
    >>>
    >>> 1. Windows > Preferences > General > Content Types, set UTF-8 as the
    >>> default encoding for all content types.
    >>> 2. Windows > Preferences > General > Workspaces, set "Text file
    >>> encoding" to "Other : UTF-8".
    >>>
    >>> However when I create a new text file, the encoding is always
    >>> ANSI/ISO-8859-1. What did I missed? Thanks.
    >>>
    >>> Regards,
    >>> Warren
    >>
    >> I've also tried
    >> Project Properties > Resource > Text file encoding = UTF-8
    >> However it doesn't work either.
    >>
    >> The only thing that works is changing the file's encoding property,
    >> but I don't want to change it every time I create a new file.
    >>
    >> Is it a bug?
    >
    > It turns out that there are other places I need to set up for HTML and
    > CSS files:
    >
    > Windows > Preferences > Web > CSS Files > Encoding = UTF-8
    > Windows > Preferences > Web > HTML Files > Encoding = UTF-8
    I'm getting mad... The file (on the disk) is still not encoded in UTF-8
    but ANSI.

  • Setting maximum char limit for password field

    Hi,
    I am using JPasswordField and I want to restrict the number of characters entered in that field to 20. Any help please...

    See example using JTextField. Same principle applies to JPasswordField.
    http://forum.java.sun.com/thread.jspa?forumID=54&threadID=266101

  • How to generate dynemic GET/SET Method in Struts.....

    hi,
    experts,
    i m doing struts application and i get struct at generatting GET/SET properties for my Dynemic html form in that form i fetch control name and related properties from database and i want to access this properties in action with the help of form which generates dynemic GET/SET properties depends on form controls
    how would i do please give some hints...
    example:
    my html form:
    <html:text name="bpmAttrForm" property="attrName"></html:text>
    . dynemic controls( i don't no how many )
    my form in struts
    public void getX()
    public void setX()
    .... dynemic GET/SET Properties ( i don't no how many )
    like this....
    thnks.....

    Hi ,
    You would have to create a Dynamic form class extending DynaActionForm and ovrride get and set method. In the implementation you access the dyanValues HashMap of DyanActionForm to set and get values from it.
    package yourpackage;
    import org.apache.struts.action.DynaActionForm;
    public class DynaForm extends DynaActionForm
      public Object get(String name)
          Object value = dynaValues.get(name);
          return (value);
      public void set(String name, Object value)
          dynaValues.put(name, value);
    }now in your struts configuration would be
    <form-bean name="myDynaForm" type="yourpackage.DynaForm" />
    if your action class execute method you would have to add and retrive your form properties through the map.
    DynaActionForm myDynaForm = (DynaActionForm) form;
    String prop1  = (String)myDyanaForm .get(propertyName);in your jsp you can access properties using expression library
    ${myDynaForm.map.propertyName}
    Cheers
    Masood

  • I have to generate a 4 char unique string from a long value

    I got a requirment
    I have to generate a 4 char unique string from a long value
    Eeach char can be any of 32 character defined has below.
    private static final char char_map[] = new char[]{'7','2','6','9','5','3','4','8','X','M','G','D','A','E','B','F','C','Q','J','Y','H','U','W','V','S','K','R','L','N','P','Z','T'};
    So for 4 char string the possible combination can be 32 * 32 * 32 * 32 = 1048576
    If any one passes a long value between 0 - 1048576 , it should generate a unique 4 char string.
    Any one with idea will be a great help.

    Well, a long is 64 bits. A char is 16 bits. Once you determine how you want to map the long's bits to your char bits, go google for "java bitwise operators".

  • Generate unique 10 char string

    Hi,
    i have to generate a unique 10 char string ( a string with length of 10 ) which has numbers and alphabets with no special characters, is there any code of doing it
    Ashish

    class UniqueString {
      private static final int NUM_CHARS = 10;
      private static int[] lastString = new int[NUM_CHARS];
      private static final String chars =
    "0123456789abcdefghijklmonpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
      static String getUnique() {   
         char[] buf = new char[NUM_CHARS];   
         carry(lastString, buf.length-1);
         for(int i=0;i<buf.length;i++) {
           buf[i] = chars.charAt(lastString);
    return new String(buf);
    private static void carry(int[] ca, int index) {
    if(ca[index]==(chars.length()-1)) {
    ca[index]=0;
    carry(ca,--index);
    else ca[index]= ca[index]+1;
    public static void main(String[] args) {
    for(int i=0;i<10000;i++)
         System.out.println(UniqueString.getUnique());
    Guarenteed to be unique within one VM instance.
    matfud

  • Preventing ejbgen generating a pk setter on the local interface

    The spec states (10.3.1) that the setter for the pk cmp-field should
    not be exposed on the component interface yet the interface
    generated by ejbgen does in fact generate the setter.
    How do I prevent this?

    Just make sure that you delete something like the following on top of the
    setter
    @ejbgen: local-method
    "Aaron" <[email protected]> wrote in message
    news:3f88ecce$[email protected]..
    >
    The spec states (10.3.1) that the setter for the pk cmp-field should
    not be exposed on the component interface yet the interface
    generated by ejbgen does in fact generate the setter.
    How do I prevent this?

Maybe you are looking for

  • Hi,i have macbook pro ,,how can i install snapchat for my mac

    how to install snapchat for macbook pro

  • How to use JNDI look up from a JSP

    Hello, I know I should not be doing this (writing the lookup code in a JSP) but have to do it for some reasons. I am using this code in my JSP: try      Context ctx = new InitialContext();      dataSource = (DataSource)ctx.lookup("jdbc/mybillingora")

  • Unable to add text in DIVs (Was: divs)

    I have inserted three divs. In the first one I was able to add text to but I am not able to do so for the second nor third, why is this?

  • Group by in reports using Datalink

    I have following queries Q-1 select a1, a2, Amount1 from table1 ,table 2, table 3 where some condidtions group by a1, a2 Q-2 select a1, a2, amount 2 from table 1, table 2, table3 where some condition group by a1, a2 In my report have display the colu

  • PerformancePoint Scorecard not usable by non-admin/creator

    [Using SharePoint 2013 Enterprise SP1] I (as a farm admin) have been successfully creating and using PerformancePoint Scorecards/KPIs which were created in Dashboard Designer. Another admin has been able to use them as well. But when I try to even ju