# CS Ed Week Programming Challenge 2013

Purdue University's Computer Science K-12 Outreach program held its first high school programming challenge during the week of December 9th-15th. The week was chosen in support of the events of Computer Science Education Week.

Computer Science Education Week was started as an attempt to help raise the profile of computer science in K-12 classrooms. The dates in December were selected in order to honor the birthday of Grace Murray Hopper, the woman who first developed a high-level programming language, as well as a compiler for converting code written in that language to instructions that a computer processor can understand.

The programming challenge offered three programming problems for students to solve during the week. These problems were designed to challenge students' abilities to think algorithmically and write solutions that address the four tenets of software design. These include a program's correctness, design, style and efficiency.

Listed below are the solutions for each of the winners from this year's competition along with their names, schools and sponsoring teacher. Each winning student will receive a Purdue Computer Science t-shirt and a certificate for their accomplishment.

**Problem 1: Steganography**

The process of hiding secret messages in plain sight is known as steganography. Write a function that finds a secret message by taking the first and last letter of every word in the original message and then appends those letters alternately to the front or end of a new solution string. The function takes a string as input, and returns a string as output.

Best solution by **Colton Cline**, **Damon Jones**, **Wesley Martin** and **Ryan Rogers** from Lebanon High School in Lebanon, IN. Sponsored by Ms. Vicki Davis. Solution written in QBASIC.

```
CLS
RANDOMIZE TIMER
SERIAL = INT(RND * 10000) + 1
PRINT USING "You are number #####"; SERIAL
PRINT "Enter message:"
PRINT
INPUT "", Message$
Message$ = LCASE$(Message$)
leng = LEN(Message$)
beg = 1
FOR a = 1 TO leng
IF (MID$(Message$, a, 1) = " ") THEN
scount = scount + 1
word$ = MID$(Message$, beg, a - beg)
counter = counter + 1
beg = a + 1
L$ = LEFT$(word$, 1)
R$ = RIGHT$(word$, 1)
m$ = L$ + R$
DO UNTIL cc = scount
IF c = 0 THEN
smessage$ = m$ + smessage$
c = 1
ELSE
c = 0
smessage$ = smessage$ + m$
END IF
cc = cc + 1
LOOP
END IF 'END IT
NEXT a
word$ = MID$(Message$, beg)
L$ = LEFT$(word$, 1)
R$ = RIGHT$(word$, 1)
IF ((scount MOD 2) = 0) THEN
PRINT L$; R$;
PRINT smessage$;
ELSE
PRINT smessage$; L$; R$
END IF
```

Other solutions: Monica Viers and Jalen Wright (Franklin Central HS - Indianapolis, IN); Staci Cline, Aaron Fischer, Benjamin Moore, and Brady Morgan (Lebanon HS - Lebanon, IN); Minh Tong (Northview HS - Brazil, IN)

**Problem 2: Sum of Squared Integers**

Any positive integer can be represented by a sum of squared integers. Write a function that finds the smallest set of integers that sum to the original integer when squared. The function should take a single integer as input and return an array or list of integers as output (the output does not need to be sorted).

Best solution by **Cody Hayes**, **Mitchell Mills**, **Christopher Powell**, **Murtuza Shaikh**, and **Jonathon Yeary **from Mount Vernon High School in Fortville, IN. Sponsored by Ms. Julie Bravard-Johnson. Solution written in Java.

```
class Challenge {
public static void main(String[] args) {
final double originalDouble = Double.parseDouble(javax.swing.JOptionPane.showInputDialog(null, "Enter number"));
final int originalNumber = (int)originalDouble;
java.util.ArrayList
``` numbers = new java.util.ArrayList();
int number = originalNumber;
int total = 0;
while (number > 0) {
number = (int)Math.sqrt(number);
numbers.add(number);
for (int i = 0; i < numbers.size(); i++) {
total += (numbers.get(i) * numbers.get(i));
}
if ((originalNumber - total) == 0)
break;
number = originalNumber - total;
total = 0;
}
String equation = originalNumber + " = ";
for (int i = 0; i < numbers.size(); i++) {
if (i < (numbers.size() - 1))
equation += numbers.get(i) + "^2 + ";
else if (i == (numbers.size() - 1))
equation += numbers.get(i) + "^2";
}
System.out.println(equation);
new java.util.Scanner(System.in).next();
}
}

Other solutions: Minh Tong (Northview HS - Brazil, IN)

**Problem 3: Stamen Numeral System**

Many people are familiar with the Roman numeral system. Fewer are familiar with the Stamen numeral system used by flowers. In this system, A daisy (“D”) is worth 20, a pansy (“P”) is worth 5, a clover (“C”) is worth 3, and a rose (“R”) is worth 1. Numbers are constructed as follows. If the character to the right is lesser or equal in value, it is added to the sum unless the character to its left is greater in value. If the character to the right is greater in value, then you add the difference of the larger minus the smaller.

Best solution by **Shannon V Neumann **from IAS High School in Princeton, IN. Sponsored by Mr. Al Anturing. Solution written in Python.

```
def stamen(x):
n = 0
valueList = []
while n < len(x):
if x[n] not in {'D','P','C','R'}:
return 'Original input is not a stamen numeral'
elif x[n] == 'D':
valueList = valueList + [20]
elif x[n] == 'P':
valueList = valueList + [5]
elif x[n] == 'C':
valueList = valueList + [3]
elif x[n] == 'R':
valueList = valueList + [1]
n = n + 1
n = 0
total = 0
while n < len(valueList) - 1:
if valueList[n] >= valueList[n+1]:
total = total + valueList[n]
else:
total = total - valueList[n]
n = n + 1
total = total + valueList[len(valueList) - 1]
return total
```

Other solutions: None

*Last Updated:*Apr 13, 2017 5:02 PM