Skip to content

Commit

Permalink
Add constructor for creating InputUtil from multiline String
Browse files Browse the repository at this point in the history
  • Loading branch information
dumazy committed Dec 1, 2023
1 parent a5ae181 commit 08b1831
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions utils/input_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ class InputUtil {
InputUtil(int day)
: _inputAsString = _readInputDay(day),
_inputAsList = _readInputDayAsList(day);

/// Reads the entire input contents as one String.
/// This is useful for parsing the test input.
///
/// Example:
/// ```dart
/// final input = InputUtil.fromMultiLineString('''
/// two1nine
/// eightwothree
/// abcone2threexyz
/// xtwone3four
/// 4nineeightseven2
/// zoneight234
/// 7pqrstsixteen
/// ''');
/// final lines = input.getPerLine();
InputUtil.fromMultiLineString(String input)
: _inputAsString = input,
_inputAsList = input.split('\n');

final String _inputAsString;
final List<String> _inputAsList;

Expand Down

0 comments on commit 08b1831

Please sign in to comment.