public override void ReadInputFile() { using (FileHandler inputFile = new FileHandler(Global.IOMode.Input, true)) { try { firstSequence = inputFile.FetchLine(1).Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray(); } catch { throw new DynamicProgrammingException("In Longest Common Subsequence problem first line of the input text should always be a valid sequence seperated by blank space."); } try { secondSequence = inputFile.FetchLine(2).Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray(); } catch { throw new DynamicProgrammingException("In Longest Common Subsequence problem second line of the input text should always be a valid sequence seperated by blank space."); } } }
/// <summary> /// Read and Parse Input File /// </summary> public override void ReadInputFile() { using (FileHandler inputFile = new FileHandler(Global.IOMode.Input, true)) { try { lengthOfCut = int.Parse(inputFile.FetchLine(1)); } catch { throw new DynamicProgrammingException("In Rod-Cutting problem first line of the input text should always be a valid number which represent number of cuts to make."); } try { costs = inputFile.FetchLine(2).Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray(); } catch { throw new DynamicProgrammingException("In Rod-Cutting problem second line of the input text should always be the array of cost (number) seperated by blankspace"); } } }
/// <summary> /// Read and Parse Input File /// </summary> public override void ReadInputFile() { using (FileHandler inputFile = new FileHandler(Global.IOMode.Input, true)) { try { lengthOfCut = int.Parse(inputFile.FetchLine(1)); } catch { throw new DynamicProgrammingException("In Rod-Cutting problem first line of the input text should always be a valid number which represent number of cuts to make."); } try { costs = inputFile.FetchLine(2).Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray(); } catch { throw new DynamicProgrammingException("In Rod-Cutting problem second line of the input text should always be the array of cost (number) seperated by blankspace"); } } }
public override void ReadInputFile() { using (FileHandler inputFile = new FileHandler(Global.IOMode.Input, true)) { try { firstSequence = inputFile.FetchLine(1).Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray(); } catch { throw new DynamicProgrammingException("In Longest Common Subsequence problem first line of the input text should always be a valid sequence seperated by blank space."); } try { secondSequence = inputFile.FetchLine(2).Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray(); } catch { throw new DynamicProgrammingException("In Longest Common Subsequence problem second line of the input text should always be a valid sequence seperated by blank space."); } } }