From 57ffe0dc46fa413b3754b74cf4a572f027a830fe Mon Sep 17 00:00:00 2001 From: notaero2 Date: Thu, 13 Feb 2025 13:24:14 +0800 Subject: [PATCH] Added nineknights --- nineknights/input.txt | 5 ++++ nineknights/output.txt | 2 ++ nineknights/stub.dsl | 4 ++++ nineknights/stub.js | 53 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 nineknights/input.txt create mode 100644 nineknights/output.txt create mode 100644 nineknights/stub.dsl create mode 100644 nineknights/stub.js diff --git a/nineknights/input.txt b/nineknights/input.txt new file mode 100644 index 0000000..4eb3297 --- /dev/null +++ b/nineknights/input.txt @@ -0,0 +1,5 @@ +...k. +...k. +k.k.. +.k.k. +k.k.k \ No newline at end of file diff --git a/nineknights/output.txt b/nineknights/output.txt new file mode 100644 index 0000000..5f5d299 --- /dev/null +++ b/nineknights/output.txt @@ -0,0 +1,2 @@ +[ '...k.\r', '...k.\r', 'k.k..\r', '.k.k.\r', 'k.k.k' ] +undefined diff --git a/nineknights/stub.dsl b/nineknights/stub.dsl new file mode 100644 index 0000000..bac305a --- /dev/null +++ b/nineknights/stub.dsl @@ -0,0 +1,4 @@ +function(string, checkSolution, string_array board) +array(string, board, 5, multi) +invoke(string, validity, checkSolution, board) +print(string, validity) \ No newline at end of file diff --git a/nineknights/stub.js b/nineknights/stub.js new file mode 100644 index 0000000..bfeb5cc --- /dev/null +++ b/nineknights/stub.js @@ -0,0 +1,53 @@ +'use strict'; + +const fs = require('fs'); + +process.stdin.resume(); +process.stdin.setEncoding('utf-8'); + +let inputString = ''; +let currentLine = 0; + +process.stdin.on('data', function(inputStdin) { + inputString += inputStdin; +}); + +process.stdin.on('end', function() { + inputString = inputString.split('\n'); + + main(); +}); + +function readLine() { + return inputString[currentLine++]; +} + +/* + * Complete the 'checkSolution' function below. + * + * The function is expected to return a STRING. + * The function accepts STRING_ARRAY board as parameter. + */ + +function checkSolution(board) { + // Write your code here + + console.log(board) +} + +function main() { + const ws = process.stdout; + + let board = []; + + for (let i = 0; i < 5; i++) { + const boardItem = readLine(); + board.push(boardItem); + } + + const validity = checkSolution(board); + + ws.write(validity + '\n'); + + ws.end(); +}