const fs = require('fs');
let max=-Infinity,min=Infinity;
(fs.readFileSync('input.txt')+'').split('\n').forEach(v => {
v=+v;
if(v > max)max = v;
if(v < min)min = v;
});
console.log(`Blah blah blah ${min+max}`)
const fs = require('fs');
fs.readFile('f.txt', 'utf8', (err, data) => {
if (err) throw err;
const numbers = data.split('\n').map(Number);
const first = numbers[0];
const last = numbers[numbers.length - 1];
const difference = last - first;
console.log(`The difference between the first and last numbers is ${difference}`);
});
файл f это блокнот.
пример на python:
f = open('input.txt', 'r')
minNum = None
maxNum = None
for line in f:
num = float(line)
if minNum is None or minNum > num: minNum = num;
if maxNum is None or maxNum < num: maxNum = num;
print("Сумма минимального и максимального элементов:", minNum + maxNum)