--- title: "Internet Conciseness Programming Contest: Round 5" type: "article" slug: "internet-conciseness-programming-contest-round-5" url: "http://localhost/article/internet-conciseness-programming-contest-round-5/" markdown_url: "http://localhost/article/internet-conciseness-programming-contest-round-5.md" published_at: "2025-11-30T08:02:01+00:00" modified_at: "2026-06-21T23:26:00+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "In past issues of the QHJ I've covered this contest. I've included Round 5 for completeness - ED PAPER FOLDING You are given a sheet of paper that contains all asterisks ('*') on top, and all pound signs ('#') on the bottom. A three by five sheet of this paper would look like this: *****…" category: - name: "QL Hacker's Journal" slug: "ql-hackers-journal" taxonomy: "category" url: "http://localhost/category/periodicals/ql-hackers-journal/" post_tag: - name: "Full Text" slug: "fulltext" taxonomy: "post_tag" url: "http://localhost/tag/fulltext/" indiv: - name: "Tim Swenson" slug: "tim-swenson" taxonomy: "indiv" url: "http://localhost/indiv/tim-swenson/" publication_r: id: 33686 title: "QL Hacker’s Journal" type: "periodical" url: "http://localhost/periodical/ql-hackers-journal/" authors_r: - name: "Tim Swenson" slug: "tim-swenson" taxonomy: "indiv" url: "http://localhost/indiv/tim-swenson/" issue: "15" issues_articles: - id: 61551 title: "QL Hacker’s Journal 15" type: "issue" url: "http://localhost/issue/ql-hackers-journal-15/" pubdate: "October 1993" archive_link: true --- # Internet Conciseness Programming Contest: Round 5 In past issues of the QHJ I’ve covered this contest. I’ve included Round 5 for completeness – ED PAPER FOLDING You are given a sheet of paper that contains all asterisks (‘*’) on top, and all pound signs (‘#’) on the bottom. A three by five sheet of this paper would look like this: ``` ***** ***** ***** ``` on top, and this: ``` ##### ##### ##### ``` on the bottom. If you were to make a vertical fold in the paper one unit from the right edge of the paper, the resulting paper would look like this: ``` ***# ***# ***# ``` on top. For this round, you will be writing a program which, given the dimensions of a piece of paper with asterisks on top and pound signs on the bottom, will show how that piece of paper looks after a number of folds have been made in it. ### The Input There will be multiple data sets in the input file. Each data set will start with two numbers on a single line separated by a space ( 1 <= x <= 10, 1 <= y <= 10 ). These are the dimensions of the piece of paper — x rows and y columns. The next line of the data set contains a single number which indicates the number of folds you are to make in the piece of paper. The next lines will each contain a description of a fold in the form ED N where E is either ‘T’, ‘B’, ‘L’, or ‘R’ (meaning ‘top’, ‘bottom’, ‘left’, and ‘right’ respectively); D is either ‘O’ or ‘U’ (meaning ‘over’ or ‘under’ respectively; and N is an integer indicating how many units from the edge you are to make the fold. E will always be in column 1, D will always be in column 2, a space will always be in column 3, and N will always start in column 4. The specifiers E, D, and N mean that you are to fold the E edge of the paper in the direction D at a point N units from the E edge. Thus, a line which reads RO 1 means you are to fold the right side of the paper over, one unit from the *current* rightmost edge of the paper. A line reading BU 3 means you are to fold the *current* bottom edge of the paper under, three units from the current bottom edge. ### The Output Produce as output what the paper looks like after all folds have been made. Left justify your output, and print a blank line between data sets. ### Sample Input ``` 3 5 1 RO 1 4 6 2 BU 1 RO 1 6 6 1 LU 5 ``` ### Sample Output ``` ***# ***# ***# ****# ****# ***** *#### *#### *#### *#### *#### *#### ```