Download All Files (as .zip)

CCC 2013 - Problem J2: Rotating Letters

I actually wrote this contest and this is the code I used to be marked. I've since fixed up the code and rewrote it in Java. Here is a link to that fixed up code.

The problem:

An artist wants to construct a sign whose letters will rotate freely in the breeze. In order to do this, she must only use letters that are not changed by rotation of 180 degrees: I, O, S, H, Z, X, and N.

Write a program that reads a word and determines whether the word can be used on the sign.

Input Specification
The input will consist of one word, all in uppercase letters, with no spaces. The maximum length of the word will be 30 letters, and the word will have at least one letter in it.

Output Specification
Output YES if the input word can be used on the sign; otherwise, output NO.

Sample Input 1
SHINS

Output for Sample Input 1
YES

Sample Input 2
NOISE

Output for Sample Input 2
NO

My solution (in VB):

Option Strict On
Public Class Form1

    Private Sub btnD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnD.Click

        Dim word As String = txtWord.Text.ToUpper.Trim

        If word = "" Then
            txtD.Text = "NO"
        Else
            If word.Contains("A") Or word.Contains("B") Or word.Contains("C") Or word.Contains("D") Or word.Contains("E") Or word.Contains("F") Or word.Contains("G") Or word.Contains("J") Or word.Contains("K") Or word.Contains("L") Or word.Contains("M") Or word.Contains("P") Or word.Contains("Q") Or word.Contains("R") Or word.Contains("T") Or word.Contains("U") Or word.Contains("V") Or word.Contains("W") Or word.Contains("Y") Or word.Contains("0") Or word.Contains("1") Or word.Contains("2") Or word.Contains("3") Or word.Contains("4") Or word.Contains("5") Or word.Contains("6") Or word.Contains("7") Or word.Contains("8") Or word.Contains("9") Or word.Contains(".") Or word.Contains(",") Or word.Contains("*") Or word.Contains("!") Or word.Contains("@") Or word.Contains("#") Or word.Contains("$") Or word.Contains("^") Or word.Contains("%") Or word.Contains(")") Or word.Contains("&") Or word.Contains("[") Or word.Contains("(") Or word.Contains("'") Or word.Contains("[") Or word.Contains("{") Or word.Contains("}") Or word.Contains("<") Or word.Contains(">") Or word.Contains("`") Or word.Contains("~") Or word.Contains("?") Or word.Contains("\") Or word.Contains("|") Or word.Contains("/") Or word.Contains("'") Or word.Contains(";") Or word.Contains("-") Or word.Contains("+") Or word.Contains("_") Then
                txtD.Text = "NO"
            Else
                txtD.Text = "YES"
            End If

        End If

    End Sub
End Class

'If Not (word.Contains("I")) And Not (word.Contains("O")) And Not (word.Contains("S")) And Not (word.Contains("H")) And Not (word.Contains("Z")) And Not (word.Contains("X")) And Not (word.Contains("N")) Then
'    txtD.Text = "NO"
'Else
'    txtD.Text = "YES"
'End If


DOWNLOAD as .zip

Test cases (as .in files):

Using their test cases:

All the following outputs are exactly the expected outputs.

Input:
TEST
Output:
NO
DOWNLOAD as .in

Input:
HOISIN
Output:
YES
DOWNLOAD as .in

Input:
NOZ
Output:
YES
DOWNLOAD as .in

Input:
ZZZABC
Output:
NO
DOWNLOAD as .in

Input:
ABCDE
Output:
NO
DOWNLOAD as .in

Input:
IOI
Output:
YES
DOWNLOAD as .in

Input:
HI
Output:
YES
DOWNLOAD as .in

Input:
AXE
Output:
NO
DOWNLOAD as .in

Input:
IIOOSSHHZZXXNN
Output:
YES
DOWNLOAD as .in

Input:
IOSHZXNQ
Output:
NO
DOWNLOAD as .in


              Created: February 26, 2013
Completed in full by: Michael Yaworski