UTS Programming Competition 2015 Problem 1

From ProgSoc Wiki

Jump to: navigation, search

Problem 1: ASCII Chequerboards

Run time limit: 2 seconds

Problem Description

Let's kick off our competition with some fun and games!

If you have ever played board games such as chess or chequers, or at least watched these games being played, you will have undoubtedly encountered the game board upon which these games are played. You would have noticed the distinct, alternating two-toned pattern of smaller squares arranged within a larger square that is the game board, upon which the game pieces were placed, moved about and removed from.

Your task is to write a program that recreates that pattern. In lieu of black and white squares, you will instead use characters from the keyboard -- an ASCII chequerboard!

"This is a pointless task!", you may well say. "Au contraire!", is my rejoinder, for in order to succeed in this competition, you will need to be sure that you know how to correctly read input, write output, and follow specifications. Consider this task to be a sanity test of sorts.

Data Specification

Input

A single integer, N, where 2 <= N <= 40, denoting the size of your chequerboard.

Output

There will be N horizontal lines in total. For clarity, we shall refer to the first line as line 1 (which is an "odd-numbered line") and the last line as line N (which can be odd or even).

The first character to print on odd-numbered lines will be an asterisk (*). The following character will be an underscore (_). Alternate printing asterisks and underscores until N characters have been printed on that line.

On even-numbered lines, the first character will be an underscore, followed by an asterisk. Alternate printing underscores and asterisks until N characters have been printed on that line.

Sample Input

5 

Sample Output

*_*_* 
_*_*_ 
*_*_* 
_*_*_ 
*_*_*

Solutions

Put your solutions here!

Personal tools