HOB Software Competition

For their 25th anniversary HOB Software decided to have a Problem Solving competition

 

1

2

I was at work and decided to give it a go during the break. After decompressing the HSM Problem solving Competition.rar6

Stage 1:

I opened the raw class file in vim and noticed something interesting

7

<p style=”font-size:110%”><b>Stage 2: U3RhZ2UgMzogNTMgNzQgNjEgNjcgNjUgMjAgMzQgM2EgMjAgMzEgMzMgMzQgMzcgMzcgMzcgMzMgMzcgMzUgMzY=</b></p>

To me this seemed like a base64 encoded string prefixed with Stage 2: meant I somehow solved the first Stage. Not being satisfied I decided to decompile the class back to java which produced the following code:

import Main;
import java.awt.Color;
import java.awt.Component;
import java.awt.GridBagLayout;
import java.awt.LayoutManager;
import java.io.File;
import java.net.URL;
import java.security.CodeSource;
import java.security.ProtectionDomain;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.border.Border;

public class Competition
extends JFrame {
final String gz = "STAGE 1 COMPLETE! 4 STAGES LEFT!";
private static final long serialVersionUID = 1;
private String gotostage2dottxt = "gotostage2.txt";
private JTextPane label;

public Competition() {
super("HOB Software Malta Competition");
this.setDefaultCloseOperation(3);
this.setLayout(new GridBagLayout());
this.label = new JTextPane();
this.label.setEditable(false);
this.label.setBackground(null);
this.label.setBorder(null);
this.label.setContentType("text/html");
File file = new File(String.valueOf(this.getExecutableLocation()) + this.gotostage2dottxt);
if (file.exists() && !file.isDirectory()) {
this.doTextFilePresentProcedure();
this.setSize(1000, 200);
} else {
this.doTextFileAbsentProcedure();
this.setSize(600, 200);
}
this.setLocationRelativeTo(null);
this.setVisible(true);
}

String getExecutableLocation() {
return Main.class.getProtectionDomain().getCodeSource().getLocation().getPath().replaceAll("%20", " ");
}

void doTextFilePresentProcedure() {
this.label.setText("<p style=\"font-size:110%\"><b>Stage 2: U3RhZ2UgMzogNTMgNzQgNjEgNjcgNjUgMjAgMzQgM2EgMjAgMzEgMzMgMzQgMzcgMzcgMzcgMzMgMzcgMzUgMzY=</b></p>");
JPanel panel1 = new JPanel(new GridBagLayout());
panel1.add(this.label);
this.add(panel1);
}

void doTextFileAbsentProcedure() {
this.label.setText("<p style=\"font-size:150%\"><b>404 - File Not Found</b></p>");
JPanel panel1 = new JPanel(new GridBagLayout());
panel1.add(this.label);
this.add(panel1);
}
}

There is a conditional looking for a file named gotostage2.txt, so in reality the first stage was to create an empty text file named gotostage2.txt and execute the run_me.bat.

3

another fact seems like that from “STAGE 1 COMPLETE! 4 STAGES LEFT!” this competition has 5 stages.

Stage 2:

https://www.base64decode.org/

4

U3RhZ2UgMzogNTMgNzQgNjEgNjcgNjUgMjAgMzQgM2EgMjAgMzEgMzMgMzQgMzcgMzcgMzcgMzMgMzcgMzUgMzY=

Stage 3: 53 74 61 67 65 20 34 3a 20 31 33 34 37 37 37 33 37 35 36

 

Stage 3:

http://www.rapidtables.com/convert/number/hex-to-ascii.htm

53 74 61 67 65 20 34 3a 20 31 33 34 37 37 37 33 37 35 36

5

Stage 4: 1347773756

Stage 4:

1347773756

 

I tried a lot of things including trying to map the numbers to letters on the phone keypad but yielded no success.

Stuck here!!

 

Stage 5:

??

CodingChillout.Malta

Sphere contest    Last week it was the first of which I took part and landed at 2nd place on the leader board

 

POS 1 2 3
NAME Peng Cao Fairmutex Javi
TEST1.00 1.00 (1) 1.00 (1) 1.00 (1)
FCTRL21.00 1.00 (17) 1.00 (1) 1.00 (1)
ADDTWO1.00 1.00 (24) 1.00 (1) 1.00 (1)
REVARR1.00 1.00 (1) 1.00 (1) 1.00 (1)
PREFSUFF10.00 10.00 (7) 10.00 (2) 10.00 (14)
CONVERT50.00 50.00 (9) 50.00 (11) 50.00 (5)
GLUTTONS5.00 5.00 (1) 5.00 (1) 5.00 (10)
HTMLTAGS25.00 25.00 (1) 25.00 (1) 25.00 (1)
LADYBUGS80.00 80.00 (1) 72.00 (3) 64.00 (4)
SOL 9 9 9
SCORE 174 166 158

The questions ranged from very easy to ones that required some thinking

http://codechillout.sphere-contest.com/ranking

Winners announced on twitter

I will try to post about the Challenges and how I tackled them soon.

Warm-up session

TEST ( c99 strict )
Small factorials ( Python 2.7 )
Add two number ( Python 2.7 )
Reverse Array ( Python 2.7 )

Online Round

Prefix-suffix balance ( c99 strict )
Simple Numbers Conversion (Python 2.7)
Gluttons (Java 7/Python 2.7 / c99 strict )
Ladybugs race (c99 strict)
HTML tags (Python 2.7)

http://codechillout.sphere-contest.com/

 

CodingChillout.Malta: HTML tags

http://codechillout.sphere-contest.com/problems/onlineround/HTMLTAGS

HTML tags

We often write HTML tags with both lower-case and capital letters. As a result, the website’s source code looks ugly. Your task is to write a program which will turn all the lowe-case letters in the HTML tags (i.e. those appearing in between of the signs “<” a “>”) into capital letters.

Input

You are given a fragment of HTML source code.

Output

Your output should print the same HTML source code, but with all the HTML tags written in capital letters.

Example

Input:
<html>
<head>
<TITLE>This is title</Title>
</head>
<body>
<b>Something</b>
</body>
</html>

Output:
<HTML>
<HEAD>
<TITLE>This is title</TITLE>
</HEAD>
<BODY>
<B>Something</B>
</BODY>
</HTML>

Answer

import fileinput
for line in fileinput.input():
   res = '';
   for c in line:
    if(c == '< '):
        flag = True
    elif(c == '>'):
        flag = False
    if(flag == False):
        res += c
    elif(flag == True):
        res += c.upper()
   print res

CodingChillout.Malta: Simple Number Conversion

http://codechillout.sphere-contest.com/problems/onlineround/CONVERT

Converting a number from any base to any base.
Assume that n ≤ 36 and the digits are 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z.

Input

The first line contains integer N, the number of test cases.
n s r
n is the number to convert
s is the source base
r is the resulting base

Output

For each n s r, output the number n in r base.

Example

Input:
4
56378 10 2
AB98BC 15 10
ABCDEF123456 36 2
1000100101010 2 10

Output:
1101110000111010
8182977
1001011010111011111010000110001101100010101101000110110111010
4394

import sys

digits ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"

def base2base(number,rBase,sBase):
    '''
    # Implementation of Any base to Decimal, but int() is faster
    dec = 0
    for n in number:
        dec = digits.index(n,0,rBase) + dec * rBase
    '''
    dec = int(number,rBase)
    result = []
    while(dec != 0):
        dec,mod = divmod(dec, sBase)
        result.insert(0,digits[mod])
    for i in result:
        sys.stdout.write( "%s" % (i))
    print


instances = int(raw_input())
for v in range(0,instances):
    data = raw_input().split(" ")
    number = data[0]
    rBase = int(data[1])
    sBase = int(data[2])
    if(number != '0'):
       base2base(number,rBase,sBase)
    else:
        print 0

Code on Ideone