Piet Souris

Saloon Keeper
+ Follow
since Mar 08, 2009
Merit badge: grant badges
Forum Moderator
Piet Souris currently moderates these forums:
Netherlands
Cows and Likes
Cows
Total received
207
In last 30 days
1
Total given
148
Likes
Total received
1144
Received in last 30 days
17
Total given
173
Given in last 30 days
6
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Piet Souris

What do you mean by 'generalized solution'?
I don't use regex much, and if I do I always have to read a tutorial first. Can you explain what that regex means?

Liutauras Vilda wrote:(...) and then...
Piet - "No particular problems, exercise 7 was more tedious than difficult."  <--


Just looked it up. I have absolutely no clue as to what I was doing there.
Hmm.... again not difficult, but with a snag. I created a Map<String, File>, in order to be able to look up a file or directory given the name. That worked perfectly in the given test, but failed for the real thing. I thought all names were unique... be warned.
hi Kate,

welcome to the Ranch and enjoy the stay!

One of the many ways is for instance:
1 day ago
Solved day 5.

Again easy, but a bit tricky, it was easy to make some mistakes, like forgetting to skip some elements and to re-initialize the stacks between the first and the second part. But it was again fun.

I did the input manually, by far the fastest way, I think. So my input-routine for the test looked like:
It sure is tricky. When determining the files in the methods themselves, I used for each of the methods

but for your method, I also sorted the list with .sorted(), but it differed also between

and
3 days ago
Just read the exercise. Indeed the problem is the inputfile. Three strategies come to mind: using a regex to determine the position of each letter, the positions of the letters are fixed, so require just some counting, and typing the piles into your code, which is probably the quickest way. Won't have time until this afternoon, though.

Junilu Lacar wrote:@Piet I was looking at your Day 1 solution on GitHub.

Regarding this:

Do you need .boxed() on line 49? Doesn't mapToInt() already give you an IntStream?


An IntStream only has the sorted-method, without a Comparator. But now I wonder if when using just 'map' instead of 'mapToInt' will give me a List<Integer> straightaway. Gonna give it a try!

Just tried it:

works fine, even though getSumOfCalories() returns an int. Wonderful, that autoboxing!

Junilu Lacar wrote:@Piet: was looking at your Day 1 solution -- just want to point out that singular of Elves is just Elf.


Thanks! Just like in Dutch then: elf - elven
Be careful with what you wish... one day you might get it (and that'll be sooner rather than later)
hi Carey,

yes, I could have expected a performance test!

One remark though: in your Carey-test you create a list ar, that gets sorted. That means that from try 2, the argument-array is already sorted, and that saves a lot of time. I adjusted the test in two ways: one where each list is created in the method itself, and two where I create a general list, and in your method I take a copy and sort that. That gives quite a difference.

But the way to the outcome is much more interesting than the corresponding performance. and OP has quite a few solutions now. Hope he likes it.
4 days ago
Indeed easy again. But we haven't seen the last of it yet.... that hint to "longer numbers ...456...." probably means misery awaiting.

I used a record called Range, and I wanted to give it a constructor with a String parameter of the form "3-6". but I could not get that to work, some error about something being not canonical or likewise. So I added a static method Range of(String s), and that worked.

Java, of course.

edit: github
Indeed, nice and very readable. Here are two other ways that are O(n):
4 days ago