Menu
CoddyTech

Recap: Record Readings

Lesson 17 of 48 in Coddy's Dart for C# Developers course.

challenge icon

Challenge

Easy

Implement records(List<int> values): retain the first value and each later value strictly larger than every earlier one. Do not change input. Output comma-separated records or empty. Input is zero or more integers from -100 to 100.

Do not print from editable files. The supplied exercise.dart parses input and returns output; the locked driver independently probes the public APIs and prints the result with one newline.

Your code goes in functions.dart, exercise.dart. main.dart holds the supplied input/output code and cannot be edited.

Try it yourself

import 'dart:io';
import 'dart:convert';
import 'exercise.dart';
import 'functions.dart';
void check(bool condition){if(!condition)throw StateError('Public API contract failed');}
Future<void> main() async {
final raw=await stdin.transform(utf8.decoder).join();
final input=raw.replaceFirst(RegExp(r'\r?\n$'),'');
check(records([2,1,3,3,4]).join(',')=='2,3,4');
stdout.writeln(solve(input));
}

All lessons in Dart for C# Developers

Practice on your own: Online Dart compiler