Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Day 1 - Halloween Coding Challenges 2023 - PHP

simong1993

Diamond Coder
Staff Team
Guardian
🎃 Welcome to the Haunted Code Challenge! 🎃

Greetings, brave souls! As Halloween draws near, the spirits have awakened and taken over the realm of code. They've trapped a sequence of magical numbers within broken scripts, and only those with the skill and wit can free them.

Each day, you'll face a new challenge, a piece of code haunted by ghostly bugs. Your task? Fix the code, set the number free, and slowly uncover the mystical sequence that holds immense power.

👻 Day 1 Challenge👻

In the hallowed halls of the first spectral challenge, an ethereal riddle awaits. The mischievous spirits, playful in their haunting, have left behind a broken PHP script. Amidst the eerie echoes and ghostly apparitions, a number is imprisoned, crying out for release.

As you traverse the corridors of this haunted code mansion, remember: In the world of code, things are not always what they seem. While humans might start counting from one, arrays have a trick up their sleeve. Their tale begins at zero, a fact you must believe.

Listen closely to the whispers of the lingering souls. They speak in tongues of loops and variables, of echoes and arrays. Muster your courage, trust your skill, and free the number trapped within. Only then can you move forward, to face the next day's eerie forays.

PHP:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spooky Challenge - Day 1</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background: url('https://png.pngtree.com/thumb_back/fh260/background/20230617/pngtree-halloween-wallpapers-and-backgrounds-for-laptop-or-desktop-image_2968567.jpg') no-repeat center center fixed;
            background-size: cover;
            color: red;
            text-align: center;
            padding-top: 50px;
        }
    </style>
</head>
<body>
    <h1>Welcome to the Haunted Code Mansion</h1>
    <p>The ghosts in this mansion have messed up the code. Can you fix it and find the hidden number?</p>

    <?php
    $hiddenNumbers = array(9, 4, 2, 7, 5);
    $crypticMessage = "The second spirit whispers the number.";
 
    // The ghosts have tampered with the code below, fix it to reveal the number.
    echo "The hidden number is: " . $hiddenNumbers[5];
    ?>

</body>
</html>

If you need an online compiler to test your solution, you can use this link:
🔗 Online PHP Compiler

🔗 Useful Resource: For a deep dive into PHP arrays and their intricacies, consider exploring W3Schools' PHP Array Tutorial.

Good luck, and may the spirits guide you on this eerie journey! Remember, each number you free brings you one step closer to the grand revelation on the final day. Stay vigilant, and don't let the ghosts fool you! And please, no sharing of answers until tomorrow. Let everyone enjoy the thrill of the hunt!

🎃 Day 1 Solution Unearthed 🎃

Congratulations, intrepid code-witcher! By navigating the haunted halls of the PHP mansion and deciphering the riddles of the spirits, you've unveiled the trapped number and set it free.

The Spirit's Trap Revealed:
The ethereal chains binding the number were twined around the concept of arrays. In the spectral realm of PHP, arrays start their tale from the position 0, not 1. This ghostly misdirection was the key to the spirit's playful deception.
Here's the corrected incantation that banished the shadows:


PHP:
<?php
echo "The hidden number is: " . $hiddenNumbers[2];
?>

With the right chant, the number "2" emerged from the shadows, clear and bright. Rest now, for you've done well. But keep your wits about you; more challenges lurk in the nights to come...
 
Last edited:
Tomorrow, do you want the whole code or just the number?
I will show my solution and number tomorrow evening and you can do the same, will be cool to see others' versions of the solution 🙂 for now, though you are welcome to talk and help each other try and work the solution out 🙂
 
So by pumpkins like spirits, 3rd so 2 but probably second so 4. Like my code for second.
PHP:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spooky Challenge - Day 1</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background: url('https://png.pngtree.com/thumb_back/fh260/background/20230617/pngtree-halloween-wallpapers-and-backgrounds-for-laptop-or-desktop-image_2968567.jpg') no-repeat center center fixed;
            background-size: cover;
            color: red;
            text-align: center;
            padding-top: 50px;
        }
    </style>
</head>
<body>
    <h1>Welcome to the Haunted Code Mansion</h1>
    <p>The ghosts in this mansion have messed up the code. Can you fix it and find the hidden number?</p>

    <?php
    $hiddenNumbers = array(9, 4, 2, 7, 5);
    $crypticMessage = "The second spirit whispers the number.";
 
    // The ghosts have tampered with the code below, fix it to reveal the number.
    echo "The hidden number is: " . $hiddenNumbers[1];
    //X E.
    ?>

</body>
</html>

Just change that last 1 to a 2 for like my other answer, 2. I get that because second big pumpkin has 3 pumpkins in a trail from it.
X E.
 
So boys and girls, day 1 has come to a close and you are correct, the hidden number is 2. This is a play of words and code, Looking at the array:-

Code:
array(9, 4, 2, 7, 5);

The second digit is 4, but as you and i know an array starts with 0 so the end digit would in fact be number 2. Well done for getting it right JosiahMaybe and i would love to see your workings menator01. I will be uploading day 2 in a few moments 🙂
 
Back
Top Bottom