Permutations of non-sequential string in C

Hi,
I'm just learning C now and am trying to get my head around this permutation pickle I'm in.  I can pretty simply write code that will give all permutations of N number of letters from A-z.  E.g., if N = 4, it will print out AAAA AAAB .... zzzz. This is pretty simple iteratively or recursively with a counter.
now, however, I want to enter in a string that does not neccessary contain letters in sequence, and find all the possible relevant permutations of that string.  E.g. I input a string of BEHP, and  I want to find all the permutations of this combination.  I don't want BBBB, BBBE, etc., I want BEHP, BHPE, BPHE, etc. 
I think my current approach is severely limited by the counter method, as it's giving permutations that are just not relevant.
Also, can someone please confirm the maths on this.  If I have a string of 3 letters, ABC, the number of possible combinations is 3! right? 3 factorial?
Thanks

I don't know C, but have a couple of logic-based suggestions.  I believe you are right in your permutations calculation of 3!.  To solve your problem of combinations, could you do something like put each character into an array (which is ordered by index) and then use a similar technique to the one you used for the other set of letters but base it on the index number?

Similar Messages

  • Non-sequential scanning with SCXI and Labwindows/CVI

    I'm trying to scan channels 0 and 2 (skipping channel 1) of a SCXI-1520 module with a SCXI-1000 chassis using LabWindows/CVI, but am getting error 10370 (Invalid Scan list).
    I've read here that the SCXI-1520 module supports non-sequential scanning, even with traditional NI-DAQ drivers, but I can't get this working.
    I'm using NI-DAQ 6.9.3 and LabWindows/CVI 6.0.
    I'm not using a channel string, but intead am using SCXI_Track_Hold_Setup and SCXI_SCAN_Setup.
    For the scan setup my arrays are:
    Module_List={1,1}
    #_of_Channels_List={1,1}
    Start_Channel_List={0,2}
    I've tried setting the Hol
    d_Count for the module to both 1 and 2 in SCXI_Track_Hold_Setup, but that doesn't help.
    Is this possible, and if so, how?

    OK, in essence, my code is:
    SCXI_Reset(chassis,-1);
    SCXI_Load_Config(chassis);
    hold_count=2; // Note: Tried 1 but that doesn't work either.
    SCXI_Track_Hold_Setup(chassis,slot,2,2,0,hold_count,device);
    // Note: tried 2,0,2 but doesn't work either, and then can't scan multiple modules.
    SCXI_Set_Gain(chassis,slot,-1,1);
    SCXI_Set_Excitation(chassis,slot,-1,VDC,5.0,&actual);
    SCXI_Configure_Filter(chassis,slot,0,BYPASS,0);
    SCXI_Configure_Filter(chassis,slot,2,BYPASS,0);
    SCXI_Configure_Connection(chassis,slot,-1,QUARTER);
    num_modules=2;
    Module_List={1,1};
    Channels_List={1,1};
    Start_List={0,2}
    SCXI_Scan_Setup(chassis,num_modules,Module_List,Channels_List,Start_List,device,0);
    // This causes error -10370:badScanListError
    Any help greatly appre
    ciated!

  • Non english string in URL

    Hi,
    I'm trying to send a non English string from one WD application to another.
    I managed to encode it to UTF-8 using java.net.URLEncoder in the sending application but could not decode it in the receiving application. The WD is doing some decoding to a character set I don't now.
    Any idea anyone??
    Thanks and regards,
    Nachshon

    Suggestions
    1) Try with NLS_LANG as
    SWEDISH_SWEDEN.WE8DEC
    2) Make a paramform and enter via paramform (unencoded)
    (This is just for testing purpose)
    3) Change machine locale to swedish and try
    4) Which reports version is this ?
    Please see
    BUG 2713695 - NLS CHARACTERS FOR PARAMETERS CHANGE TO QUESTION MARKS WHEN PASSED ON URL BAR
    Get in touch with Support to see if this is the issue and if "yes" get a one-off patch.
    [    All Docs for all versions    ]
    http://otn.oracle.com/documentation/reports.html
    [     Publishing reports to web  - 10G  ]
    http://download.oracle.com/docs/html/B10314_01/toc.htm (html)
    http://download.oracle.com/docs/pdf/B10314_01.pdf (pdf)
    [   Building reports  - 10G ]
    http://download.oracle.com/docs/pdf/B10602_01.pdf (pdf)
    http://download.oracle.com/docs/html/B10602_01/toc.htm (html)
    [   Forms Reports Integration whitepaper  9i ]
    http://otn.oracle.com/products/forms/pdf/frm9isrw9i.pdf
    ---------------------------------------------------------------------------------

  • A way to add cross-dissolves to a bunch of different, non-sequential clips?

    Hey mac geniuses,
    Is there a way to add cross-dissolves to a bunch of non-sequential clips? Basically, one of my three video tracks features a different image for a few seconds every minute or so (they're slides from a presentation), and I'd like to be able to add a cross-dissolve at the beginning and end of each image.
    Is there a way to do those transitions all at once considering they're not back to back?
    Thanks for your help!
    BP

    Select the clips on the track with the track forward tool and press Cmd-T, assuming the current version.

  • Non-English string access from excel sheet through JDBC

    My excel sheet data is
    Test ������������
    I am using JDBC connectivity for accessing the Excel sheet.
    Code looks like,
    List Output = new List();
    try
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    c = DriverManager.getConnection( "jdbc:odbc:qa-list", "", "" );
    stmnt = c.createStatement();
    ResultSet rs = stmnt.executeQuery("select * from [Sheet1$];");
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    for(int i=1; i <= numberOfColumns; i++){
    Output.add(rsmd.getColumnLabel(i));
    catch( Exception e )
    System.err.println( e );
    finally
    try
    stmnt.close();
    c.close();
    catch( Exception e )
    System.err.println( e );
    Now. I am showing those data into the table(JTable) Applet programming.
    For, English string it is showing properly but, for non-English string are showing �???????????????????�
    I would like to know what could be the reason.
    Addional info:
    ava version "1.6.0_01"
    Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
    Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
    If possible please send some reference code .

    I have one excel sheet which having differenct countries specific meaining of common words.
    I am using JDBC connectivity for accessing that Excel sheet.
    Code looks like,
    List Output = new List();
    try
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    c = DriverManager.getConnection( "jdbc:odbc:qa-list", "", "" );
    stmnt = c.createStatement();
    ResultSet rs = stmnt.executeQuery("select * from [Sheet1$];");
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    for(int i=1; i <= numberOfColumns; i++){
    Output.add(rsmd.getColumnLabel(i));
    catch( Exception e ){
    System.err.println( e );
    finally{
    try{
    stmnt.close();
    c.close();
    catch( Exception e ){
    System.err.println( e );
    Now. I am showing those output data into the table(JTable) in my Applet programming.
    For, English string it is showing properly but, for non-English strings are showing question marks like, �?????�
    I would like to know what could be the reason.
    Please help me, i am stuck in my project.

  • Non-sequential shuffle.

    Hey all, I seem to be a bit.. stuck. I'm trying to make a program that takes a user defined integer from the command line, then prints it out in a shuffled, non-sequential order. Meaning, 4 cannot follow 5, and 9 cannot follow 8, etc. Here is my code thus far:
         int N = Integer.parseInt(args[0]);
              int[] song = new int[N];
         for (int position = 0; position < N; position++) {
             int list = position;
             song[position] = list;
            for (int current = 0; current < N; current++) {
             int swap = current + (int) (Math.random() * (N - current));
             int tempSong = song[current];
             song[current] = song[swap];
             song[swap] = tempSong;
             if (song[current] == (song[swap+1] || song[swap-1]))
              { randomize song[swap]; }
             else
              { System.out.println(song[swap]); }
         System.out.println(song[current] + " ");
         }When I go to compile it, it gives me the following two errors:
    Shuffle2.java:22: ']' expected
              { randomize song[swap]; }
                               ^
    Shuffle2.java:22: illegal start of expression
              { randomize song[swap]; }
                                   ^
    2 errorsAny help with this would be greatly appreciated.

    I'm really just not getting it. I wanna say I'm almost there, but at the same point I just don't know.
         int N = Integer.parseInt(args[0]);
         int[] song = new int[N];
         for (int position = 0; position < N; position++) {
             int list = position;
             song[position] = list;
            for (int current = 0; current < N; current++) {
             int swap = current + (int) (Math.random() * (N - current));
             int tempSong = song[current];
             song[current] = song[swap];
             song[swap] = tempSong;
             if (song[current] == song[swap+1] ||
              song[current] == song[swap-1])
             else
              { System.out.println(song[swap]); }
         System.out.println(song[current] + " ");
         }I'm just lost as to what I put where the "**" is.

  • Cannot convert between unicode and non-unicode string datatypes

      My source is having 3 fields :
    ItemCode nvarchar(50)
    DivisionCode nvarchar(50)
    Salesplan (float)
    My destination is : 
    ItemCode nvarchar(50)
    DivisionCode nvarchar(50)
    Salesplan (float)
    But still I am getting this error : 
    Column ItemCode cannot convert between unicode and non-unicode string datatypes.
    As I am new to SSIS , please show me step by step.
    Thanks In Advance.

      My source is having 3 fields :
    ItemCode nvarchar(50)
    DivisionCode nvarchar(50)
    Salesplan (float)
    My destination is : 
    ItemCode nvarchar(50)
    DivisionCode nvarchar(50)
    Salesplan (float)
    But still I am getting this error : 
    Column ItemCode cannot convert between unicode and non-unicode string datatypes.
    As I am new to SSIS , please show me step by step.
    Thanks In Advance.
    HI Subu ,
    there is some information gap , what is your source ? are there any transformation in between ?
    If its SQL server source and destination and the datatype is as you have mentioned I dont think you should be getting such errors ... to be sure check advance properties of your source and check metada of your source columns
    just check simple oledb source as
    SELECT TOP 1 ItemCode = cast('111' as nvarchar(50)),DivisionCode = cast('222' AS nvarchar(50)), Salesplan = cast(3.3 As float) FROM sys.sysobjects
    and destination as you mentioned ... it should work ...
    somewher in your package the source columns metadata is not right .. and you need to convert it or fix the source.
    Hope that helps
    -- Kunal
    Hope that helps ... Kunal

  • Non-sequential enum causes error

    When calling a .NET object that has a property that sets an enum value, I am getting a runtime error in the .NET code if the enum is defined such that each value is not a sequential number (as in a bit mask). If the values are sequential there is no problem. In both cases, the sequence editor shows a drop down with the names of the enum values but puts the name in quotes.
    Does TestStand handle enums with non-sequential values properly?
    Solved!
    Go to Solution.

    It works for me if I specify the values separated by commas or specify the value numerically. For example:
        [Flags]
        public enum mybitfield
            myval1 = 0x1,
            myval2 = 0x2
    For the above bitfield, to specify both values for a parameter you can either specify:
    "myval1, myval2"
    0x1 | 0x2
    0x3
    Any of the above worked for me in both TestStand 4.2.1 and TestStand 2010.
    Hope this helps,
    -Doug

  • Non sequential values for knobs

    Is it possible to set non-sequential values for the control knobs on the front panel? For example, I'd like to set values of 1, 2, 5, 10, 20, 25, 50, 100, etc...

    Use the log mapping and text labels.  See example.
    Attachments:
    Non_Seq_Knob.ctl ‏5 KB

  • Ascii value of a non numeric string  literal

    hi,
    i would like to get the ascii value of a non numeric string
    having special characters from extended ascii set.
    for example i have a user id "J��o M��" and i want to get the ascii value of each character in this string.
    (There are special characters having ascii value more than 127, present in string literal)
    if you know some methods to do that ??
    thanks

    Use charAt(i) to give you each char in the string. A char is also the numeric value of the character: note that there's no such thing as "extended ASCII" -- ASCII is the first 128 characters of Unicode, and Java uses Unicode characters.
    String str = "Hello";
    for (int i = 0; i < str.length(); i++)
        System.out.println((int) str.charAt(i)); // cast to int so the char is displayed as a number

  • Generating non-sequential primary keys

    Is there a simple way to generate non-sequential primary keys? Say for instance I want to generate a user ID. I'd like all of the IDs to be unique, but not strictly sequential.

    >
    Hi Crottyan,
    Is there a simple way to generate non-sequential primary keys? Say
    for instance I want to generate a user ID. I'd like all of the IDs to be
    unique, but not strictly sequential.Normally this is done to eliminate contentation for index inserts - why do
    you want to do it?
    Be careful with GUID - it can be [url http://en.wikipedia.org/wiki/Globally_unique_identifier#Sequential_algorithms]sequential.
    It's a pity you didn't tell us your version of Oracle :( - you should always do this.
    10 XE has a sequential algorithm. 11 XE doesn't.
    HTH,
    [Edit] Just saw your post about inferring insert order - fair enough. Will be able to tell you about 11 EE next
    week ;)
    Paul...
    Edited by: Paulie on 18-Jul-2012 18:03

  • SSIS Package : While Extracting Sharepoint Lookup column, getting error 'Cannnot convert between unicode and non-unicode string data types'

    Hello,
    I am working on one project and there is need to extract Sharepoint list data and import them to SQL Server table. I have few lookup columns in the list.
    Steps in my Data Flow :
    Sharepoint List Source
    Derived Column
    its formula : SUBSTRING([BusinessUnit],FINDSTRING([BusinessUnit],"#",1)+1,LEN([BusinessUnit])-FINDSTRING([BusinessUnit],"#",1))
    Data Conversion
    OLE DB Destination
    But I am getting the error of not converting between unicode and non-unicode string data types.
    I am not sure what I am missing here.
    In Data Conversion, what should be the Data Type for the Look up column?
    Please suggest here.
    Thank you,
    Mittal.

    You have a data conversion transformation.  Now, in the destination are you assigning the results of the derived column transformation or the data conversion transformation.  To avoid this error you need use the data conversion output.
    You can eliminate the need for the data conversion with the following in the derived column (creating a new column):
    (DT_STR,100,1252)(SUBSTRING([BusinessUnit],FINDSTRING([BusinessUnit],"#",1)+1,LEN([BusinessUnit])-FINDSTRING([BusinessUnit],"#",1)))
    The 100 is the length and 1252 is the code page (I almost always use 1252) for interpreting the string.
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • Column "A" cannot convert between unicode and non-unicode string data types

    I am following the SSIS overview video-
    https://secure.cbtnuggets.com/it-training-videos/series/microsoft-sql-server-2008-business-development/6143?autostart=true
    I have a flat file that i want to import the contents onto a SQL database.
    I created a Dataflow task, source file and oledb destination.
    I am getting the folliwung error -
    "column "A" cannot convert between unicode and non-unicode string data types"
    in the origin file the data type is coming as string[DT_STR] and in the destination object it is coming as "Unicode string [DT_WSTR]"
    I used a data conversion object in between, dosent works very well
    Please help what to do

    I see this often.
    Right Click on FlatFileSource --> Show Advanced Editor --> 'Input and Output Properties' tab --> Expand 'Flat File Source Output' --> Expand 'Output Columns' --> Select your field and set the datatype to DT_WSTR.
    Let me know if you still have issues.
    Thank You,
    Jay

  • Cannot convert between unicode and non-unicode string data types.

    I'm trying to copy the data from 21 tables in a SQL 2005 database to a MS Access database using SSIS. Before converting the SQL database from 2000 to 2005 we had this process set up as a DTS package that ran every month for years with no problem.  The only way I can get it to work now is to delete all of the tables from the Access DB and have SSIS create new tables each time. But when I try to create an SSIS package using the SSIS Import and Export Wizard to copy the SQL 2005 data to the same tables that SSIS itself created in Access I get the "cannot convert between unicode and non-unicode string data types" error message. The first few columns I hit this problem on were created by SSIS as the Memo datatype in Access and when I changed them to Text in Access they started to work. The column I'm stuck on now is defined as Text in the SQL 2005 DB and in Access, but it still gives me the "cannot convert" error.

    I was getting same error while tranfering data from SQL 2005 to Excel , but using following method i was able to tranfer data. Hopefully it may also help you.
    1) Using Data Conversion transformation
       data types you need to select is DT_WSTR (unicode in terms of SQL: 2005)
    2) derived coloumn transformation
       expression you need to use is :
        (DT_WSTR, 20) (note : 20 can be replace by your character size)
    Note:
    Above teo method create replica of your esting coloumn (default name will be copy of <coloumn name>).
    while mapping data do not map actual coloumn to the destination but select the coloumn that were created by any of above data transformer (replicated coloumn).

  • How to fix "cannot convert between unicode and non-unicode string data types" :/

    Environment: SQL Server 2008 R2
    Introduction:Staging_table is a table where data is being stored from source file. Individual and ind_subject_scores are destination tables.
    Purpose: To load the data from a source file .csv while SSIS define table  fields with 50 varchar, I can still transfer the data to the entity table/ destination and keeping the table definition.
    I'm getting validation error "Cannot convert between a unicode and a non-unicode string data types" for all the columns.
    Please help

    Hi ,
    NVARCHAR = DT_WSTR
    VARCHAR = DT_STR
    Try below links:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/ed1caf36-7a62-44c8-9b67-127cb4a7b747/error-on-package-can-not-convert-from-unicode-to-non-unicode-string-type?forum=sqlintegrationservices
    http://social.msdn.microsoft.com/Forums/en-US/eb0d1519-4be3-427d-bd30-ae4004ea9e8d/data-conversion-error-how-to-fix-this
    http://technet.microsoft.com/en-us/library/aa337316(v=sql.105).aspx
    http://social.technet.microsoft.com/wiki/contents/articles/19612.ssis-import-excel-to-table-cannot-convert-between-unicode-and-non-unicode-string-data-types.aspx
    sathya - www.allaboutmssql.com ** Mark as answered if my post solved your problem and Vote as helpful if my post was useful **.

Maybe you are looking for

  • Re: 2ª via de Nota Fiscal e certificado de garantia.

    Olá! Meu problema é parecido com a da lorenafayal: "Comprei um notebook Dell com vcs em Orlando. Gostaria de solicitar uma segunda via da nota fiscal. Como devo proceder?" Obrigado. Anderson Bueno Solved! Go to Solution.

  • Is it possible to change the scale of graph in webi ?

    Hi All, How to change the scale of graph in the web intelligence report. Thanks in advance, Ravi

  • Deep DDIC-Structure - Method to get the Comp.Type of a sub-structure

    Dear colleagues, thought the subsequent piece of coding might be helpful for the following problem: In DDIC you have created a deep/nested Structure e.g. a complete Business Document representation like s_doc_header type struct_doc_header      (incl.

  • Adapter Engine is not working

    hi all My Adapter Engine is not working in RWB. In runtime workbench - message monitoring u2013 message from component - adapter engine is not working experts provide me the solution Regards Raju

  • Cabling Clarification - HDMI vs. component/optical

    Unfortunately, I'm out of HDMI ports to connect my AppleTV. If I understand it correctly, one of HDMI's advantages is the ability to send 1080p signals. I'm thinking that doesn't really matter because nothing broadcast through the AppleTV is of that