Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/21/17 11:33:53 (7 years ago)
Author:
pkimmesw
Message:

#2665 Testet Problems, Testet error functions, Small fixes, Created HL files

Location:
branches/PushGP/HeuristicLab.PushGP
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP

    • Property svn:ignore
      •  

        old new  
        11*.user
         2packages
         3TestResults
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/Grades.cs

    r15017 r15334  
    11namespace HeuristicLab.BenchmarkSuite.Problems {
     2  using System;
     3
    24  using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Integer;
    35  using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.String;
     
    68    private const string name = "Grades - Hard";
    79    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.";
    911
    1012    protected override string FileName { get { return fileName; } }
     
    1820        Name = Name,
    1921        Description = Description,
     22        ProgramExecutionBudget = 60000000,
    2023        Examples = CloneExamples(),
    2124        BestResult = 0,
    22         WorstResult = 25,
     25        WorstResult = 5000,
    2326        InputArgumentTypes = new[] { ExampleArgumentType.Integer, ExampleArgumentType.Integer, ExampleArgumentType.Integer, ExampleArgumentType.Integer, ExampleArgumentType.Integer },
    2427        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
     
    3942
    4043    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
    4148      return new Example {
    4249        InputArgs = input,
     
    4451        InputInteger = ExampleArgumentConverter.ConvertIntegers(input),
    4552        OutputPrint = output[0],
     53
     54        // help
     55        OutputChar = new[] { grade }
    4656      };
     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;
    4769    }
    4870  }
Note: See TracChangeset for help on using the changeset viewer.