Simon McNamara

Ranch Hand
since Nov 13, 2019
Cows and Likes
Cows
0
In last 30 days
0
Total given
0
Likes
2
0
Total given
0
Given in last 30 days
0
Scavenger Hunt
Ranch Hand Scavenger Hunt
Greenhorn Scavenger Hunt

Recent posts by Simon McNamara

Wow that's such a succinct solution. I don't know python very well, but I'll try my hand at translating that to java!
5 days ago
Thanks Piet, that was driving me bonkers.

I've returned to the question of building the set of all possible combinations (with "duplicates") as discussed earlier. I've started with some version of the pseudo code that Paul suggested.

For an example List = [5, 6, 7], I can get all possible combination of two elements with this:

So, obviously, I place a call to List.add() with two indices as arguments, so I'll only ever get combinations of two items. I'm now trying to generalize this to start by adding all combinations of 3 items, decrementing my list, adding all combinations of 2 items, and so on. However I'm having some trouble figuring out how to add a series of 3 indices. Any suggestions for this?
5 days ago
Paul,

On my way to a solution, I'm strangely confused.

I'm trying here to get all combinations of two lists, where the first list is the 1st dimension of the list and the 2nd list is the 2nd dimension of the list.

args = [ [ 1, 2 ], [8, 9] ]

Why doesn't this work?:

I'm getting:
[1, 2], [1, 2], [8, 9], [8, 9],

[1,8], [1,9], [2,8], [2,9]

I don't often work with Lists, maybe I'm missing something in the API.

5 days ago
Thanks Paul!

Yes, what you describe is what I'd like! What a name, huh?

Would anyone happen to know of an implementation of such an esoteric combination?

Many thanks,
6 days ago
Darn.

After some more googling, I think I can better describe what I want as all possible permutations of an array. From what I've seen, all permutations of some array [a, b, c] necessarily involves the many combinations of only 3-item arrays (each resulting array is 3-items long).

This may seem hackey, but perhaps I can retrieve those permutations, decrement my array by one object, compute those permutations, and so on, until I've exhausted my array. Then, I can mash all of the arrays together.

Unless one of you tries to stop me, I might just try this. Really though, if you suggests an easier solution, I'm all ears.

6 days ago
Hey Paul,

Yes, you've got it exactly. I do recognize that this is not a power set, strictly speaking. I thought perhaps this is a well-known problem of which I don't know the name!

6 days ago
Hello all,

Well, when it rains, it pours. When I find myself on code ranch, it's usually because I have 5 or 25 questions, not just 1! Here I go again for the 2nd time in 2 days!

I'm looking for a tidy way to assemble every possible combination for arguments I'm feeding to a test.

I have, for example, and array of integers from 4, 7 (inclusive): [ 4, 5, 6, 7 ]

I'd like to basically build the power set. I find lots of useful stuff on the web for building a power set from an array in java. However, I want to include [ 4, 5 ] AND [ 5, 4 ]. A typical power set omits these, as they're considered duplicate. My tests does different things with the 1st or the second item in that subset, so I want to preserve "duplicates".

My current code is:

This code is not mine, it's adapted from Matt McPeak here: https://stackoverflow.com/questions/5162254/all-possible-combinations-of-an-array

This code is great, but it doesn't allow duplicates ( it includes [5, 6] but not [6, 5]). Any feedback is welcomed. Does this problem go by a different name?

Many thanks,
6 days ago
Thanks for the feedback. Yes, I suppose it is rather verbose. I'll check out that link. Thanks for your help.
6 days ago
Indeed, but I can't control which methods a client puts into their class. If they call my code, it'll still execute in the correct order despite their deplorable java styling.
1 week ago
For crying out loud.

Somehow I forgot to account for the fact of upper case letters, even while I have a method with an upper case letter...!

If I change my comparison to the following, the method behaves correctly:

FROM THIS:

TO THIS:

Thank guys,
1 week ago
I'm attempting to write a method which returns an alphabetical list of Method objects given some arbitrary list of method objects. I cannot for my life figure out why my method keeps missing Method objects starting with 'A'. After methods starting with 'A', everything seems to work fine! Any feedback is much appreciated.

Here's my method to alphabetize method objects:

I'm running my method using a class with the following method names:

And I consistently see the Method BothNegNums() is first! After this, the list is correctly alphabetized (item 2 is 'absNonNeg', 'boo', etc).

I must be missing something simple since the behavior is correct after the 0th item. Thanks for taking a look.
1 week ago
Hello Code Ranchers,

I've got a real doosey for you tonight!

I've been working on the back end of my java swing program for a while. Since I've been away from window builder for so long (window builder in eclipse to edit swing GUI), something must have changed between then and now. Unfortunately, it's been so long that I don't remember my eclipse version when everything last worked well (~6 months ago). Anyway, when I try to add any component, I get the spinning wheel and eclipse stops responding. I have no errors.

To be specific; I select an object from the pallet, then I hover over my GUI. When the object transparency appears over the GUI, indicating the planned location, I select that location. The spinning wheel starts and never stops.

I'm running MacOS 10.15.6, eclipse 2019-12.

I've tried increasing the available memory with this:
https://crunchify.com/increase-eclipse-memory-size-to-avoid-oom-on-startup/

I thought this may have helped at first, but it definitely has not.

Any thoughts or suggestions are welcomed. I literally can't add any components right now. I'm slowly dying inside.

Thanks,
8 months ago
Hello,

Many thanks for the replies. I clicked about in the panel for, say, 7 to 10 hours between yesterday and today and I found my problem. The tabbed panel in the JPanel was making things a mess. My error log was propagating null pointer exceptions, but without any stack entry related to my GUI class. After I deleted and rebuilt the tabbed panel, those seem to be gone completely and I can click individual objects properly. I'm still getting pretty frequent "Unhandled event loop executions" while moving things about, but they don't seem to be doing much, so I'm carrying on.

Thanks,
11 months ago
Hello Code Ranchers,

I am using WindowBuilder in Eclipse to design a Swing GUI. I'm using one JPanel in a card layout. Within this card layout, I have a number of JPanels. Each of these have various buttons and text boxes.

My issue is editing the JPanels which belong to the Card Layout. For all of the JPanels except one, I can select the JPanel by name from the nested list. Window Builder brings that JPanel to the top. Once on the top, I can freely select individual components to edit on that JPanel.

However, for one JPanel in the Card Layout ("calibrationPanel", shown in the pictures), when I attempt to edit the components by clicking on them, it's as though the panel doesn't exist and my mouse selects objects from panels "under" the shown panel. This makes it difficult or impossible to determine if one label is jLabel1 or jLabel2, for example. I'm going bananas.

I'm using Eclipse 2019-12 with WindowBuilder "Last Good Build" from here: http://download.eclipse.org/windowbuilder/lastgoodbuild/ . I've also tried Eclipse 2020-3 with the same problem.

Any feedback is appreciated.
11 months ago
Hey Tim,

Thanks for posting about Preferences. I'll check that out. Seems like my solution detailed in my previous post is pretty similar to global preferences.

Many thanks,
11 months ago