Created
April 15, 2015 06:58
-
-
Save south-str/0276c66abf6204688704 to your computer and use it in GitHub Desktop.
Answers for POH5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var line; | |
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
process.stdin.on('data', function (chunk) { | |
line = chunk.split(""); | |
}); | |
process.stdin.on('end', function () { | |
var result = line.map(function(x, y){ | |
if(y === 0 || y % 2 === 0){ | |
return x; | |
} | |
}); | |
result.forEach(function(x){ | |
if(x !== undefined){ | |
process.stdout.write(x); | |
} | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var line; | |
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
process.stdin.on('data', function (chunk) { | |
line = chunk.split("\n"); | |
}); | |
process.stdin.on('end', function () { | |
var result = [0,0,0,0,0,0,0]; | |
var days = parseInt(line[0]); | |
for(i = 1; i <= days; i++){ | |
if(i%7 === 0){ | |
result[6] += parseInt(line[i]); | |
}else{ | |
result[i%7 - 1] += parseInt(line[i]); | |
} | |
} | |
result.forEach(function(x){ | |
process.stdout.write(x + '\n'); | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
process.stdin.on('end', function () { | |
var x = 'MINAMI'; | |
process.stdout.write(x + '\n'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
var line = []; | |
process.stdin.on('data', function (chunk) { | |
line = chunk.split("\n"); | |
}); | |
process.stdin.on('end', function () { | |
var firstLine = line.shift(); | |
var xy = firstLine.split(' '); | |
var x = parseInt(xy[0]); | |
var y = parseInt(xy[1]); | |
var matrix = line.map(function(elem){ | |
return elem.split(' '); | |
}); | |
var revMatrix = []; | |
for(var a=0;a<x;a++){ | |
revMatrix.push([]); | |
} | |
for(var i=0;i<x;i++){ | |
for(var j=0;j<y;j++){ | |
if(matrix[j][i] != '2'){ | |
revMatrix[i].push(parseInt(matrix[j][i])); | |
}else{ | |
revMatrix[i].push(0); | |
} | |
} | |
} | |
var sum = revMatrix.map(function(elem){ | |
return elem.reduce(function(x,y){ | |
return x+y; | |
}) | |
}); | |
var falled = sum.map(function(elem){ | |
var bombedLine = []; | |
for(var bomb=0;bomb<y;bomb++){ | |
if(bomb < elem){ | |
bombedLine.push(1); | |
}else{ | |
bombedLine.push(0); | |
} | |
} | |
return bombedLine.reverse(); | |
}); | |
var result = []; | |
for(a=0;a<y;a++){ | |
result.push([]); | |
} | |
for(i=0;i<y;i++){ | |
for(j=0;j<x;j++){ | |
result[i].push(falled[j][i]); | |
} | |
} | |
result.forEach(function(elem){ | |
process.stdout.write(elem.join(' ') + '\n'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment