ELF Code Python
Introduction
KringleCon - Dining Room
Conversations
Instructions
Solution
Level 0
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 munchkin's 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
Level 1
import elf, munchkins, levers, lollipops, yeeters, pits
lollipop = lollipops.get(0)
elf.moveTo(lollipop.position)
elf.moveUp(10)
Alternate solution:
import elf, munchkins, levers, lollipops, yeeters, pits
elf.moveTo({"x":2,"y":2})
Level 2
import elf, munchkins, levers, lollipops, yeeters, pits
# Gets all lollipops as a list
all_lollipops = lollipops.get()
# Can set lollipop1 using:
lollipop1 = all_lollipops[1]
lollipop0 = all_lollipops[0]
elf.moveTo(lollipop1.position)
elf.moveTo(lollipop0.position)
elf.moveLeft(3)
elf.moveUp(6)
Alternate solution:
import elf, munchkins, levers, lollipops, yeeters, pits
elf.moveTo({"x":2,"y":10})
elf.moveTo({"x":5,"y":8})
elf.moveTo({"x":2,"y":2})
Level 3
Lever #0 Objective: Add 2 to the returned int value of running the function lever0.data(). For example, if you wanted to multiply the value by 3 and store to a variable, you could do:
sum = lever0.data() * 3
Then submit the sum using:
lever0.pull(sum)
import elf, munchkins, levers, lollipops, yeeters, pits
lever0 = levers.get(0)
answerL0 = lever0.data() + 2
pop0 = lollipops.get(0)
elf.moveTo(lever0.position)
lever0.pull(answerL0)
elf.moveTo(pop0.position)
elf.moveUp(10)
Alternate solution:
import elf, munchkins, levers, lollipops, yeeters, pits
l0 = levers.get(0)
lAns0 = l0.data() + 2
elf.moveTo({"x":6,"y":6})
l0.pull(lAns0)
elf.moveTo({"x":2,"y":2})
Level 4
Lever 4 - Submit any string object to this lever using lever.pull(string_object). Lever 3 - Submit ANY bool object to this lever using lever.pull(bool_object) Lever 2 - Submit ANY int or float object to this lever using lever.pull(int_object) Lever 1 - Submit ANY list object to this lever using lever.pull(list_object) Lever 0 - Submit ANY dict object to this lever using lever.pull(dict_object)
import elf, munchkins, levers, lollipops, yeeters, pits
lever0, lever1, lever2, lever3, lever4 = levers.get()
elf.moveLeft(2)
lever4.pull("A String")
elf.moveTo(lever3.position)
lever3.pull(True)
elf.moveTo(lever2.position)
lever2.pull(32)
elf.moveTo(lever1.position)
lever1.pull(list(("one", "two", "three")))
elf.moveTo(lever0.position)
lever0.pull({"country" : "North Pole", "cons" : 2})
elf.moveUp(2)
Level 5
Lever 4 - Calling lever.data() will return a string to you. Take this string and concatenate it with a string of " concatenate". Submit these two concatenated strings using lever.pull(concatenated_strings) .
Lever 3 - Submit the inverse bool object returned by pulling lever.data() to this lever using lever.pull(inversed_bool_object). For example, if True is returned, then you must submit False.
Lever 2 - Add one 1 + to the integer returned from running lever.data(). Then submit this modified int using lever.pull(int_one_plus).
Lever 1 - Append the int 1 to the end of the list returned from running lever.data(). Submit this new list using lever.pull(appended_list).
Lever 0 - lever.data() will return a dict object. Add a key and value pair to this dictionary of "strkey":"strvalue" and then submit this modified dictionary using lever.pull(modified_dict).
import elf, munchkins, levers, lollipops, yeeters, pits
lever0, lever1, lever2, lever3, lever4 = levers.get()
elf.moveTo(lever4.position)
ans4 = lever4.data() + " concatenate"
lever4.pull(ans4)
elf.moveTo(lever3.position)
ans3 = lever3.data()
lever3.pull(not ans3)
elf.moveTo(lever2.position)
ans2 = lever2.data() + 1
lever2.pull(ans2)
elf.moveTo(lever1.position)
ans1 = lever1.data()
ans1.append(1)
lever1.pull(ans1)
elf.moveTo(lever0.position)
ans0 = lever0.data()
ans0["strkey"]="strvalue"
lever0.pull(ans0)
elf.moveUp(2)
Level 6
Lever 0 -
Calling lever.data() will return a boolean, a number, a list of integers, a string, or a dict with "a" and an integer to you. For a boolean, return the inverse. For a number, return double the number. For a list of integers, return that list with each integer incremented by 1. For a string, return the string concatenated with itself. For a dict, return the dict with a's value + 1. Submit this response using lever.pull(conditional_answer) .
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:
for a in data:
a = a + 1
elf.moveTo(lever.position)
lever.pull(data)
elf.moveUp(2)
Level 7
import elf, munchkins, levers, lollipops, yeeters, pits
elf.moveLeft(1)
for num in range(2):
elf.moveUp(11)
elf.moveLeft(2)
elf.moveDown(11)
elf.moveLeft(2)
elf.moveLeft(1)
elf.moveUp(10)
Alternate solution:
import elf, munchkins, levers, lollipops, yeeters, pits
elf.moveLeft(1)
elf.moveTo({"x":11,"y":1})
elf.moveTo({"x":9,"y":12})
elf.moveTo({"x":7,"y":1})
elf.moveTo({"x":5,"y":12})
elf.moveTo({"x":2,"y":2})
Level 8
Lever 0 - Use lever.data() to be returned an array similar to:
[1, 2, 3, "c", "d", 4]
Add the string "munchkins rule" to the front of this array. The example array above would become:
["munchkins rule", 1, 2, 3, "c", "d", 4]
Then submit this new array to elf.pull_lever(answer)
Munchkin 0 - Use munchkin.ask() and I will return a JSON object similar to:
{
"2ghd3":327,
"pwmcojfd":23,
"ivntirc":"asjkdhfg",
"qpwo":76,
"szixuchv":"lollipop",
"aiusywt":4,
"xmzxcv":"sdfhj",
}
Use munchkin.answer(answer) to tell me the name of the key with a value of lollipop. In this example, the solution would be munchkin.answer("szixuchv").
import elf, munchkins, levers, lollipops, yeeters, pits
munchkin = munchkins.get(0)
data = munchkin.ask()
ans = [key for key in data if data[key] == "lollipop"]
#print(ans[0])
all_lollipops = lollipops.get()
for lollipop in all_lollipops:
elf.moveTo(lollipop.position)
elf.moveLeft(8)
elf.moveUp(2)
munchkin.answer(ans[0])
elf.moveUp(2)
Alternate solution:
import elf, munchkins, levers, lollipops, yeeters, pits
all_lollipops = lollipops.get()
munchkin = munchkins.get(0)
data = munchkin.ask()
ans = [key for key in data if data[key] == "lollipop"]
for lollipop in all_lollipops:
elf.moveTo(lollipop.position)
elf.moveTo({"x":2,"y":4})
munchkin.answer(ans[0])
elf.moveUp(2)
Complete!
Next: term-10