Elf Code Python Terminal Challenge
Elf Introduction
Help Rib Bonbowford in the Dining Room
Hello, I'm Ribb Bonbowford. Nice to meet you!
Are you new to programming? It's a handy skill for anyone in cyber security.
This here machine lets you control an Elf using Python 3. It’s pretty fun, but I’m having trouble getting beyond Level 8.
Tell you what… if you help me get past Level 8, I’ll share some of my SQLi tips with you. You may find them handy sometime around the North Pole this season.
Most of the information you'll need is provided during the game, but I'll give you a few more pointers, if you want them.
Not sure what a lever requires? Click it in the Current Level Objectives panel.
You can move the elf with commands like elf.moveLeft(5)
, elf.moveTo({"x":2,"y":2})
, or elf.moveTo(lever0.position)
.
Looping through long movements? Don't be afraid to moveUp(99) or whatever. You elf will stop at any obstacle.
You can call functions like myFunction()
. If you ever need to pass a function to a munchkin, you can use myFunction
without the ()
.
Hints and Other Resources
Hints from talking with Rib
Lever Requirements
Not sure what a lever requires? Click it in the Current Level Objectives
panel.
Moving the Elf
You can move the elf with commands like elf.moveLeft(5)
, elf.moveTo({"x":2,"y":2})
, or elf.moveTo(lever0.position)
.
Bumping into Walls
Looping through long movements? Don't be afraid to moveUp(99)
or whatever. You elf will stop at any obstacle.
Function Calls
You can call functions like myFunction()
. If you ever need to pass a function to a munchkin, you can use myFunction
without the ()
.
Other Resources
The Ultimate Python Beginners's Handbook
https://www.freecodecamp.org/news/the-python-guide-for-beginners/
Open the Terminal
Open the Elf Code Python game in the Dining Room
Screenshot
Solution
For this challenge you must write Python code for each level to guide the elf to his objective.
Level 1 - Get Moving
Move the elf to collect the lollipops and get to the KringleCon entrance at dict location {"x":2,"y":2}
Use no more than 8 lines of code and 6 object function calls.
1 2 3 4 5 |
|
Level 2 - Get moveTo'ing
Move the elf to collect the lollipops and get to the KringleCon entrance.
Use no more than 10 lines of code and 6 object function calls.
1 2 3 4 5 6 7 |
|
Level 3 - Don't Get Yeeted!
Move the elf to collect the lollipops and get to the KringleCon entrance.
Use no more than 10 lines of code and 6 object function calls.
1 2 3 4 5 6 7 8 9 |
|
Level 4 - Data Types
Pull ALL of the levers by submitting the requested data for each using lever.pull(data) to disable the Yeeter trap at the KringleCon entrance.
Use no more than 18 lines of code and 15 object function calls.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Level 5 - Conversions and Comparisons
Pull all of the levers by submitting the requested data for each using lever.pull(data) to disable the Yeeter trap at the KringleCon entrance.
Use no more than 23 lines of code and 18 object function calls.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
Level 6 - Types and Conditionals
Move the elf to the lever. Get the lever data lever.data() and perform the appropriate action to the data. Submit the modified data using lever.pull(modified_data).
Use no more than 23 lines of code and 6 object function calls.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
Level 7 - Up Down Loopiness
Navigate through the obstacles and collect the lollipop before arriving at the KringleCon entrance.
Use no more than 12 lines of code and 12 object function calls.
1 2 3 4 5 6 7 8 9 10 |
|
Level 8 - Two Paths, Your Choice
Navigate past the obstacles and avoid the munchkin watching the KringleCon entrance.
Use no more than 12 lines of code and 10 object function calls.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
1 2 3 4 5 6 7 8 9 10 11 |
|
Completion
Talk to Rib to receive hints for Objective 12) Frost Tower Website Checkup
Gosh, with skills like that, I'll bet you could help figure out what's really going on next door...
And, as I promised, let me tell you what I know about SQL injection.
I hear that having source code for vulnerability discovery dramatically changes the vulnerability discovery process.
I imagine it changes how you approach an assessment too.
When you have the source code, API documentation becomes tremendously valuable.
Who knows? Maybe you'll even find more than one vulnerability in the code.
Bonus Level 9 - Yeeter Swirl
Follow the swirl being careful not to step on any traps (or get yeeted off the map). Note: The elf.moveTo(object) function has been disabled for this challenge.
Use no more than 27 lines of code and 25 object function calls.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Bonus Level 10 - Munchkin Dodging Finale
Dodge the munchkins to get to the KringleCon entrance.
Use no more than 17 lines of code and 15 object function calls.
1 2 3 4 5 6 7 8 9 10 |
|