cancel
Showing results for 
Search instead for 
Did you mean: 

Compiler Error - Metadata file 'System.Collections.Generic.dll' could not be found

PJNI
Level 2

Hi 

I am having difficulties getting this to run, any help would be most appreciated:

Global Code in c#

using System;
using System.Linq;
using System.Collections.Generic;

public static class MinimumValuesCalculator
{
public static List<int> CalculateMinimumValues(List<int> inputValues, int totalValue)
{
List<int> usedValues = new List<int>();
int remainingValue = totalValue;

// Sort the input values in descending order
inputValues.Sort((a, b) => b.CompareTo(a));

foreach (int value in inputValues)
{
if (value <= remainingValue)
{
// Add the value to the usedValues list
usedValues.Add(value);
// Subtract the value from the remainingValue
remainingValue -= value;
}

if (remainingValue == 0)
{
// If the remainingValue becomes zero, we have found the minimum values
break;
}
}

// If remainingValue is not zero, it means it's not possible to make up the total value
if (remainingValue != 0)
{
usedValues.Clear(); // Clear the usedValues list
}

return usedValues;
}
}

 

Here is the Code Stage Code

List<int> inputValues = InputParameters["InputValues"].Value as List<int>;
int totalValue = Convert.ToInt32(InputParameters["TotalValue"].Value);

List<int> usedValues = MinimumValuesCalculator.CalculateMinimumValues(inputValues, totalValue);

OutputParameters["UsedValues"].Value = usedValues;

1 REPLY 1

PJNI
Level 2

image.png