LOGO100 logo

Berlin 2025 CODE100

Pseudo Code Questions (5)

1. Given the function, which input will return true?

Function isNumberValid(num)
    While num > 1
        If num mod 3 ≠ 0 then
            Return false
        End If
        num = num / 3
    End While
    Return num == 1
End Function

Answer: 4 - 243 is correct, as the function checks if the input is a power of 3. 243 is 3x3x3x3x3.

Codepen: https://codepen.io/Daniel-Cranney/pen/ZYYeOQe

2. What will this function return when the input is [3, 1, 4, 1, 5]?

Function countNums(nums)
    count = 0
    For each n in nums
        If n == 1 then
            count = count + 1
        End If
    End For
    Return count
End Function

Answer: 2 - 2 is correct, as the function only counts 1’s.

Codepen: https://codepen.io/Daniel-Cranney/pen/NPPpRxv

3. Given the function, which string will return true?

Function checkString(str)
    Set seen to empty set
    For each char in str
        If char in seen then
            Return true
        Else
            Add char to seen
        End If
    End For
    Return false
End Function

Answer: 3 - Notebook will return true, as the function checks for duplicates in the string.

Codepen: https://codepen.io/Daniel-Cranney/pen/WbbpGZM

4. What input will return ‘HELLO’?

Function decodeLetters(nums)
    alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    output = ""
    For each n in nums
        index = floor(n / 2)
        output = output + alphabet[index - 1]
    End For
    Return output
End Function

Answer: 4 - [16, 10, 24, 24, 30] will return “HELLO”, as each of the numbers/2 and minus 1 will return [7, 4, 11, 11, 14] (the position for each in the alphabet when zero-indexed)

Codepen: https://codepen.io/Daniel-Cranney/pen/XJJMMyL

5. What will this function return when given [5, 8, 10]?

Function addNums(nums)
    total = 0
    For each n in nums
        If n mod 2 == 0 then
            total = total + n
        End If
    End For
    Return total
End Function

Answer: 3 - The function will return the sum of even numbers, so 10 + 8 = 18, and 5 is ignored.

Codepen: https://codepen.io/Daniel-Cranney/pen/NPPpgNP

Pair programming round

X-Men united

Your challenge is to turn this array of numbers:

[3, 12, 16, 40,36, 66, 65]

Into the X-Men logo:

⚫️⚫️⚫️⚫️⚫️🔴🔴🔴🔴⚫️⚫️⚫️⚫️⚫️
⚫️⚫️⚫️🔴🔴⚫️⚫️⚫️⚫️🔴🔴⚫️⚫️⚫️
⚫️⚫️🔴⚫️⚫️⚫️⚫️⚫️⚫️⚫️⚫️🔴⚫️⚫️
⚫️🔴⚫️🔴⚫️⚫️⚫️⚫️⚫️⚫️🔴⚫️🔴⚫️
⚫️🔴⚫️⚫️🔴⚫️⚫️⚫️⚫️🔴⚫️⚫️🔴⚫️
🔴⚫️⚫️⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️⚫️⚫️🔴
🔴⚫️⚫️⚫️⚫️⚫️🔴🔴⚫️⚫️⚫️⚫️⚫️🔴
🔴⚫️⚫️⚫️⚫️⚫️🔴🔴⚫️⚫️⚫️⚫️⚫️🔴
🔴⚫️⚫️⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️⚫️⚫️🔴
⚫️🔴⚫️⚫️🔴⚫️⚫️⚫️⚫️🔴⚫️⚫️🔴⚫️
⚫️🔴⚫️🔴⚫️⚫️⚫️⚫️⚫️⚫️🔴⚫️🔴⚫️
⚫️⚫️🔴⚫️⚫️⚫️⚫️⚫️⚫️⚫️⚫️🔴⚫️⚫️
⚫️⚫️⚫️🔴🔴⚫️⚫️⚫️⚫️🔴🔴⚫️⚫️⚫️
⚫️⚫️⚫️⚫️⚫️🔴🔴🔴🔴⚫️⚫️⚫️⚫️⚫️

Some hints:

Possible solution:

import { readFileSync, writeFile } from 'fs';
let pixels = JSON.parse(readFileSync('xmen.json', 'utf8'));

pixels = pixels.map((row) => {
    return row.toString(2).padStart(7, '0');
})

pixels.map((row, i) => {
    pixels[i] = pixels[i] + pixels[i].split('').
    reverse().join('');
});

pixels = pixels.
            concat([...pixels].reverse()).
            join('\n').
            replaceAll('0', '⚫️').
            replaceAll('1', '🔴');
writeFile('xmen.txt', pixels, (err) => {
    if (err) {
        console.error(err);
        return;
    }
    console.log('File has been saved!');
});
console.log(pixels);

Tie Breaker Pair Round

What does the page visibility API do?

Answer 3

Quiz round Questions (7)

1. What’s next in this sequence?

1,10,11,100,101

Answer: 3 - 110 is correct, this is counting in binary

2. How is the text in this HTML example aligned?

<p align="center" 
   style="text-align:right;display:flex;justify-content=center">
   Text
</p>
  1. Centered
  2. Right
  3. Left
  4. 25% of the screen

Answer: 3 - Left: align is overuled by text-align and flex overules left-align, but there is a typo a “=center” (should be “:center”)

3. What does CSRF stand for?

  1. Cascading Style React Foundation
  2. Complete Security Review Fatigue
  3. Cross-Site Requirement Files
  4. Cross-Site Request Forgery

Answer: 4 - Cross-Site Request Forgery

4. Which one of the following is not a native CSS function?

  1. calc()
  2. cross-fade()
  3. random()
  4. tan()

Answer: 3 - random() is not a function in CSS - cross-fade() is new-ish but does exist.

5. How many of the following are W3C standards/proposals?

  1. SVG *
  2. JSX
  3. VML
  4. VoiceXML *
  5. EPUB *

Answer 3 - VoiceXML, EPUB and SVG

6. Which of the following is not a security acronym?

  1. Cross Site Scripting
  2. SQLite spoofing
  3. Man-in-the-Middle Attack
  4. SQL injection
  5. Slopsquatting

Answer 2 - there is no SQLite spoofing

7. What is not an accessibility requirement for online products?

  1. Images must have alternative text
  2. Animations must be possible to control
  3. Videos need captions
  4. Nothing should flash more than three times in a second.
  5. Content be 400% zoomable without losing information
  6. Links must be only referenced once
  7. Text have enough contrast to be readable

Answer 6 - Links must have unique names, but can be referenced several rimes

Final code challenge

Cracking the Code

This challenge is about decrypting a message. You get a encrypted message:

f14h2f27o2y11 u42s12f14u14a36 u42j6w27a2 l38g12y5 j5h23 
q14r2b27n2w11 p42w12l14q14x36 m35r2t31 d38f12h5 
q40i12r13c14 m14e2d27x2m11 n42p12c14k14q36 h11j5t14 
l36i11v12w5m14n40 j36a14n40 b40f2d24g2x11a31 h38q12c5

And you get a key sentence to decrypt the message:

the quick brown fox jumps over the lazy dog

Here are some examples of encrypted words using this method:

Some hints:

What’s the message?

Possible solution:

import { readFileSync } from 'fs';
let data = readFileSync('challenge.json', 'utf8');
let message = JSON.parse(data).message;
let key = JSON.parse(data).key;

const decode = (message, key) => {
    let words = message.split(' ');
    let decoded = [];
    words.forEach(word => {
        word = word.split(/[a-z]/).map((char) => {
            return char ? key[char] : '';
        });
        decoded.push(word.join(''));
    });
    return decoded.join(' ');
};

console.log(decode(message, key));

Tie Breaker Final Round

Which one returns true?

function isWeAreDevelopers(str) {
    let WeAreDevelopers = new RegExp('\/\/\> 20[0-9]{2}');
    return WeAreDevelopers.test(str);
}

Answer: The second one is the only true one.

Audience Rounds

Audience Round 1

Given the following HTML:

<div id="test2">
    <span id="1_price"></span>
</div>

How many of the following do return an error?

Answer: 2 - the first, the fourth and the fifth work. CSS allows for IDs to start with a number, but JS does not allow variables to be named like that, so the automatic conversion from ID to global fails.

Audience Round 2

What is AGI?

Answer: Option 4

Audience Round 3

What is next in the sequence?

8, 11, 5, 4, 9, 1 …

Answer: 7 - it is the numbers 1 to 12 in alphabetical order