Piet Souris

Bartender
+ Follow
since Mar 08, 2009
Forum Moderator
Piet Souris currently moderates these forums:
Cows and Likes
Cows
Total received
182
In last 30 days
0
Total given
126
Likes
Total received
1003
Received in last 30 days
9
Total given
126
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Piet Souris

Well, I always use doubles, that is not a problem. What I sometimes find a problem around here, is that personal opinions are being sold as if they were the truth, the whole truth and nothing but the truth.
4 days ago
Besides, if you use Processing (see Processing.org) then you notice that floats are standard, and I've seen no example whatsoever where that leads to any problem at all.
4 days ago
@Carey,

as I wrote to Tangara in one of my replies:

"No, all this is not necessary, your way is as good as mine, but I find my way more comfortable."

As I said, I hate nested index loops, like I hate incomprehensible cli-commands, so I was only showing a way that I find easy.

And your comment about optimizing made me have another think. Indeed I do some redundant checking. I have in my Matrix-class a method 'Matrix getMinorMatrix(int[][] a, int skipRow, int skipCol), and so to eliminate unnecessary checking, I could have this method:

But admitted, that tends to pure hobbyism!

@Jesse
I've never been involved as a professional programmer, albeit I used things like Basic, C and Java at home, and Excel, VBA and R in my job. So I am not hindered by any professional standard there may be, I am as free as a bird to follow any convention I like, even self-made conventions!
6 days ago

Carey Brown wrote:

Piet Souris wrote:for me the advantage of using Streams is that is makes things much more comprehensible.

Not comprehensible if you don't know what getColumn() is.


Does a person exist who is working with matrices and has no clue what the method 'getColumn' means?

Carey Brown wrote:Can this be refactored to take advantage of the optimization I mentioned?


I stick to

But my point was to give an alternative to nasty nested index loops. Perhaps I was not clear enough in my writing.
6 days ago
And to add to all previous repliers: a way to get both 'in Pooler" and "in Threader" printed is to override the run-method in Pooler as follows:
hi Tangara,

for me the advantage of using Streams is that is makes things much more comprehensible. If there is anything I hate then it is using nasty nested index-loops.

Now, if you have a 2D array 'a' in java, then it is very easy to acces the rows of a. For instance, a[2] will give you the third row. Unfortunately, there is no equivalent easy way to acces the columns. To acces the columns, it is required that matrix a is rectangular. i.e. all rows have the same length. I have a method in my library called 'int[] getColumn(int[][] a, int index)'
and it goes:

and so I avoid that nasty index juggling as much as possible, and I do not need to worry about the dimensions of my result-array. And as far as symmetric concerns, a Matrix is symmetric if row 1 equals column 1, row 2 equals column 2, et cetera.

No, all this is not necessary, your way is as good as mine, but I find my way more comfortable.
6 days ago
A Matrix can only be symmetric if that Matrix is square. And in that case you can avoid all those nested ifs with:
6 days ago
Carey is right, you will have a resizing problem.

But you can use this.getWidth() and this.getHeight() in your menubar-class For instance:

and to get this working from the start, use for instance:
6 days ago
According to your Comparator, "c" and "d" are considered the same, since their lengths are 1. So it finds "c" at location 0.
I would put the addGenre method in the Genre enum.
Make a static Map<Character, Genre> in Genre, and initialize it.
Add a static method

and then you can find your enum by using
1 week ago
Since Einstein we know that almost everything is relative. So they may have seen 'earth from above', we've seen a 'rocket from below', and that free of charge.
1 week ago
I did, PAUL, but still the lines do not line up at the end. In my IDE, the output lines up as it should.
1 week ago
Confusing topic. Op's code in his opening post is almost correct. Instead of the line (68)

it sould either be

or

and for your latest question:how about
1 week ago
A strategy could be:

let the String 'word' be "######", the number of repeats 100, the separator 'sep' "  " (two spaces) and the linelength 90.

Now, form a String 'longString' containing 100 times the word, and in between two consecutive words the sep. That makes longString 798 characters long.

Now, the string 'word' + 'sep' has length 8 and fits 11 times in the given linelength of 90. So we could as our first line, print the first 88 characters of longString. But then that line would end in two spaces, which is undesirable. So, from 88 we subtract the lenght of 'sep', giving 86.

And finally, we split our longString into substrings of length 86, and eventually a rest substring. In effect, I am adjusting the given linelength from 90 to 86.

For the given values, you would get this output (unfortunately, I cannot choose a monospaced font, so the lines look ragged)

######  ######  ######  ######  ######  ######  ######  ######  ######  ######  ######
 ######  ######  ######  ######  ######  ######  ######  ######  ######  ######  ####
##  ######  ######  ######  ######  ######  ######  ######  ######  ######  ######  ##
####  ######  ######  ######  ######  ######  ######  ######  ######  ######  ######  
######  ######  ######  ######  ######  ######  ######  ######  ######  ######  ######
 ######  ######  ######  ######  ######  ######  ######  ######  ######  ######  ####
##  ######  ######  ######  ######  ######  ######  ######  ######  ######  ######  ##
####  ######  ######  ######  ######  ######  ######  ######  ######  ######  ######  
######  ######  ######  ######  ######  ######  ######  ######  ######  ######  ######
 ######  ######  ######


I made these methods:
and

1 week ago