Challenge of lists πŸ˜΅β€πŸ’«

Hello, I have a question that can be a challenge for many people.
We have 3 lists:

(2 2 2 3 3 1 1)
(54 300 155 158 320 240 270)
(7 5 12 18 2 1 9)

All lists have 7 elements.

Create a new list for each number in the first list without repeating itself, containing the number and the sum of the second list in case the index of the first list matches its number, minus the sum of the numbers in the third list in case the index of the first list matches its number.

The result should be:
(1 500) //explanation (240+270) - (1+9)
(2 485) //explanation (54+300+155)-(7+5+12)
(3 458) //explanation (158+320)-(18+2)

A nice task for a homework…
In case you need some help, let us know what you have tried and show us a screenshot of your relevant blocks

Taifun

Sure.

To solve it, I used the ListUtils extension:

https://community.kodular.io/uploads/short-url/v788fcoznL3iyAFhXluagnOJivx.aix

from the developer @The_K_Studio, to whom I send my thanks.

To start, I have a list of lists:
((2 2 2 3 3 1 1) (54.12 300 155 158 320 240 270) (7 5 12 18 2 1 9))

  1. I select the unique numbers from the first list
  2. I group the results of the 3 lists based on the coincidence of the next 2 lists with the index of the first list and create a list with this grouping ((1 2 3) (4 5) (6 7))
  3. For each 1 of the numbers in the first list, I add the indexes of the second and third lists and subtract the indexes between them.

2 Likes

You don’t Need Any kind of Extensions for the Challenge. You can do it Without Them

Surely, you would like to share your solution, surely it helps us understand how to implement new solutions.

Greetings and Happy Holidays.

Ya I was not on Creator at that time Here you go @micaot :

Results:



@micaot is is correct ?

Yes, the result is correct, every time you press the button it gives you the result of one of the 3 possibilities in list 1.

I like your solution and it makes the use of any extension unnecessary, although it is true that more variables must be declared with this method.

Congratulations on your solution and thanks for your contribution.

All the best.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.