Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save omas-public/9e6d0634e71fcd1c564548a22b2680fe to your computer and use it in GitHub Desktop.
Save omas-public/9e6d0634e71fcd1c564548a22b2680fe to your computer and use it in GitHub Desktop.
もし次の常駐先が女子エンジニアばかりだったら

御影百合絵からのお願い

const lines = require('fs').readFileSync('/dev/stdin', 'utf8').toString().trim().split('\n');
console.log(Array.from(lines, Number).reduce((a, b) => a + b));

春日みちるからのSOS

const lines = require('fs').readFileSync('/dev/stdin', 'utf8').toString().trim().split('\n');
console.log(lines[0].includes('help') ? 'SOS' : lines[0]);

園田冴絵からの依頼

const cols = require('fs').readFileSync('/dev/stdin', 'utf8').toString().trim().split('\n')[0].split(' ');
const calc = (p) => ({'-' : (a, b) => a - b, '+': (a, b) => a + b})[p];
console.log(calc(cols[2])(parseInt(cols[0],10), parseInt(cols[1],10)));

芦屋川雛乃からのヘルプ依頼

const lines = require('fs').readFileSync('/dev/stdin', 'utf8').toString().trim().split('\n');
const Codec = ((t, c) => ({encode:i => t[i], decode:s => t.indexOf(s)}[c]))(lines[0].split(' '), lines[1]);
console.log(Array.from(lines[2], Codec).join(''));

桂乃梨子とピンチを乗り越えろ

const lines = require('fs').readFileSync('/dev/stdin', 'utf8').toString().trim().split('\n').map(v => Array.from(v.split(' '), Number));
console.log(lines[2].map(r => lines[1].map(c => r + c).join(' ')).join('\n'));

水無瀬朋の一大事

const lines = require('fs').readFileSync('/dev/stdin', 'utf8').toString().trim().split('\n');
const split = (ls, s, e) => ls.slice(s, e).map(l => Array.from(l.split(' '), Number));
const calc = (p, a) => (p[0] * a) - (p[2] * Math.floor(a / p[1]));
console.log(split(lines, +lines[0] + 2, lines.length).map(c => calc(split(lines, 1, +lines[0] + 1)[c[0] - 1], c[1])).join('\n'));
(stdin => {
// Define Function
const Calc = (oper) => ({
'+' : (a, b) => a + b,
'-' : (a, b) => a - b
}[oper]);
// Declare Variable
const inputs = stdin.toString().trim().split('\n');
const cols = inputs[0].split(' ');
// Main Procedure
const result = ((a, b, operator) => {
let calc = Calc(operator);
return calc(...Array.from([a, b], Number));
})(cols[0], cols[1], cols[2]);
// Display
console.log(result);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));
(stdin => {
// Define Function
const add = (a, b) => a + b;
// Declare Variable
const inputs = stdin.toString().trim().split('\n');
// Main Procedure
const result = ((a, b, c) => {
return Array.from([a,b,c], Number).reduce(add);
})(inputs[0], inputs[1], inputs[2]);
console.log(result);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));
(stdin => {
// Define Function
const Reply = (pred) => ({
true : () => 'SOS',
false: (sentence) => sentence
}[pred]);
};
// Declare Variable
const inputs = stdin.toString().trim().split('\n');
// Main Procedure
const result = (sentence => {
const reply = Reply(sentence.includes('help'));
return reply(sentence);
})(inputs[0]);
console.log(result);
(stdin => {
// Define Function
const Crypt = (table, command) => ({
encode:(c) => table[c],
decode:(c) => table.indexOf(c)
}[command]);
// Declare Variable
const inputs = stdin.toString().trim().split('\n');
// Main Procedure
const result = ((table, command, data) => {
const crypt = Crypt(table, command);
return Array.from(data, crypt).join('');
})(inputs[0].split(' ')
, inputs[1]
, Array.from(inputs[2]));
// Display
console.log(result);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment