From 6edb5e92a61e89e6d0b21ad2d21ef53c643dfc60 Mon Sep 17 00:00:00 2001 From: Manuel Cota <108767897+MaAnCoSa@users.noreply.github.com> Date: Fri, 23 Dec 2022 18:19:43 -0700 Subject: [PATCH 1/3] Update punched_cards.js Updated comments --- solutions/punched_cards/punched_cards.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solutions/punched_cards/punched_cards.js b/solutions/punched_cards/punched_cards.js index 0ac333ed..7a261272 100644 --- a/solutions/punched_cards/punched_cards.js +++ b/solutions/punched_cards/punched_cards.js @@ -1,7 +1,7 @@ // Punched Cards - // Individual Problem - Manuel Cota - Apprentice Batch 2022 D + // Individual Problem - Manuel Cota - Apprentice 2022 D // The following code is here so that the program can correctly communicate // with the input and output format in the Google Code Jam platform. @@ -93,4 +93,4 @@ function main() { process.stdout.write('Case #' + test_no + ': \n'); solve(); } - } \ No newline at end of file + } From a59a52048913669e7996a553c056da466b1156fc Mon Sep 17 00:00:00 2001 From: Manuel Cota <108767897+MaAnCoSa@users.noreply.github.com> Date: Fri, 23 Dec 2022 18:21:23 -0700 Subject: [PATCH 2/3] Delete punched_cards.js --- solutions/punched_cards/punched_cards.js | 96 ------------------------ 1 file changed, 96 deletions(-) delete mode 100644 solutions/punched_cards/punched_cards.js diff --git a/solutions/punched_cards/punched_cards.js b/solutions/punched_cards/punched_cards.js deleted file mode 100644 index 7a261272..00000000 --- a/solutions/punched_cards/punched_cards.js +++ /dev/null @@ -1,96 +0,0 @@ - - // Punched Cards - - // Individual Problem - Manuel Cota - Apprentice 2022 D - -// The following code is here so that the program can correctly communicate -// with the input and output format in the Google Code Jam platform. -//---------------------------------------------------------------------- -'use strict'; - -process.stdin.resume(); -process.stdin.setEncoding('utf-8'); - -let inputString = ''; -let currentLine = 0; - -process.stdin.on('data', inputStdin => { - inputString += inputStdin; -}); - -process.stdin.on('end', _ => { - inputString = inputString.trim().split('\n').map(string => { - return string.trim(); - }); - - main(); -}); - -function readline() { - return inputString[currentLine++]; -} -//---------------------------------------------------------------------- - - -// This function draws the card saving it in a variable "card". -function punched_cards(R, C) { - - // We initiate by creating the top row, which will always be there. - // The following code types the top edge depending on the # of columns. - let row = "..+"; - for (let j = 0; j < (C-1); j++) { - row += "-+"; - } - row += "\n"; - - let card = row; - - // Now, we create each new row, starting with an exception for the first iteration. - // This is because the top left corner of the card is only dots. - row = "..|"; - let row2 = "+-+"; - for (let j = 0; j < R; j++) { - for (let k = 0; k < (C-1); k++) { - row += ".|"; - row2 += "-+"; - } - row += "\n"; - row2 += "\n" - card += row + row2 - - // With this resets, all following iterations will only have "+-+", unlike the top left corner. - row = "|.|"; - row2 = "+-+"; - } - - return card; -} - -// This function receives the values for R and C in each iteration from all the T cases. -// It uses those values to draw the punched card using the punched_cards function and then -// gives it as output. -function solve() { - // Declare variables R and C. - var R, C; - // Read the integers from the standard input. - [R, C] = readline().split(' ').map(x => parseInt(x)); - - // Obtains the card from the punched_cards function. - var card = punched_cards(R, C); - - // Print the result onto the standard output. - process.stdout.write(card); - } - - -function main() { - // Declare and read the number of test cases. - var T; - T = parseInt(readline()); - - // Loop over the number of test cases. - for (var test_no = 1; test_no <= T; test_no++) { - process.stdout.write('Case #' + test_no + ': \n'); - solve(); - } - } From c44c6251ac42b70a1049fc3293ec374a82c71242 Mon Sep 17 00:00:00 2001 From: Manuel Cota <108767897+MaAnCoSa@users.noreply.github.com> Date: Fri, 23 Dec 2022 18:21:50 -0700 Subject: [PATCH 3/3] Add files via upload --- solutions/punched_cards/punched_cards.js | 96 ++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 solutions/punched_cards/punched_cards.js diff --git a/solutions/punched_cards/punched_cards.js b/solutions/punched_cards/punched_cards.js new file mode 100644 index 00000000..0ac333ed --- /dev/null +++ b/solutions/punched_cards/punched_cards.js @@ -0,0 +1,96 @@ + + // Punched Cards + + // Individual Problem - Manuel Cota - Apprentice Batch 2022 D + +// The following code is here so that the program can correctly communicate +// with the input and output format in the Google Code Jam platform. +//---------------------------------------------------------------------- +'use strict'; + +process.stdin.resume(); +process.stdin.setEncoding('utf-8'); + +let inputString = ''; +let currentLine = 0; + +process.stdin.on('data', inputStdin => { + inputString += inputStdin; +}); + +process.stdin.on('end', _ => { + inputString = inputString.trim().split('\n').map(string => { + return string.trim(); + }); + + main(); +}); + +function readline() { + return inputString[currentLine++]; +} +//---------------------------------------------------------------------- + + +// This function draws the card saving it in a variable "card". +function punched_cards(R, C) { + + // We initiate by creating the top row, which will always be there. + // The following code types the top edge depending on the # of columns. + let row = "..+"; + for (let j = 0; j < (C-1); j++) { + row += "-+"; + } + row += "\n"; + + let card = row; + + // Now, we create each new row, starting with an exception for the first iteration. + // This is because the top left corner of the card is only dots. + row = "..|"; + let row2 = "+-+"; + for (let j = 0; j < R; j++) { + for (let k = 0; k < (C-1); k++) { + row += ".|"; + row2 += "-+"; + } + row += "\n"; + row2 += "\n" + card += row + row2 + + // With this resets, all following iterations will only have "+-+", unlike the top left corner. + row = "|.|"; + row2 = "+-+"; + } + + return card; +} + +// This function receives the values for R and C in each iteration from all the T cases. +// It uses those values to draw the punched card using the punched_cards function and then +// gives it as output. +function solve() { + // Declare variables R and C. + var R, C; + // Read the integers from the standard input. + [R, C] = readline().split(' ').map(x => parseInt(x)); + + // Obtains the card from the punched_cards function. + var card = punched_cards(R, C); + + // Print the result onto the standard output. + process.stdout.write(card); + } + + +function main() { + // Declare and read the number of test cases. + var T; + T = parseInt(readline()); + + // Loop over the number of test cases. + for (var test_no = 1; test_no <= T; test_no++) { + process.stdout.write('Case #' + test_no + ': \n'); + solve(); + } + } \ No newline at end of file