Combinations of integers

Hello is there anyone there who can help me? I am writing a program that evaluates poker hands. I need a way of creating all 2 card combinations from the list of all cards not yet dealt.
I have 4 arrays that store the undealt cards off each suit. I now need to search one of the arrays and find the first instance of an undealt card and fix this card as card 1. I then want to recursively search the rest of this array and the 3 other arrays each time returning the values of the cards not yet dealt. I have tried a few methods but either can only print out different pairs and not different combinations or i get a StackOverFlowError.
below is the code I have currently.
    public void selectCards(){
     //p = new PokerHand();
     added = 0;
     //fix first card
     while(added == 0){
         for(int i=0;i<tothearts.length;i++){//tothearts is the array containin the hearts
          if(tothearts[i] == 1){
              PokerCard c1 = new PokerCard(i,PokerCard.HEARTS);//create an instance of a card with rank i & suit
              p.addCard(c1);
              tothearts[i] = 0;//remove this card so that duplicate cards arent included
              added++;
              break;
     while(added >= 1 && added <=2){
         for(int i=0;i<tothearts.length;i++){//tothearts is the array containin the hearts
          if(tothearts[i] == 1){
              PokerCard c1 = new PokerCard(i,PokerCard.HEARTS);//create an instance of a card with rank i & suit
              p.addCard(c1);
              tothearts[i] = 0;//remove this card so that duplicate cards arent included
              added++;
              System.out.println("Hand = "+p);
              p.removeCard(p.getHand().size()-1);
              break;
     selectCards();
    }The above code is only for one suit eventually i want to be able to do it for all four suits
here is my output:
My hand = 7c qd ah 5h jc 8c 9c
Opponents hand = ? ? ah 5h jc 8c 9c
Hand = 2h 3h
Hand = 2h 4h
Hand = 2h 6h 7h
Hand = 2h 6h 8h
Hand = 2h 6h 9h 10h
Hand = 2h 6h 9h jh
Hand = 2h 6h 9h qh kh
If anyone could point out to me where i am going wrong that would be helpful.

Hello is there anyone there who can help me? I am writing a program that evaluates poker hands. I need a way of creating all 2 card combinations from the list of all cards not yet dealt.
--Well, I solved a similar poker problem, that 'normalize' any number of poker hands then 'rank' them in order from best to worst. If you need any help to normalize and rank poker hands then let me know. For an example:
Input:
4
8H 9D 8S 9C 8C
AS 2S 3S 4S 5S
TS JS 9H 8D QC
KC KS 2C 2H 2D
Output:
Normalize Hands:
4
8H 8S 8C 9D 9C
AS 5S 4S 3S 2S
QC JS TS 9H 8D
2C 2H 2D KC KS
Ranked Hands:
AS 5S 4S 3S 2S-------> Straight-Flush
8H 8S 8C 9D 9C------->Full-House
2C 2H 2D KC KS------->Full-House
QC JS TS 9H 8D-------->Straight
Good luck!

Similar Messages

  • Are clusters or individual elements better for shared variables?

    So...  I have some RT code that is being updated, and pulled out of the Stone Ages of LabVIEW.  It was originally written for an old FieldPoint controller operating in "headless" mode, and used the "publish" and datasocket methods for communications and external control.  I had to get clever way back then, and put together a parsing/unparsing system for strings to send sets of data back and forth between the controller and any HMI or other computer attached.
    Now, I'm completely rewriting the code for a cRIO system, and doing my best to leverage all of the strengths of the latest LabVIEW versions.  I have already done an intermediate stage, where I converted from the publish/datasocket method to using network shared variables for my strings, so I could keep some of the original control and calculation logic.  Now, however, I'm going back to the drawing board for most of the program, with only some of the proven logic being held over into the new version.  And, as I'm putting together the data structures I need for both internal control and external communication, I'm in a bit of a quandary...
    I have come upon a data structure dilemma:  should I use individual shared variables for my data, or assemble associated data into clusters?  My original program had a string (essentially a flattened cluster) for each sensor in use (up to 4), one for the system parameters and states, and one for the control parameters and states.  There was a certain advantage to keeping the data compartmentalized like that, it kept things organized and forced me to avoid too many random references of each data point.  And it kept the number of communications channels limited to just a handful.  Mimicking this structure with cluster shared variables would be easy.  But, I'm not sure it's the best or most network-efficient method.
    I know the bundling/unbundling will add some processor time in my code, that is not new to me (it will still be much faster than my old parsing routines).  But, if I have individual data points being thrown around, I can access them easily from things like Data Dashboard (which is great, but far too limited to be able to grab items in clusters and such).  Having all of my data points individually available would make my project messier, but open up easier access.  It would also dramatically increase the number of data points being thrown around on the network at any one moment.  For reference, I would probably have a maximum of 100 data points at one time, made up of a combination of integers, floats, booleans, integer arrays, boolean arrays.  Or I would have a maximum of 8 clusters that would contain those data points.
    Any suggestions on which way I should lean?  Are there any advantages/disadvantages between shared clusters like the ones I need vs. the number of individual shared variables I would need using the alternative methods?  Network traffic and efficiency are always a concern, particularly since this is a "headless" cRIO in a control situation that must maintain a fast scan rate...
    Thanks for any help.  I'm so stuck on this fence, and I can't figure out which side to fall off!
    Solved!
    Go to Solution.

    Thanks Tim, that is a great source that I somehow missed in my hunt for information regarding my dilemna...
    I have to wonder though, does that 25 number also include the I/O points on your cRIO?  Anyone know that particular?  Most of the I/O points are network shared by default during initial configuration, and you could very quickly exceed 25 variables on an 8 slot rack (such as the one I use, a 9074).  Now I'm a bit worried that I'm overusing the variable engine, even before the communications clusters get figured in...

  • Combining two ArrayLists of Integers into a new ArrayList.

    Basicly I have two arrayLists that have a list of numbers and I want to add them both into one new arrayList in the same index. Example
    aList1 = [ 4 , 5 , 10 , 33 ]
    aList2 = [ 1 , 3 , 19 ]
    combinedList = aList1 + aList2
    print out combinedList = [4,5,10,33,1,3,9]
    That's what I want out of it but the only way I can do this is if I write
    combinedList.add[aList1]
    combinedList.add[aList2]
    but it would come out like [ 4 , 5 , 10 , 33 ] [ 1 , 3 , 19 ]. Two seperate indexs holding a list of Integers. Where I need it to be [4 , 5 , 10 , 33 , 1 , 3 , 9]
    Which is incorrect cause they are in seperate indexs. I need to place both of them into the same index starting with all the numbers for aList1 and then aList2.
    I could just go through each aList1 index and placed each one into a new arrayList and then do that with aList2 but I'm trying to make this a little more efficient than that. I tried using addAll but it seems to add each arrayLists as an object and that just comes out like 2. Here's some of the code from by program.
    Collections.sort(alist1);
    Collections.sort(alist2);
    aNewList.add(alist1);
    aNewList.add(alist2);   
    return aNewList;Like I said I could do it the long way but I'm trying to keep the complexity to a minimum. Any help would be very much appreciated. Thanks :)
    Edited by: DavidMilot on Oct 18, 2008 6:08 PM

    DavidMilot wrote:
    Not to be rude I just cannot copy and paste all my code into the forum out of fear of plagerism.I didn't mean for you to post all of your code. Just a small program that demonstrates the problem. This program would have 3 arraylists on it, 2 filled, one empty that would receive the other two. You combine them, print out the third and that's it.
    I could rename all my variables and method names but I unfortunately don't have time to do all that because I have 3 midterms coming in 3-4 days. This doesn't seem to be an easy fix just by giving out minimal code (which the names have been altered) but I still appreciate the effort. For now I tend to leave the code the way it is havingThe onus of effort here must be yours.
    newList.add(aList1)
    newList.add(aList2)
    It's not perfect but that's as close as I can get for now. Plus this assignment is due monday hehe. Feel free to continue giving me ideas to try out I plan to ask my TA monday before handing it in. Thanks again.I mainly wanted to see is if you are using addAll two add both aList1 and aList2. For some unknown reason in the code you posted before you didn't. Again, lord knows why.

  • How to combine integers with JTextFields?

    Hello
    I have 2 textFields and i want to add on each a integer
    I also have 3 buttons 1for the "+"function 2 for the "-" function and 3 for the "="
    function
    How can i put integers and make the above functions using (JTextFields which are working with Strings as far i know)without throwing me exception thread String needed?
    thanks

    Why not just set the text to whatever number you want (or have the user do it by typing in the JTextField), then use getText() to retrieve the text and do your operations on it?
    User enters stuff into textfields
    User hits "enter" (or whatever)
    Use JTextField.getText()
    Use Integer.valueOf(String)
    etcOr whatever floats your boat.

  • How can i combine an array of string and an array of integers ?

    i have an array of string data [to be used as header], and an array of multiple column integer vakues;i need them together in one file. 
    Am not able to combine them so that i can write them into a single file.
    Solved!
    Go to Solution.
    Attachments:
    string file input.txt ‏1 KB
    Test build_1.vi ‏13 KB

    There are a few ways you can do this.  What I recommend is:
    Open the file
    Use the Array to Spreadsheet String to turn your headers into a single string
    Write this to the file.
    Use the Array to Spreadsheet String to turn your numeric data into a single string
    Write this to the file.
    Close the file
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Merging two linked lists of integers that are sorted

    hey guys,
    i need to write a method to merge two linked lists of integers that are sorted into ascending order. the results should be a third linked list that is the sorted combination of the original lists.
    can someone help me start this? Basically, the method will be taking in two sorted linked lists of integers and merge them into one big sorted linked list.
    Im just looking to get some algorithm ideas and maybe one or two lines of pseudocode to get me started.
    thanks

    i can't destroy the original lists so im gonna need
    to create a new sorted list. then since both of the
    lists im using are sorted, i'll just have to copy one
    of them into the new list i created. Then i will get
    an item from the unused list and search that node in
    the new copied list and insert in appropriate
    position using the two Nodes...example(prev and
    curr).That can work. I'd probably do it by initializing a new list and compare the first items in each of the original lists, inserting the smaller in my new list and advancing to the next element in the original list from which I took the item, repeating the process until I copied each item from both original lists. Don't forget to take into account that you will reach the end of one list before the other.

  • An Average of a Count erroneously returns integers and not decimals

    I have a table which holds sales information showing the invoice number and the branch (e.g. 'New York', 'Boston', etc..)  that sold the items. Each row represents a product on an invoice. I am trying to find out the average number of lines per invoice
    for each branch. So my final result set might tell me that the 'New York' invoices had an average of 2.4 lines per invoice and the 'Boston' invoices had an average of 1.9 lines per invoice. Like this:
    New York, 2.4
    Boston, 1.9
    I've first written a subquery that counts the number of lines for each BRANCH & INVOICE combination for any date after 1/1/2015. Then I've put a query around that subquery which averages this count by Branch. The problem is, the entire query is only
    returning integers and not decimals. Why is this?
    Note that I tried casting the data type to DECIMAL and FLOAT but still get the same results.
    Here is the query:
    Select t1.Branch, cast(avg(t1.Count) as numeric(10,2))
    as Avg_Lines
    from
    (Select Branch, invoice, count(*) as Count
     from linprm
     where invdte>20150101
     group by Branch, invoice) t1
     group by t1.Branch

    To expand Scott's answer:
    Select t1.Branch, avg(cast(t1.Count as numeric(10,2)))
    as Avg_Lines
    from
    (Select Branch, invoice, count(*) as Count
    from linprm
    where invdte>20150101
    group by Branch, invoice) t1
    group by t1.Branch
    -- or
    Select t1.Branch, cast(avg(t1.Count) as numeric(10,2))
    as Avg_Lines
    from
    (Select Branch, invoice, cast(count(*) as numeric(10,2)) as Count
    from linprm
    where invdte>20150101
    group by Branch, invoice) t1
    group by t1.Branch
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • Formulas for Permutation and Combination??

    Hi All,
    I got a requirement to develop a Simulator for a chemical process.. In which ther will be some inputs given by the user for a process.. the output must be Optimus result or best result...
    I need to know.. is ther any standard for using Permutation and Combinations..
    Also is ther any feature to develop a simulation process??
    Thanks and Regards
    Aravindh Mani

    hi,
    _*FORMULA*_
    Permutation = nPr = n! / (n-r)!
    Combination = nCr = nPr / r!
    where,
                  n, r are non negative integers and r<=n.
                  r is the size of each permutation.
                  n is the size of the set from which elements are permuted.
                  ! is the factorial operator.
    Example:
    Example:Find the number of permutations and combinations: n=6; r=4.
      Step 1: Find the factorial of 6.
                6! = 6×5×4×3×2×1 = 720
      Step 2: Find the factorial of 6-4.
                (6-4)! = 2! = 2
      Step 3: Divide 720 by 2.
                Permutation = 720/2 = 360
      Step 4: Find the factorial of 4.
                4! = 4×3×2×1 = 24
      Step 5:Divide 360 by 24.
                Combination = 360/24 = 15
    The above example will help you to find the Permutation and Combination manually.
    hope this helps
    Regards
    RItesh J

  • How can I combine different pdf files in one?

    How can I combine different pdf files in one?

    Sara,
    It is not working. I wish to decline in having the pdf pack. How can I give up this purchase? I definitely do not want the Adobe PDF Pack anymore.
    Who do I have to contact or what do I need to do to cancel this purchase?
    Flávia
    Enviado do Email do Windows
    De: Sara.Forsberg
    Enviado: terça-feira, 6 de maio de 2014 14:59
    Para: Eu
    How can I combine different pdf files in one?
    created by Sara.Forsberg in Adobe PDF Pack - View the full discussion 
    Hi Flávia,
    Adobe PDF Pack is an online subscription--it definitely allows you to combine several files into one PDF file. For more information about PDF Pack, see Reliably Create PDFs, Convert PDFs, & Merge PDFs Online | Adobe PDF Pack. If you don't have the full version of Acrobat, this is a great solution for combining PDF files.
    However, if you're using Acrobat (not Adobe Reader), you combine files by following these steps:
    Open a PDF file that you want to add pages to.
    Click the Pages pane on the Tools panel (on the right side of the application).
    Click Insert From File, and choose the file that you want to combine with the PDF that you opened in step 1.
    Make any changes necessary in the Insert Pages dialog box--these settings determine where the new file will be inserted.
    Click OK.
    Please let me know how it goes.
    Best,
    Sara
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6358990#6358990
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Adobe PDF Pack by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • I have 3 different itunes accounts and would like to combine them into just one for all my devices, a macbook pro, an iphone 4S, an older IPOD, and a ver sion one Ipad. how can i do this on all devices ?

    i have 3 different itunes accounts and would like to combine them into just one for all my devices, a macbook pro, an iphone 4S, an older IPOD, and a ver sion one Ipad. how can i do this on all devices ?

    i had one for a long time, then when i got the ipad i didn't realize they would all still work under one so i set up the second one on that
    then when i got the new iphone i put in the info for the first and main one from my mac pro and it would not work at all, and i knew it was right, then it asked me to create a new one or i couldnt finish the setup
    hence why i have 3 now
    hard to believe you cannot combine into one
    oh well, i will just make them all accessible for all 3
    thanks

  • HT1203 My gifriend and I have separate iTunes accounts, we would like to combine them into one, is this possible?

    My girlfriend and I have separate iTunes accounts and would like to combine then so we can have all the same music and books on our iPads and iPhones. Is it possible to combine the two accounts or somehow sync hers to mine and just use one from now on?

    iTunes- How to share music between different accounts on a single computer
    iTunes- How to share music and video
    Understanding Home Sharing
    iTunes- Setting up Home Sharing on your computer
    iOS- Setting up Home Sharing on your device
    Do these help?

  • I have photos I want to group together in one album, but can't do this because some may have the same number. How can I combine them all into one album?

    I have photos I want to group together in one album, but can't do this because some may have the same number. How can I combine them all into one album? I was trying to move several albums onto a USB drive and it stated all other files exist at this location.  They are pictures taken at different times and have the same number I guess.

    In iPhoto albums may contain photos with the same file name - iPhoto handles that just fine
    If you are exporting them to move somewhere else use the sequential file name feature of export to give each file a unique name
    LN

  • HT4137 I have two itunes accounts, how can i combine them

    We have a IPOD and IPAD.. the music is under 1 account and all the apps are under a different account.  Can we combine them into one account so everything can be together.

    No

  • How do you Combine Pictures into one Photo

    I'm really re.tarded when it comes to this stuff.
    I want to take 4 pictures and combine them, making like a montage and I have no clue how to do that.
    Message was edited by: S.E.S.

    Welcome to the Apple Discussions. Did your computer happen to have come with OmniGraffle? It is an amazing application and can create a collage very easily like this one I made out of 96 photos.
    If it didn't come with your computer it's demo mode it will let you work with up to 10 items on a page.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto (iPhoto.Library for iPhoto 5 and earlier) database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger or later), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 6 and 7 libraries and Tiger and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.
    Note: There now an Automator backup application for iPhoto 5 that will work with Tiger or Leopard.

  • I have three different ipods with music on them and have had to replace our computer as it was in a fire. How can we combine the ipods into one ipod.

    We had to replace our computer due to a fire and lost many of the fiels which were on them. Many were music files for the ipods, we have thre. Also, do not have ID's and passwords to the iTunes store.
    How can we combine the information so that they are all in each one or at least compbine everything into one ipod?

    Just so you know the method suggested by Nelsonleee will cost your $29.95 USD, Yamipod is free.

Maybe you are looking for

  • Change payroll area in middle of the month

    Currently I had face a problem where this staff whose is reentering the company in the middle of the month. Before this he use payroll area XX, after he reenter the company in the middle of the month, the payroll area need to be change to AA. But the

  • Lightbox gallery issue

    Hi everyone, I have a problem with the thickbox gallery. Im using dreamweaver CS5. My thickbox gallery was working just fine. But since I added a slideshow at the top of my website The thickbox stopped working properly. Now everytime I click on a pic

  • Installed new cartridge and nothing prints on the paper...either black or white

    I installed new cartridges...installed and re installed them several times...ran all the scan doctors sw, re installed sw, aligned cartridges, cleaned heads....but my documents print blank pages.  HP support center says ink cartridges check out fine.

  • About UserDefined Fields..

    hello guys, I have the following requirement....in the AR Invoice i have created the following UDFs with the following Names--Billable Days,Absent Days,ManMonths....... about these fields the BillableDays field must be showing the no Of days in the c

  • IPod Touch wifi issue?

    My iPod Touch's wifi is playing up; When I got home today, the ipod picked up the wifi connection, with 2 bars signal, yet when I went on facebook and weather they both said 'update failed' and 'error' etc... The signs that there is no connection. Th