Skip to content

Instantly share code, notes, and snippets.

@ryu1-1uyr
Created February 25, 2019 17:31
Show Gist options
  • Save ryu1-1uyr/7e609d0010c3b87b0ac9d429c299e17d to your computer and use it in GitHub Desktop.
Save ryu1-1uyr/7e609d0010c3b87b0ac9d429c299e17d to your computer and use it in GitHub Desktop.
Ramda.js使ってます
const R = require('ramda');
process.stdin.resume();
process.stdin.setEncoding('utf8');
let lines = [];
let reader = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
reader.on('line', (line) => {
lines.push(line);
});
reader.on('close', () => {
console.log("\n")
const sumTeamNumber = lines[0]
const matchResult = lines.filter(x=>!(x>=0))
//数字の削除 => 1文字ずつ分解&&配列化 => 余分な文字をまとめてからの文字列に => 要素のカウント
const treatmentMatchResult = matchResult.filter(x=>x).map(x=>[...[]+x]).map(x=>x.map(y=>y.replace(' ','').replace('-',''))).map(x=>R.countBy(R.toLower)(x))
const winPoints = {}
const points = []
//ここのカウンターくそダセェ
let counter = 0;
let teamCounter = 1
//勝ち点カウント ~NaN対策を添えて~
treatmentMatchResult.forEach(x=>{
counter += (x['w']-[])*2 || 0
counter += (x['d']-[]) || 0
winPoints[teamCounter] = counter
points.push(counter)
counter = 0
teamCounter ++
})
const winnerTeamsPoint = points.reduce((a,b)=>Math.max(a,b))
const winnerTeam = Object.keys(winPoints).filter((key) => {
return winPoints[key] === winnerTeamsPoint
})
//優勝チーム,勝ち点,勝ち,引き分け,負け,<= undefined対策
console.log(
winnerTeam[0],winnerTeamsPoint,
treatmentMatchResult[winnerTeam[0] -1]['w'] || 0,
treatmentMatchResult[winnerTeam[0] -1]['d'] || 0,
treatmentMatchResult[winnerTeam[0] -1]['l'] || 0
)
});botchi_b_2002
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment