Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

punched cards python solution uploaded - Apprentice 2022d #417

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added solutions/punched_cards/.DS_Store
Binary file not shown.
77 changes: 77 additions & 0 deletions solutions/punched_cards/punched_cardss.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
'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++];
}

// Make a Snippet for the code above this and then write your logic in main();

const draw = (row, col) => {
let rowN = '';
for (let r=0; r<row;r++){
for (let c=0; c<col; c++){
if(r<=1 && c<=1)
rowN += '.' ;
else if (c % 2 === 0){
if (r % 2 === 0)
rowN += '+';
else
rowN += '|';
}
else {
if (r % 2 !== 0)
rowN += '.';
else
rowN += '-';
}
}
rowN += '\n';
}
return rowN;
};

function solve() {
// Declare variables N and M.
var row, col;
// Read the integers from the standard input.
[row, col] = readline().split(' ').map(x => parseInt(x));
row = (row*2) +1;
col = (col*2) +1;

// Compute the value of the sum modulo M.
let drawing = draw(row, col);

// Print the result onto the standard output.
process.stdout.write(drawing);
}

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();
}
}