Skip to content

Commit 33ed9e1

Browse files
authored
punchedcards.cpp
1 parent 7967e16 commit 33ed9e1

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

2022

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,39 @@
1-
CODEJAM 2022 HAD FUN PROBLEMS.
2-
In qualification round , there were 5 problems.
3-
[punchedcards](https://codingcompetitions.withgoogle.com/codejam/round/0000000000876ff1/0000000000a4621b)
4-
* 3D PRINTING
5-
* d1000000
6-
* CHAIN REACTIONS
7-
* TWISTING LITTLE PASSAGES
1+
#include <iostream>
2+
#include <vector>
3+
using namespace std;
84

9-
---------------------------------------------------------------------------
10-
# Problem # PUNCHED CARDS
11-
A secret team of programmers is plotting to disrupt the programming language landscape and bring punched cards back by introducing a new language called Punched Card Python that lets people code in Python using punched cards!
12-
Like good disrupters, they are going to launch a viral campaign to promote their new language before even having the design for a prototype.
13-
For the campaign, they want to draw punched cards of different sizes in ASCII art.
5+
int main(){
6+
int t, q = 0;
7+
cin >> t;
8+
while (q++ < t) {
9+
int n, m, i, j;
10+
cin >> n >> m;
11+
// compute the actual number of rows in the output
12+
n = (n - 1) * 2 + 3;
13+
m = (m - 1) * 2 + 3;
1414

15+
cout << "Case #" << q << ":" << endl;
16+
for (i=0;i<n;i++) {
17+
for (j=0;j<m;j++) {
18+
// handle top left corner
19+
if (i < 2 && j < 2) {
20+
cout << ".";
21+
continue;
22+
}
23+
// handle intersection coordinates
24+
if (i % 2 == 0 && j % 2 == 0) {
25+
cout << "+";
26+
continue;
27+
}
28+
// handle pipes
29+
if (i % 2 == 0 && j % 2 == 1) cout << "-";
30+
if (i % 2 == 1 && j % 2 == 0) cout << "|";
31+
32+
// everything else
33+
if ((i + j) % 2 == 0) cout << ".";
34+
}
35+
cout << endl;
36+
}
37+
}
38+
return 0;
39+
}

0 commit comments

Comments
 (0)