DU
Size: a a a
DU
L
const fs = require('fs');
const INPUT_FILE = 'input-201.txt'
const OUTPUT_FILE = 'input-201.a.txt'
function parseFile(path, next) {
const input = fs.readFileSync(path, "utf8")
let i = 0, j = 0;
for(j = i; j < input.length; j++) {
if ( input[j] === "\r" || input[j] === "\n" ) {
if ( i !== j )
next( input.slice(i, j) )
i = j + 1
}
}
if ( i !== j )
next( input.slice(i, j) )
}
class Uni {
constructor() {
const map = {}
this.n = 0
this.next = s => {
s |= 0
const c = map[s] = (map[s]|0) + 1
if ( c <= 2 )
this.n ^= +s
}
}
}
const u = new Uni()
parseFile(INPUT_FILE, u.next)
fs.writeFileSync(OUTPUT_FILE, u.n)
S
const fs = require('fs');
const INPUT_FILE = 'input-201.txt'
const OUTPUT_FILE = 'input-201.a.txt'
function parseFile(path, next) {
const input = fs.readFileSync(path, "utf8")
let i = 0, j = 0;
for(j = i; j < input.length; j++) {
if ( input[j] === "\r" || input[j] === "\n" ) {
if ( i !== j )
next( input.slice(i, j) )
i = j + 1
}
}
if ( i !== j )
next( input.slice(i, j) )
}
class Uni {
constructor() {
const map = {}
this.n = 0
this.next = s => {
s |= 0
const c = map[s] = (map[s]|0) + 1
if ( c <= 2 )
this.n ^= +s
}
}
}
const u = new Uni()
parseFile(INPUT_FILE, u.next)
fs.writeFileSync(OUTPUT_FILE, u.n)
DU
const fs = require('fs');
const INPUT_FILE = 'input-201.txt'
const OUTPUT_FILE = 'input-201.a.txt'
function parseFile(path, next) {
const input = fs.readFileSync(path, "utf8")
let i = 0, j = 0;
for(j = i; j < input.length; j++) {
if ( input[j] === "\r" || input[j] === "\n" ) {
if ( i !== j )
next( input.slice(i, j) )
i = j + 1
}
}
if ( i !== j )
next( input.slice(i, j) )
}
class Uni {
constructor() {
const map = {}
this.n = 0
this.next = s => {
s |= 0
const c = map[s] = (map[s]|0) + 1
if ( c <= 2 )
this.n ^= +s
}
}
}
const u = new Uni()
parseFile(INPUT_FILE, u.next)
fs.writeFileSync(OUTPUT_FILE, u.n)
L
DU
L
const fs = require('fs');
const INPUT_FILE = 'input-201.txt'
const OUTPUT_FILE = 'input-201.a.txt'
function parseFile(path, next) {
const input = fs.readFileSync(path, "utf8")
let i = 0, j = 0;
for(j = i; j < input.length; j++) {
if ( input[j] === "\r" || input[j] === "\n" ) {
if ( i !== j )
next( input.slice(i, j) )
i = j + 1
}
}
if ( i !== j )
next( input.slice(i, j) )
}
class Uni {
constructor() {
const map = {}
this.n = 0
this.next = s => {
if ( !isFinite(s) )
return
s |= 0
const c = map[s] = (map[s]|0) + 1
if ( c <= 2 )
this.n ^= +s
}
}
}
const u = new Uni()
parseFile(INPUT_FILE, u.next)
fs.writeFileSync(OUTPUT_FILE, u.n)
DU
DE
L
L
const fs = require('fs');
const INPUT_FILE = 'input-201.txt'
const OUTPUT_FILE = 'input-201.a.txt'
function parseFile(path, next) {
const input = fs.readFileSync(path, "utf8")
let i = 0, j = 0;
for(j = i; j < input.length; j++) {
if ( input[j] === "\r" || input[j] === "\n" ) {
if ( i !== j )
next( input.slice(i, j) )
i = j + 1
}
}
if ( i !== j )
next( input.slice(i, j) )
}
class Uni {
constructor() {
const map = this.map = {}
this.next = s => {
map[s] = (map[s]|0) + 1
}
}
get() {
for(let i in this.map)
if ( this.map[i] === 1 )
return i
return ""
}
}
const u = new Uni()
parseFile(INPUT_FILE, u.next)
fs.writeFileSync(OUTPUT_FILE, u.get())
DU
DU
DU
DU
L
const fs = require('fs');а так
const INPUT_FILE = 'input-201.txt'
const OUTPUT_FILE = 'input-201.a.txt'
fs.writeFileSync(OUTPUT_FILE, [...fs
.readFileSync(INPUT_FILE, "utf8")
.split(/[\r\n]+/)
.reduce((m, v) => m.set(v, (m.get(v)|0)+1), new Map)]
.find(v => v[1] === 1)[0])
S
const fs = require('fs');а так
const INPUT_FILE = 'input-201.txt'
const OUTPUT_FILE = 'input-201.a.txt'
fs.writeFileSync(OUTPUT_FILE, [...fs
.readFileSync(INPUT_FILE, "utf8")
.split(/[\r\n]+/)
.reduce((m, v) => m.set(v, (m.get(v)|0)+1), new Map)]
.find(v => v[1] === 1)[0])
DU
DU
НА