Task 1.3 How to make use of distinct

Moderator: Konzepte der Programmiersprachen

Janis
Neuling
Neuling
Beiträge: 4
Registriert: 27. Mai 2017 17:25

Task 1.3 How to make use of distinct

Beitrag von Janis » 25. Jan 2019 20:31

Hello, I have a (maybe rather strange) question regarding task 1.3.

In this task the goal is to implement the function combine2 which must have the same functionality as combine, using both distinct and merge.

I implemented a function that passes the test, but i noticed that it does not share the exact functionality of combine. Im not really sure how to explain this, since posting a solution isn't allowed. Let's take an example input, where my function has a different output that the original combine (even though test3 evaluates to true). The given function has the following output for the following input:

Code: Alles auswählen

combine [1,1,1] [1,1,1]
-> [1,1,1]
To be honest, I don't know how to achieve this kind of output while still using distinct, which removes repeating numbers from a list. Either I use distinct on the original lists, in which case I'm left with [1] and [1] to merge or I use it after merging, in which case I'm left with just [1]. The only way to get this output, is to somehow use distinct while merging. But at that point I can't exactly use my original two methods, can I?

Maybe I'm on the totally wrong track here. I hope you understand the problem Im having.

Janis
Neuling
Neuling
Beiträge: 4
Registriert: 27. Mai 2017 17:25

Re: Task 1.3 How to make use of distinct

Beitrag von Janis » 25. Jan 2019 20:36

Nevermind. I overlooked the requirement for the list to be strictly increasing. My bad.

Antworten

Zurück zu „Konzepte der Programmiersprachen“