Changeset 15334 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/Grades.cs
- Timestamp:
- 08/21/17 11:33:53 (7 years ago)
- Location:
- branches/PushGP/HeuristicLab.PushGP
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP
- Property svn:ignore
-
old new 1 1 *.user 2 packages 3 TestResults
-
- Property svn:ignore
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/Grades.cs
r15017 r15334 1 1 namespace HeuristicLab.BenchmarkSuite.Problems { 2 using System; 3 2 4 using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Integer; 3 5 using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.String; … … 6 8 private const string name = "Grades - Hard"; 7 9 private const string fileName = "Grades.csv"; 8 private const string description = "Given 5 integers, the first four represent the lower numeric thresholds for achieving an A, B, C, and D, and will be distinct and in descending order. The fifth represents the student’s numeric grade.The program must print Student has a X grade., where X is A, B, C, D, or F depending on the thresholds and the numeric grade.";10 private const string description = "Given 5 integers, the first four represent the lower numeric thresholds for achieving an A, B, C, and D, and will be distinct and in descending order. The fifth represents the student’s numeric grade. The program must print Student has a X grade., where X is A, B, C, D, or F depending on the thresholds and the numeric grade."; 9 11 10 12 protected override string FileName { get { return fileName; } } … … 18 20 Name = Name, 19 21 Description = Description, 22 ProgramExecutionBudget = 60000000, 20 23 Examples = CloneExamples(), 21 24 BestResult = 0, 22 WorstResult = 25,25 WorstResult = 5000, 23 26 InputArgumentTypes = new[] { ExampleArgumentType.Integer, ExampleArgumentType.Integer, ExampleArgumentType.Integer, ExampleArgumentType.Integer, ExampleArgumentType.Integer }, 24 27 OutputArgumentTypes = new[] { ExampleArgumentType.Print }, … … 39 42 40 43 protected override Example ParseExample(string[] input, string[] output) { 44 char grade; 45 if (!GetGrade(output[0], out grade)) 46 throw new InvalidOperationException("Unable to parse grade."); 47 41 48 return new Example { 42 49 InputArgs = input, … … 44 51 InputInteger = ExampleArgumentConverter.ConvertIntegers(input), 45 52 OutputPrint = output[0], 53 54 // help 55 OutputChar = new[] { grade } 46 56 }; 57 } 58 59 public static bool GetGrade(string str, out char grade) { 60 const string start = "Student has a "; 61 62 if (str.StartsWith(start) && str.Length > start.Length) { 63 grade = str[start.Length]; 64 return true; 65 } 66 67 grade = default(char); 68 return false; 47 69 } 48 70 }
Note: See TracChangeset
for help on using the changeset viewer.