Skip to content

Instantly share code, notes, and snippets.

@butackle
Last active July 1, 2017 06:55
Show Gist options
  • Save butackle/22a5e37a2f836bdae5c4354c4ee27f86 to your computer and use it in GitHub Desktop.
Save butackle/22a5e37a2f836bdae5c4354c4ee27f86 to your computer and use it in GitHub Desktop.
20170701_shellGei.js
//Q2
require("fs").readFile("./attend", (err, text) => require("fs").readFile("./attend6", (err, text6) => `${text}`.split("\n").filter((v) => !!v).forEach((v) => console.log(`${v}${text6.includes(v.split(" ")[0]) ? "出" : "欠"}`) )))
//Q4.1
console.log("-1 4 5 2 42 421 44 311 -9 -11".split(" ").sort((a,b) => Number(a) > Number(b) ? 1 : -1).map((v,i,a) => `${v} ${ !i || String(a[i+1]).length !== String(v).length ? "\n" : ""}` ).join(''))
//Q4.2
console.log("-1 +4 5 2 42 421 44 311 -9 -11".split(" ").sort((a,b) => Number(a) > Number(b) ? 1 : -1).map((v,i,a) => `${v} ${ !i || String(a[i+1]).length !== String(Number(v)).length ? "\n" : ""}` ).join(''))
//Q6
require("fs").readFile("./prime", (err, text) => console.log([...Array(100)].map((v,i) => i).filter((v) => (v > 2 && v % 2 !== 0) || v == 2).filter((v,j,a) => a.slice(0, j+1).every((x) => v % x !== 0 || x === v)).map((v) => `${ text }`.replace("\n", "").split(" ").some((x) => x === `${v}`) ? v : "\n").join(" ").replace(/\n\s+\n/, "\n", "g")))
//Q8
require("fs").readFile("./shellgei", (err, text) => console.log(`${ text }`.split("\n").map((v) => v.split("")).map((v,i,a) => v.filter((x,j) => a.map((y) => y[j]).some((z) => z !== " " && z !== undefined ))).map((v) => v.join("")).join("\n")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment