Elf Code Python

Term

Details

  • Location: KringleCon/Dining Room
  • Elf: Ribb Bonbowford

Elf's Objective Message

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 ().

This terminal is located in the Dining Room at KringleCon. Solving this terminal challenge provides additional hints for objective 12. To view the hints for this terminal challenge use the menu on the left.

Term

To solve this terminal challenge you need to solve 9 levels. The solution for each of these levels is provided below:

Answers for Levels

  import elf, munchkins, levers, lollipops, yeeters, pits
  # Grab our lever object
  lever = levers.get(0)
  munchkin = munchkins.get(0)
  lollipop = lollipops.get(0)
  # move to lever position
  elf.moveTo(lever.position)
  # get lever int and add 2 and submit val
  leverData = lever.data() + 2
  lever.pull(leverData)
  # Grab lollipop and stand next to munchkin
  elf.moveLeft(1)
  elf.moveUp(8)
  # Solve the munchkins challenge
  munchList = munchkin.ask() # e.g. [1, 3, "a", "b", 4]
  answer_list = []
  for elem in munchList:
      if type(elem) == int:
          answer_list.append(elem)
  munchkin.answer(answer_list)
  elf.moveUp(2) # Move to finish
  import elf, munchkins, levers, lollipops, yeeters, pits
  elf.moveLeft(10)
  elf.moveUp(12)
  import elf, munchkins, levers, lollipops, yeeters, pits
  all_lollipops = lollipops.get()
  elf.moveTo(all_lollipops[1].position)
  elf.moveTo(all_lollipops[0].position)
  elf.moveLeft(3)
  elf.moveUp(8)
  import elf, munchkins, levers, lollipops, yeeters, pits
  lever0 = levers.get(0)
  lollipop0 = lollipops.get(0)
  elf.moveLeft(6)
  lever0.pull(lever0.data()+2)
  elf.moveTo(lollipop0.position)
  elf.moveUp(12)
  import elf, munchkins, levers, lollipops, yeeters, pits
  lever0, lever1, lever2, lever3, lever4 = levers.get()
  elf.moveLeft(2)
  lever4.pull("A String")
  elf.moveUp(2)
  lever3.pull(False)
  elf.moveUp(2)
  lever2.pull(2.3)
  elf.moveUp(2)
  lever1.pull([1,2])
  elf.moveUp(2)
  lever0.pull({"Santa": "Jack"})
  elf.moveUp(2)
  import elf, munchkins, levers, lollipops, yeeters, pits
  lever0, lever1, lever2, lever3, lever4 = levers.get()
  elf.moveLeft(2)
  lever4.pull(lever4.data()+" concatenate")
  elf.moveUp(2)
  lever3.pull(not lever3.data())
  elf.moveUp(2)
  lever2.pull(lever2.data()+1)
  elf.moveUp(2)
  a=lever1.data()
  a.append(1)
  lever1.pull(a)
  elf.moveUp(2)
  b=lever0.data()
  b.update({"strkey":"strvalue"})
  lever0.pull(b)
  elf.moveUp(2)
  import elf, munchkins, levers, lollipops, yeeters, pits
  lever = levers.get(0)
  data = lever.data()
  if type(data) == bool:
      data = not data
  elif type(data) == int:
      data = data * 2
  elif type(data) == list:
      data = [x+1 for x in data]
  elif type(data) == str:
      data = data + data
  elif type(data) == dict:
      data['a']=data['a']+1
  elf.moveUp(2)
  lever.pull(data)
  elf.moveUp(2)
  import elf, munchkins, levers, lollipops, yeeters, pits
  for num in range(3): #not sure if number is right
  elf.moveLeft(3)
  elf.moveUp(12)
  elf.moveLeft(3)
  elf.moveDown(12)
  import elf, munchkins, levers, lollipops, yeeters, pits
  all_lollipops = lollipops.get()
  for lollipop in all_lollipops:
      elf.moveTo(lollipop.position)
  munchkin = munchkins.get(0)
  elf.moveLeft(8)
  elf.moveUp(2)
  json=munchkin.ask()
  print (json)
  for x,y in enumerate(json):
      if (json[y]=="lollipop"):
         munchkin.answer(y)
  elf.moveUp(2)

Once you solve level 8 you will beat the game and be greeted with the following message:

Term