parent
eb97a91ede
commit
06c418021a
@ -0,0 +1 @@
|
|||||||
|
analysis_options.yaml
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
# Files and directories created by pub
|
||||||
|
.dart_tool/
|
||||||
|
.packages
|
||||||
|
# Remove the following pattern if you wish to check in your lock file
|
||||||
|
pubspec.lock
|
||||||
|
|
||||||
|
# Conventional directory for build outputs
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Directory created by dartdoc
|
||||||
|
doc/api/
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
## 1.0.0
|
||||||
|
|
||||||
|
- Initial version, created by Stagehand
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
A sample command-line application.
|
||||||
|
|
||||||
|
Created from templates made available by Stagehand under a BSD-style
|
||||||
|
[license](https://github.com/dart-lang/stagehand/blob/master/LICENSE).
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
import 'package:aoc2020/aoc2020.dart';
|
||||||
|
import 'package:args/args.dart';
|
||||||
|
|
||||||
|
// import 'package:aoc2020/aoc2020.dart' as aoc2020;
|
||||||
|
|
||||||
|
// ignore: always_declare_return_types
|
||||||
|
ArgResults argResults;
|
||||||
|
void main(List<String> arguments) {
|
||||||
|
final parser = ArgParser()
|
||||||
|
..addOption('day', abbr: 'd', help: 'Select the day') //, callback: (day) => print('the day is aoc202012$day'))
|
||||||
|
..addFlag('list', abbr: 'l', help: 'List available days', callback: (_) => aoc2020.list());
|
||||||
|
argResults = parser.parse(arguments);
|
||||||
|
// final paths = argResults.rest;
|
||||||
|
// print('paths: ${paths}!');
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
import 'package:aoc2020/aoc20201201.dart';
|
||||||
|
import 'dart:mirrors';
|
||||||
|
|
||||||
|
import 'package:aoc2020/aocbase.dart';
|
||||||
|
|
||||||
|
class aoc2020 {
|
||||||
|
final String dayParam;
|
||||||
|
final String subdayParam;
|
||||||
|
|
||||||
|
aoc2020({this.dayParam, this.subdayParam});
|
||||||
|
|
||||||
|
static List<AOCBase> aocDays = [
|
||||||
|
AOC20201201(),
|
||||||
|
];
|
||||||
|
|
||||||
|
static void list() async {
|
||||||
|
print('Days available:');
|
||||||
|
for (var index = 0; index < aocDays.length; index++) {
|
||||||
|
var aocReflect = reflect(aocDays[index]);
|
||||||
|
var classString = aocReflect.toString().split("'")[1];
|
||||||
|
|
||||||
|
print('${index + 1} : ${classString ?? 'null'}');
|
||||||
|
var myclass = aocDays[index];
|
||||||
|
await myclass.a(test: true);
|
||||||
|
await myclass.b(test: true);
|
||||||
|
print('$index : ${myclass.answerA ?? 'null'}');
|
||||||
|
print('$index : ${myclass.answerB ?? 'null'}');
|
||||||
|
await myclass.a();
|
||||||
|
await myclass.b();
|
||||||
|
print('$index : ${myclass.answerA ?? 'null'}');
|
||||||
|
print('$index : ${myclass.answerB ?? 'null'}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
import 'package:aoc2020/aocbase.dart';
|
||||||
|
import 'package:aoc2020/model/readdata.dart';
|
||||||
|
// import 'dart:mirrors';
|
||||||
|
|
||||||
|
class AOC20201201 extends AOCBase {
|
||||||
|
@override
|
||||||
|
Future<void> a({bool test}) async {
|
||||||
|
var filename = (test ?? false) ? classStringTest : classString;
|
||||||
|
print("Running 'a'" + ((test ?? false) ? 'with test' : ''));
|
||||||
|
print('$classStringTest');
|
||||||
|
var mylist = await ReadData.readFileNum(filename);
|
||||||
|
print(mylist);
|
||||||
|
answerA = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> b({bool test}) async {
|
||||||
|
print("Running 'b'");
|
||||||
|
answerB = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
import 'dart:mirrors';
|
||||||
|
|
||||||
|
abstract class AOCBase {
|
||||||
|
num answerA;
|
||||||
|
num answerB;
|
||||||
|
String get classString => reflect(this).toString().split("'")[1];
|
||||||
|
String get classStringTest => classString + 'test';
|
||||||
|
|
||||||
|
Future<void> testa() => a(test: true);
|
||||||
|
Future<void> testb() => b(test: true);
|
||||||
|
Future<void> a({bool test});
|
||||||
|
Future<void> b({bool test});
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
print('''
|
||||||
|
classString = $classString
|
||||||
|
answerA = $answerA
|
||||||
|
answerB = $answerB
|
||||||
|
''');
|
||||||
|
return super.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,200 @@
|
|||||||
|
1993
|
||||||
|
1715
|
||||||
|
1997
|
||||||
|
1666
|
||||||
|
1676
|
||||||
|
1830
|
||||||
|
1203
|
||||||
|
1800
|
||||||
|
1125
|
||||||
|
1191
|
||||||
|
1902
|
||||||
|
1972
|
||||||
|
1471
|
||||||
|
1137
|
||||||
|
2003
|
||||||
|
1250
|
||||||
|
1548
|
||||||
|
1070
|
||||||
|
1152
|
||||||
|
2004
|
||||||
|
1127
|
||||||
|
1111
|
||||||
|
1898
|
||||||
|
1848
|
||||||
|
1934
|
||||||
|
1236
|
||||||
|
1704
|
||||||
|
1950
|
||||||
|
1387
|
||||||
|
1713
|
||||||
|
1214
|
||||||
|
1266
|
||||||
|
1114
|
||||||
|
1089
|
||||||
|
1677
|
||||||
|
1207
|
||||||
|
1341
|
||||||
|
1689
|
||||||
|
1772
|
||||||
|
1901
|
||||||
|
1932
|
||||||
|
1645
|
||||||
|
1285
|
||||||
|
1884
|
||||||
|
883
|
||||||
|
1291
|
||||||
|
1543
|
||||||
|
1455
|
||||||
|
1213
|
||||||
|
1088
|
||||||
|
1784
|
||||||
|
1506
|
||||||
|
1879
|
||||||
|
1811
|
||||||
|
1880
|
||||||
|
994
|
||||||
|
1021
|
||||||
|
1585
|
||||||
|
1662
|
||||||
|
1683
|
||||||
|
1071
|
||||||
|
1643
|
||||||
|
1754
|
||||||
|
1389
|
||||||
|
1124
|
||||||
|
1820
|
||||||
|
1168
|
||||||
|
1875
|
||||||
|
1017
|
||||||
|
1180
|
||||||
|
1375
|
||||||
|
1359
|
||||||
|
1311
|
||||||
|
1357
|
||||||
|
1501
|
||||||
|
1719
|
||||||
|
1584
|
||||||
|
1609
|
||||||
|
1977
|
||||||
|
1786
|
||||||
|
1232
|
||||||
|
1263
|
||||||
|
1748
|
||||||
|
1664
|
||||||
|
1693
|
||||||
|
1766
|
||||||
|
1598
|
||||||
|
1053
|
||||||
|
1277
|
||||||
|
1466
|
||||||
|
1877
|
||||||
|
1844
|
||||||
|
1829
|
||||||
|
1165
|
||||||
|
1606
|
||||||
|
1298
|
||||||
|
1963
|
||||||
|
1873
|
||||||
|
1911
|
||||||
|
1729
|
||||||
|
1418
|
||||||
|
1372
|
||||||
|
1777
|
||||||
|
1371
|
||||||
|
1588
|
||||||
|
1329
|
||||||
|
1029
|
||||||
|
1931
|
||||||
|
1115
|
||||||
|
1810
|
||||||
|
1595
|
||||||
|
1237
|
||||||
|
1282
|
||||||
|
1838
|
||||||
|
1642
|
||||||
|
1937
|
||||||
|
1343
|
||||||
|
1578
|
||||||
|
1425
|
||||||
|
1814
|
||||||
|
1690
|
||||||
|
1129
|
||||||
|
1321
|
||||||
|
1174
|
||||||
|
1863
|
||||||
|
1405
|
||||||
|
1066
|
||||||
|
1220
|
||||||
|
1780
|
||||||
|
1410
|
||||||
|
1156
|
||||||
|
1991
|
||||||
|
1568
|
||||||
|
1368
|
||||||
|
99
|
||||||
|
1750
|
||||||
|
1280
|
||||||
|
1400
|
||||||
|
1601
|
||||||
|
1804
|
||||||
|
1363
|
||||||
|
1613
|
||||||
|
1252
|
||||||
|
1434
|
||||||
|
1094
|
||||||
|
1867
|
||||||
|
1542
|
||||||
|
1093
|
||||||
|
1926
|
||||||
|
1251
|
||||||
|
1348
|
||||||
|
689
|
||||||
|
1441
|
||||||
|
1913
|
||||||
|
1969
|
||||||
|
1409
|
||||||
|
1201
|
||||||
|
1459
|
||||||
|
1110
|
||||||
|
1452
|
||||||
|
1051
|
||||||
|
1860
|
||||||
|
1346
|
||||||
|
1537
|
||||||
|
1060
|
||||||
|
1182
|
||||||
|
1386
|
||||||
|
1141
|
||||||
|
1184
|
||||||
|
1989
|
||||||
|
1852
|
||||||
|
1097
|
||||||
|
1135
|
||||||
|
1078
|
||||||
|
1587
|
||||||
|
1984
|
||||||
|
1970
|
||||||
|
1259
|
||||||
|
1281
|
||||||
|
1092
|
||||||
|
1294
|
||||||
|
1233
|
||||||
|
1186
|
||||||
|
1555
|
||||||
|
1755
|
||||||
|
1886
|
||||||
|
1030
|
||||||
|
1706
|
||||||
|
1313
|
||||||
|
1481
|
||||||
|
1998
|
||||||
|
1181
|
||||||
|
1244
|
||||||
|
1269
|
||||||
|
1684
|
||||||
|
1798
|
||||||
|
1023
|
||||||
|
1960
|
||||||
|
1050
|
||||||
|
1293
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
1721
|
||||||
|
979
|
||||||
|
366
|
||||||
|
299
|
||||||
|
675
|
||||||
|
1456
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
class ReadData {
|
||||||
|
static Future<List<String>> readFileString(String classString) async {
|
||||||
|
var fileName = 'lib/model/' + classString.toLowerCase() + '.data';
|
||||||
|
var file = File(fileName);
|
||||||
|
var contents = <String>[];
|
||||||
|
|
||||||
|
print('open file "$fileName"');
|
||||||
|
if (await file.exists()) {
|
||||||
|
contents = await File(fileName).readAsLines();
|
||||||
|
} else {
|
||||||
|
print('File "$fileName" not found.');
|
||||||
|
}
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<List<num>> readFileNum(String classString) async {
|
||||||
|
var fileName = 'lib/model/' + classString.toLowerCase() + '.data';
|
||||||
|
var file = File(fileName);
|
||||||
|
var contents = <num>[];
|
||||||
|
|
||||||
|
print('open file "$fileName"');
|
||||||
|
if (await file.exists()) {
|
||||||
|
var contentStrings = await File(fileName).readAsLines();
|
||||||
|
contents = contentStrings.map(num.parse).toList();
|
||||||
|
} else {
|
||||||
|
print('File "$fileName" not found.');
|
||||||
|
}
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
name: aoc2020
|
||||||
|
description: A sample command-line application.
|
||||||
|
# version: 1.0.0
|
||||||
|
# homepage: https://www.example.com
|
||||||
|
# author: Peter Resch <peter.resch@bsci.com>
|
||||||
|
|
||||||
|
environment:
|
||||||
|
sdk: '>=2.4.0 <3.0.0'
|
||||||
|
|
||||||
|
#dependencies:
|
||||||
|
# path: ^1.6.0
|
||||||
|
|
||||||
|
dev_dependencies:
|
||||||
|
pedantic: ^1.7.0
|
||||||
|
test: ^1.5.0
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
// import 'package:aoc2020/aoc2020.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('calculate', () {
|
||||||
|
// expect(calculate(), 42);
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue