|
|
@@ -0,0 +1,41 @@
|
|
|
+const fs = require('fs');
|
|
|
+const readline = require('readline');
|
|
|
+
|
|
|
+function ElfeSections(input) {
|
|
|
+ let inputP = input.split('-').map(i => parseInt(i));
|
|
|
+ this.min = inputP[0];
|
|
|
+ this.max = inputP[1];
|
|
|
+}
|
|
|
+
|
|
|
+ElfeSections.prototype._partialContains = function(section) {
|
|
|
+ return (this.min <= section.max && section.min <= this.max);
|
|
|
+}
|
|
|
+
|
|
|
+ElfeSections.prototype.partialContains = function(section) {
|
|
|
+ return this._partialContains(section) || section._partialContains(this);
|
|
|
+}
|
|
|
+
|
|
|
+ElfeSections.prototype.fullyContains = function(section) {
|
|
|
+ return ((section.min >= this.min && section.max <= this.max) ||
|
|
|
+ (this.min >= section.min && this.max <= section.max));
|
|
|
+}
|
|
|
+
|
|
|
+async function main() {
|
|
|
+ let fullyContains = 0;
|
|
|
+ let partialContains = 0;
|
|
|
+
|
|
|
+ for await (let line of readline.createInterface({ input: process.stdin })) {
|
|
|
+ if (!line || !line.length)
|
|
|
+ continue;
|
|
|
+ let lineGroup = line.split(',').map(i => new ElfeSections(i));
|
|
|
+ if (lineGroup[0].fullyContains(lineGroup[1]))
|
|
|
+ fullyContains++;
|
|
|
+ if (lineGroup[0].partialContains(lineGroup[1]))
|
|
|
+ partialContains++;
|
|
|
+ }
|
|
|
+ console.log("Fully contains: "+ fullyContains);
|
|
|
+ console.log("Partial contains: "+ partialContains);
|
|
|
+};
|
|
|
+
|
|
|
+(main());
|
|
|
+
|