Adventofcode.com

adventofcode.com is an annual challenge to do various programming problems, in any language. I tried the first one and it was pretty easy to do in Easy Data Transform.

advent-of-code.transform (4.7 KB)

Can anyone do it in less transforms (without using the Javascript transform)?

Easy Data Transform is not intended to be a full fledged programming language, so it may not be possible to do all the questions. But we would be curious to know how many it can do, if anyone feels like trying it.

The second question is a more involved, but also doable.

advent-of-code-2.transform (8.2 KB)

I expect it is possible to do it in less transforms.

Here it is.

Transform file.
Advent_of_Code.transform (3.5 KB)

2 Likes

Very good. Your solution is better.

1 Like

Here it is.

Transform file.
Advent_of_Code2.transform (6.6 KB)

2 Likes

Oops. I missed the last step.

Can anyone do it less?

Here is day 4 solution

Transform file.
Advent_of_Code4.transform (7.6 KB)

1 Like

Did you have a go at day 3?

@Anonymous
I managed it in 12 without looking at your answer.

advent-of-code-day-4.transform (7.7 KB)

I have a feeling there is a way to do it in less. Maybe by pivoting the pivot?

I could have done it in several transforms less if there was some sort of Formula transform. Or with a simple Javascript transform.

True, since we cannot use JavaScript it is hard to do simple calculations and true the transform use would be less.

Here updated solution with 12 transforms which shows the original cards, which were the matching numbers, total match and the points.

Transform file.
Advent_of_Code4.transform (7.2 KB)

As for Day 3, I had a look at it, and to solve it, I need to know which transform, can I use to get the starting position of a string with in a string? As I could not find one or you can tell which transforms could be used to achieve this?

1 Like

I don’t think that is at possible at present, without using the Javascript transform. However it shouldn’t be hard to add to Calculate 2 extra operations:

  • indexOf - Returns the index position of the first occurrence of the string2 in string1. Returns -1 if string2 is not found.
  • lastIndexOf - Returns the index position of the last occurrence of the string2 in string1. Returns -1 if string2 is not found.
1 Like

That would be a nice addition to Calculate transform.

1 Like

In the meantime you can use Javascript string.indexOf():

I was not using JavaScript, because you mentioned in your first post that all solutions should be without using JavaScript transform.

Otherwise it becomes easy and less transformation for the previous solutions as well.

I think using Javascript is ok if it is impossible otherwise. ;0)

nasty suggestion to get the position of a string in a string:
use split column and use the searched string as delimiter. Then you can calculate the length of the first resulting column. This plus 1 is the start position of the string within the longer string.

Good to have you join us, here is the string in question

467..114..
...*......
..35..633.
......#...
617*......
.....+.58.
..592.....
......755.
...$.*....
.664.598..

Can you get the position for the numbers and symbols #*+$ ? without using JavaScript transform.

To read more on it, here is the link to Day 3 problem.

I think @Olaf’s impressively nasty hack works.

nasty-indexof.transform (3.5 KB)

You can use a regex for the split:

image

But to call it inelegant would be something of an understatement! :face_vomiting:

Ps/ Index is 0 based.

1 Like

IndexOf and LastIndexOf will be available in Calculate in the next release.

2 Likes

indexof and lastindexof are now available. Please see:

1 Like