Print out combinations

hi all
i have got this question
In a file called Combinations.java write a method with the signature:
public void printCombinations(int groupSize, int n)
that prints all the combinations of groupSize numbers taken from the range from 1 to n inclusive, with one group to a line. Groups must appear in numerical order. So, for example, the call printCombinations(3,6) prints the groups:
1 2 3
1 2 4
1 2 5
1 2 6
1 3 4
1 3 5
1 3 6
1 4 5
1 4 6
1 5 6
2 3 4
2 3 5
2 3 6
2 4 5
2 4 6
2 5 6
3 4 5
3 4 6
3 5 6
4 5 6
All the numbers on each line must be separated by a space. You are allowed to assume that printCombinations will only be called with groupSize less than or equal to n and both parameters greater than zero.
i have only managed to write the following codes.
public class Combinations {
     public static void main(String[] args) {
          Combinations q5 = new Combinations();
          q5.printCombinations(3);
     public void printCombinations(int groupsize) {
          printCombinations(groupsize,"  ");
     public void printCombinations(int len1, String  val) {
          if (len1 == 0) {
               System.out.println(" "+ val + " ");
          } else {
               for (int i = 1; i <=6 ; i++) {
                    printCombinations(len1 - 1, val+" "+i);
}output i have is
1 1 1
1 1 2
1 1 3
1 1 4
1 1 5
1 1 6
1 2 1
1 2 2
1 2 3
1 2 4
1 2 5
1 2 6
1 3 1
1 3 2
1 3 3
1 3 4
1 3 5
1 3 6
1 4 1
1 4 2
1 4 3
1 4 4
1 4 5
1 4 6
1 5 1
1 5 2
1 5 3
1 5 4
1 5 5
1 5 6
1 6 1
1 6 2
1 6 3
1 6 4
1 6 5
1 6 6
2 1 1
2 1 2
2 1 3
2 1 4
2 1 5
2 1 6
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 3 1
2 3 2
2 3 3
2 3 4
2 3 5
2 3 6
2 4 1
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
2 5 1
2 5 2
2 5 3
2 5 4
2 5 5
2 5 6
2 6 1
2 6 2
2 6 3
2 6 4
2 6 5
2 6 6
3 1 1
3 1 2
3 1 3
3 1 4
3 1 5
3 1 6
3 2 1
3 2 2
3 2 3
3 2 4
3 2 5
3 2 6
3 3 1
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 4 1
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 5 1
3 5 2
3 5 3
3 5 4
3 5 5
3 5 6
3 6 1
3 6 2
3 6 3
3 6 4
3 6 5
3 6 6
4 1 1
4 1 2
4 1 3
4 1 4
4 1 5
4 1 6
4 2 1
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 1
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 4 1
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 5 1
4 5 2
4 5 3
4 5 4
4 5 5
4 5 6
4 6 1
4 6 2
4 6 3
4 6 4
4 6 5
4 6 6
5 1 1
5 1 2
5 1 3
5 1 4
5 1 5
5 1 6
5 2 1
5 2 2
5 2 3
5 2 4
5 2 5
5 2 6
5 3 1
5 3 2
5 3 3
5 3 4
5 3 5
5 3 6
5 4 1
5 4 2
5 4 3
5 4 4
5 4 5
5 4 6
5 5 1
5 5 2
5 5 3
5 5 4
5 5 5
5 5 6
5 6 1
5 6 2
5 6 3
5 6 4
5 6 5
5 6 6
6 1 1
6 1 2
6 1 3
6 1 4
6 1 5
6 1 6
6 2 1
6 2 2
6 2 3
6 2 4
6 2 5
6 2 6
6 3 1
6 3 2
6 3 3
6 3 4
6 3 5
6 3 6
6 4 1
6 4 2
6 4 3
6 4 4
6 4 5
6 4 6
6 5 1
6 5 2
6 5 3
6 5 4
6 5 5
6 5 6
6 6 1
6 6 2
6 6 3
6 6 4
6 6 5
6 6 6
kindly assist.

try this variation of your program
public class Combinations {
    public static void main(String[] args) {
            Combinations q5 = new Combinations();
            q5.printCombinations(3);
    public void printCombinations(int groupsize) {
            printCombinations(groupsize,"  ");
    public void printCombinations(int len1, String  val) {
            if (len1 == 0) {
                    System.out.println(" "+ val + " ");
            } else {
                    for (int i = 1; i <=6 ; i++) {
                        if(isValidCondidate(val, i)) {
                            printCombinations(len1 - 1, val+" "+i);
    private boolean isValidCondidate(String val, int candidate) {
        String[] splitter = val.split(" ");
        for(int i=0; i < splitter.length ;i ++ ) {
            String string = splitter;
if(!"".equals(string) && Integer.parseInt(string) >=candidate) {
return false;
return true;

Similar Messages

  • Combining a service and item invoice in one print out

    Happy New Year everyone!
    Hope you are all well and are fresh for work! I have a dilemma with a client. They want to be able to combine a service invoice with its corresponding item (kept in the item master data) and produce a print out. The service is taxable.
    Can Crystal report or any other engine achieve that?
    Your assistance will be greatly appreciated.
    Patricia

    You could define a non-inventory item for the service and then both can be seen on the same document!

  • I'd like to print an 8x12 and cut it in half to make two 4x12 panorama type pictures.  Is there any way to combine two pictures (each cropped to 4x12) into one frame so I can print out the 8x12 and trim it after printing?

    I'd like to print an 8x12 and cut it in half to make two 4x12 panorama type pictures.  Is there any way to combine two pictures (each cropped to 4x12) into one frame so I can print out the 8x12 and trim it after printing?

    To clarify, I want to be able to make a flie I can take to a photo printing place (not for my own printer) so they can print it and I crop it.  The place I used to print at used to print an 8"x12" for the same price as 8"x10" (now they may only do 8x10 and I would need to keep the ratio the same so it would be two 3.3"x10" pics on an 8x10").  Any help is veryappreciated!

  • How can I print out the contents of my hardrive

    I have a hardrive with about 200 video clips and need to print the titles for cross refrerencing. I was just going to "grab" screenshots but this will take about ten sheets of paper. How can I print out a list of all the files on the drive?

    I tried this Finder drag method & discovered that it is very important to set the blank TextEdit document to plain text before the drag (from the format menu or with Cmd-shift-t). If you don't, TextEdit attempts to load the content of the files!
    Once I discovered this, I tried the method with Find (Cmd-F) results & it works for that, too. This means that by choosing the right combination of search location(s) & search criteria, you can extend the method to filter the list to just about any files you want, which could be very handy.
    For instance, set the "Kind" criteria to "QuickTime Movie" & location to "Computer" & you get a list of every QT movie. Or set the search location to the folder containing the movies of interest & you get all of them, including ones in subfolders. You could also use the 'date created' or other search criteria to filter the list to a specific subset of movies (or whatever).
    If you need to do this often, you could create one or more 'Smart Folders' with the criteria preloaded for each search.
    The only drawback I see for either Finder based method is the full path one. If you are getting results from just one or a few folders, Find & Replace can delete any of the path name fairly easily, but it becomes a chore if there are a lot of different ones. Some other text editor, like TexEdit Pro, that supports grep searches would be handy here, but since I'm not up to speed on grep, someone else will have to explain how to use it for this, if they want.

  • PO PRINT OUT DIFFICULTIES

    Dear SAP MMIANS,
    Here i a facing problem while po print out . in material master creation we have given description for the said material in purchase order text. but it is not appearing in po print out.bcs it is important to vendor know the details of item.
    ex; we create a LAMP as material the description of this lamp i.e brand , type, voltage , wattage be mentioned in purchasing text in material master . but it is not appearing in po print out .
    thanks regards,
    srinivas kona

    Pls check whether there is NO MATERIAL TEXT indicator selected in the PIR for Vendor/Mtrl combination...
    Due to this mostly it happens,...
    Regards
    Priyanka.P
    AWARD IF HELPFULL
    Edited by: Priyanka Paltanwale on Sep 1, 2008 12:47 PM

  • Print out put of Invoice Verification

    How to get print output of Invoice verification? How to get print output of  subsequent credit/debit of Invoice?

    Hi
    You need to create a new Message type copying any relevant message type.(tCode M806). Maintain the processing routines  with medium as print out put.
    Create  the form required for Print out put & assign it to the routine.
    Maintain the message schemas , Assign the new Message type to the existing schema.
    Now create the conditoin record using transaction MRM1 with th required key combination. Invoicing party & Company code.
    Now when ever you create the invcoie with combination the Message will be created.
    Execute transaction MR90 for the print out put. If you want the print after saving the invoice , maintain the despatch time as Send immediately when saving the application.
    Reward points if useful
    Thanks & Regards
    Kishore

  • How to get Print out of MIRO

    Hi all,
           Please tell me the steps to get a print out of Logistic Invoice verfication.

    As per standard there is no Output type for Invoice printing.
    You need to create a new message tpe ZINV copying the KONS or ERS out put type , Copy all the settings which are maintained.
    SPRO-> Materials Management-> Logistics Invoice Verification-> Message Determination-> Maintain Message Types
    Maintain ZINV in message schema in
    SPRO-> Materials Management-> Logistics Invoice Verification-> Message Determination-> Maintain Message Schemas, Here Selct
    MR0002 - Logistics Inv. Ver. (MR1M), Click on Control Dat & add the newly created out put type
    Maintain the Condition records for the output type ZINV in MRM1 transaction.
    with key combination Compnay code or Company code/Vendor
    So when you create the Invoice the Message gets triggered.
    Then you can print the Invoice using transaction MR90.
    If you want to change the form you can create anew one & then assign the Same to the Out put type
    Thanks & Regards
    Kishore
    Edited by: Kishore Kumar Chiluka on Jul 25, 2008 8:54 AM

  • How can I print out specific categories on my outlook calendar

    After downloading latest version of Icloud. I am not able to print out specific categories on icloud calendar

    I tried this Finder drag method & discovered that it is very important to set the blank TextEdit document to plain text before the drag (from the format menu or with Cmd-shift-t). If you don't, TextEdit attempts to load the content of the files!
    Once I discovered this, I tried the method with Find (Cmd-F) results & it works for that, too. This means that by choosing the right combination of search location(s) & search criteria, you can extend the method to filter the list to just about any files you want, which could be very handy.
    For instance, set the "Kind" criteria to "QuickTime Movie" & location to "Computer" & you get a list of every QT movie. Or set the search location to the folder containing the movies of interest & you get all of them, including ones in subfolders. You could also use the 'date created' or other search criteria to filter the list to a specific subset of movies (or whatever).
    If you need to do this often, you could create one or more 'Smart Folders' with the criteria preloaded for each search.
    The only drawback I see for either Finder based method is the full path one. If you are getting results from just one or a few folders, Find & Replace can delete any of the path name fairly easily, but it becomes a chore if there are a lot of different ones. Some other text editor, like TexEdit Pro, that supports grep searches would be handy here, but since I'm not up to speed on grep, someone else will have to explain how to use it for this, if they want.

  • Goods issue print out

    Hi
    I have completed stock transport order purchase order.then i do in t.code mb11 351 movement type goods issue.i want to take print out on that 351 goods issue,i try to give output type in mb02 t.code that time showing error,plz help
    Output WA02 for medium 1, partner function  is not defined
    Message no. VN025
    Diagnosis
    You have selected a combination of output and partner function which has not been defined.
    Procedure
    Make sure your entries are correct.
    This is a warning message. You can proceed by pressing ENTER.
    To prevent the warning message from appearing again, assign the required partner function to your output type in table TNAPN
    Regards
    Sam

    Hi there
    Check the below settings whether you have done it clear,,
    NACE-Select ME Click on Condition records- Select WA02( As you want)-Trans/Event Type-"WA" Print Version " 2" and Execute it
    In the next scren P-1, medium-1, Date/Time-Select 39as you want), Language EN and enter,, Now select the line and click on the communication and there enter the output device if anything specified for you,, and save it,,
    Now check in MB02, enter the material document, and double click on the any line item, Click on the messages do the same process for this document as above and save it and try MB90,, surely it wil work and for the future docs,,
    Thanks
    Senthil

  • Output Type assigning for GR Print out

    Hi,
    As after cresting of GR through MB01 or MIGO we are taking GR print out with T. Code MB90 in this we are entering only GR No. and Yaer and the print out is coming re. to Output type WE03 even though we are keepint output type  filed blank on the selection screen of MB90 .
      I want to confirm the required setting for How this can be set as defalut output type WE03, WE02 etc..
      regards,
        zafar

    Hi,
    In MN21 you matain condtion record for specific access sequence.
    Like plant/material/stor loc level or something different as per your requirement.
    If you maintain 2 diff. condtion types like WE01 and WE03  for same combination then system will trigger output for both in MB90 transaction if you do not give condtion type in selection screeen.
    Regards,
    Shailesh

  • PO print out issue

    Hi Guru ,
    This is very interesting issue regarding PO print out. i have developed Zform for PO  . I have assign this form in NACE setting.
    Ok then i have created a PO and define Message type for that PO Like ... Out Put type - NEW, Medium - Print Out , Function - Vendor , Partner - 100018 and Language - EN .
    For this Message Type - Out put is comming perfect with correct data.
    But when i changed Message Type Language - EN to AR(Arabic) and other parameter will be remain same then what happend is PO out put is comming - Mirror image (opposite of EN language). Means all data is printing in right to left and layout of form also changed - means window is also print opposite site - PO window printing in PO address window and PO address window is printing in PO window.
    Kindly any body can suggest solution regarding this.
    Regards
    Durgesh
    Please do not offer po1nts
    Edited by: Rob Burbank on Jul 26, 2010 2:36 PM

    Hi Durgesh,
    Please refer to this article in SDN which lists all the Printer/ Device  type combinations (including legacy device types)
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/1015a496-94d5-2b10-3c8e-845ff55480c0?quicklink=index&overridelayout=true
    ARSWIN is the one for your case.
    Also please copy the form into Arabic Language Key as suggested by Aidan.
    Rgds,
    Arnab Sinha

  • Print out of outbound deliverty??

    Hi ,
    My querry is  can I take out tHE print out of list of items from outbound delivery number , if yes pls guide me how to do it .

    Hi,
    Do you mean to say print out of the delivery document? Go through the following:
    IMG - logistics execution - shipping - basic shipping functions - output control - output determination - maintain output determination for outbound deliveries:
    1. Create condition table. Here select the key combination according to which you want to maintain the condition record.
    2. Maintain access sequence. Here you assign the condition table that you maintained in step no. 1.
    3. Maintain the condition type for delivery output. The standard for the outbound delivery is "LD00".
    4. Maintain the output determination procedure. Here assign the condition type "LD00" to the procedure.
    5. Assign output determination procedures. You can assign the procedure to the delivery header or item also.
    Header: Select the delivery document type and asign the procedure that you created in step no.4
    Item: Select the required item category and assign the procedure that you created in step no.4
    6 Condition record maintenance:
    Use transaction code "VV21" to maintain the record. Rnter the customer no. and press enter, the system will automatically select the partner function as "SH-ship to party". Now select the line item and click on "communication", select the printer and save it.
    Now wheneve you create the delivery and save it. Go to VL02N select the delivery doc. no. in the menu bar select the issue output to. Here select the output type and click on print preview.
    Reward points if solution helps.
    Regards,
    Allabaqsh G. Patil

  • In po,every time i want to add the message for print out.

    in po,every time i want to add the message for print out.
    is there any permanent solution for above issues ?

    Hi,
    1) use transaction nace
    2)Select application EF  and go to condition records
    3) o/p type is neu , select the same and double click on it .
    4) select paricular condition table.
    5) maintain condition records , means for particular combination NEU should appear automatically in PO print.

  • Print out confirmation after entering confirmation in CO11n

    Hello,
    we need to automatically print out an confirmation slip or some kind of document that shows the amount of confirmed materials every time we have confirmed operation 0150 (Co11n) which is always our last production order operation.
    Is there a way to do that?
    Thanks
    Anne

    Hi,
    Inorder to get the print of any shop floor control papers you to configure the same in SPRO : Tcode : OPK8 against the user and Plant.
    If you want to have your specific layout then you need to create a FORM and Assign the same here agianst the Ref Ord , Plant, List, Output devics, SAP Script Form.
    You can even give the printer Specification here, which can be assigned to Plant., MRP COntroller and List combination
    If you want to restrict at the transaction level it is possible to do here.
    Hope this will help you.
    regards
    radhak mk

  • Print out a column value only if another column has a specific value (CASE Statement)

    Hello all,
    I tried many hours to find a solution for the following request but wasn't successful. Maybe you could help me.
    I've using the already existing SQL Views in Microsoft Service Manager to do some basic reporting about my tickets.There is no closed date in the activity tickets so I decided to print out the lastmodified timestamp when the status is "closed".
    That's my query:
    SELECT DISTINCT
    dbo.DisplayStringView.DisplayName AS Status,
    CASE WHEN dbo.DisplayStringView.DisplayName = 'Closed' THEN dbo.DisplayStringView.LastModified ELSE 'NO CLOSED Date' END AS ClosedDate
    FROM dbo.MTV_System$WorkItem$Activity$ManualActivity LEFT OUTER JOIN
    dbo.DisplayStringView ON dbo.MTV_System$WorkItem$Activity$ManualActivity.Status_8895EC8D_2CBF_0D9D_E8EC_524DEFA00014 = dbo.DisplayStringView.LTStringId
    Unfortunatelly I'm not getting the value from dbo.DisplayStringView.LastModified. SQL outputs that it is not possible to convert the string to date/time.
    I think there is a problem with the CASE statement in combination with a value select.
    Any ideas how to print out a column value only if another column has a specific value?

    I think it is the other way if you want the missing date shown as a string.
    CASE
    WHEN
    dbo.DisplayStringView.DisplayName
    =
    'Closed'
    THEN
    Convert( varchar(10),dbo.DisplayStringView.LastModified
    , 101) ELSE
    'NO CLOSED Date'
    END
    AS
    ClosedDate 

Maybe you are looking for

  • Multiple Prepayment for a single Assignment or specific Assignment Set

    Hi Everyone I am working in Payroll Department, and I had a difficulties of running more than one prepayment for the same. We need sometime to pay for an employee a specific element like "Official Assignment Compensation" before the end of the month

  • Stored Proc to create XML (using nested cursors)?

    From previous posts and from the documentation for XSQL I have discovered the joys of the CURSOR operator to create nested tables: i.e: SELECT dname, CURSOR (SELECT ename, sale....) as employees FROM dept However, I can not find any other documentati

  • Labelling photos within an 'Event'

    Can I label photos within an Event folder - i.e. to show different cities visited on the same trip?

  • Objects containing objects.Expr cannot be used as an assignment.PLS-00363.

    Hi, My database: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0. I'm working with Object types containing other object types, and I'm getting the error PLS-00363 (Expression cannot be used as an assignment). I'm putting exlpicity all 'SELF

  • How to parse Soap response of anytype structure

    I have went through almost all url regarding this in stackoverflow but could not make it work even after following same steps,either getting property not found or arrayindex exception ,the response i am trying to parse is has below and this can conta