Piet Souris

Master Rancher
+ Follow
since Mar 08, 2009
Netherlands
Cows and Likes
Cows
Total received
105
In last 30 days
7
Total given
71
Likes
Total received
541
Received in last 30 days
11
Total given
54
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Piet Souris

hi Vincent,

this question was raised before. Have a look at this topic:
same question
Just solved day 8, I had no time yesterday. Reconstructed the Tree by using a mixture of iteration and recursion. The code worked beautifully for the example given, but I was plagued by a StackOverflow in the real thing. Fortunately, the bug was easy to spot. Part B was very easy.

How do you increase the Stack size? I tried java -Xss1024M, but still got the same overflow error, so that did not seem to work.

Just had a look at day 9. Looks a bit tedious, with all that marbles and placement rules. We'll see.

Baktha Elumalai wrote:How soon convert hashmap<String, Object> into map<String , List<Object>>

Thanks in advance


It is possible, but since the keys in a HashMap are unique, the List<Object> would only contain one element: the Object. So, it wouldn't make much sense.

Question: why do you have, in your opening post, an ArrayList<HashMap>? Wouldn't just a HashMap be sufficient?

Lastly, if you have a Map<String, Object> map and you want to sort the keys, burt not the values, then it is relatively simple. For instance, to sort the keys, you could do:

Can you create from this set and the values of the map a new HashMap?
3 days ago
What a nightmare! Spent the whole evening looking for a bug in part B. Couldn't find it, made a mess of my code trying everything, hairs turned grey from the misery, just found it.
I had:

Still can't believe it.... self confidence = Integer.MIN_VALUE;

Frits Walraven wrote:Although I haven't looked at the puzzles, but I just enjoy reading your posts. It must be good fun.

All of you deserve a Cow!


Thanks, Frits!
Was a bit late, today. And the fact that I had a .flatMap and a .filter in the wrong order (hard to find) didn't help.

Anyway, if you want to practise Maps and all the juggling that can come with it, then this day 6 is your chance!

To make a distinction between a normal Point and a data (input) Point, I created a PietsPoint extends Point, that only has two constructors referring to super. Don't know if that is handy, but it made the Maps a little more comprehensible.

Piet Souris wrote:Some members are not only extremely speedy, but have code that is even shorter than Scala. Amazing.


hi Michael,

welcome!

My remark was about your Perl (?) script. I don't speak Perl and I didn't understand a bit of it, but it was mighty short!

@All
I did probably the same as Stephan, only I used a StringBuilder. The whole program (reading the input, and solve parts A and B) took around 0.77 seconds.

That Tim is becoming a nuisance, closing the gap more and more....
And the Yankees are a legue too far for us mere mortals...

Oops, I got lucky.

I determined a List<Integer> sleepingMinutes from "falls asleep" to "wakes up" as

but I forgot to do 'map(i -> i % 60)' right after '.range'. So I got lucky that wake up always is in the same minute as falls asleep.
hmmm.... not so easy day 4, a little tedious too. Used many Maps and Comparators<Map.Entry>. Made me feel as if I was doing some heavy coding in SAS.

Some members are not only extremely speedy, but have code that is even shorter than Scala. Amazing.
Slightly more general is to have a variable currentShape of type Shape.
If a menu Item is clicked, then set currentShape to the Shape that has been clicked.

In your implementations of Shape (myLine, myRectangle, MyEllipse, MyCurvedLine, ...) let the implementation itself handle the mouse events. That means that you can have many different Shapes, where each Shape knows how to deal with MouseEvents. Something like

6 days ago
Day 3: a little more involved, but a nice one!
hi Jim,

in your Shape class, the variable 'myColor' is only re-evaluated when you invoke the method 'setColor' of the Shape class.
As long as you do not invoke that method, myColor will remain what it is (if even initialized). So, before invoking 'getColor()', first invoke the Shape method 'setColor()'.

Note: do not confuse the method 'g.setColor' with the setColor method of the Shape class.

But why doing so complicated? Why not make the Color list a member of the Shape class (even static if you wish), and in your 'getColor()' method just return a random Color from that list. You could add a Random 'random' as field to your Shape class.
1 week ago
That is because the laptop is my wife's (she is called Sylvia). A couple of years ago I bought her this laptop, then with 64-bit Windows 7. My old PC had 32 bit Windows XP, and when I needed Java8, I confiscated her laptop...

In NetBeans, the template for a new class was 'author: Sylvia', but I changed that to 'author: Piet'. Now it seems to have returned. Must have a look into that...

By the way: in exercise 2B I used an array to circumvent a limitation in the Java Stream. People criticised me for that, I just updated it to use an IntStream. And I managed to shorten the code by one line!

Sofar it has been easy. Waiting for the blow to come....

And there are some very fast members also busy. Reaching the top will be nigh impossible.... so my immediate target is to keep you under me    
(I would not accept that, if I were you, who the f*** does that Souris think he is)
Thanks, Liutauras!

Usually I check my replies, when it comes to code, in my IDE before replying, and the first time I do not test it, I go wrong.... that'll teach me! And with Campbell, you stand no chance of getting away with it    
hi Bart,

my mistake. Since you are comparing two Integers (and thus NOT two ints) 'o1 == o2' will probably be false, since o1 and o2 are probably two different objects, even though their value may be the same. So I should have said:
Check it for yourself: