Skip to content

Instantly share code, notes, and snippets.

@coleww
Last active August 29, 2015 14:04
Show Gist options
  • Save coleww/3eaf8209aba35f809f41 to your computer and use it in GitHub Desktop.
Save coleww/3eaf8209aba35f809f41 to your computer and use it in GitHub Desktop.
mbot codegolf problems
problems for mbot codegolf tournament script thing.
mbot will spit a prompt out into a room, and provide a sample input and output.
code is run in a node sandbox like so:
"(function($){" + CODE_STRING_FROM_USER + "})(" + case.input + ")"
So a golfers response has access to the input via the $ variable, and must return an output that matches the case.output.
I AM just assuming that hubot scripts maintain state while the server is up. If that is false then needs mongo. BUT it will save high scores also, presuming state is maintained...
problems = [
{
prompt: "reverse a $tring!",
cases: [
{
input: "testcase",
output: "esactset"
},
{
input: "1337",
output: "7331"
},
{
input: "",
output: ""
}
]
},
{
prompt: "return the $th fibonacci number (0 indexed!)",
cases: [
{
input: 6,
output: 8
},
{
input: 0,
output: 0
},
{
input: 9,
output: 34
},
{
input: 1,
output: 1
}
]
},
{
prompt: "compute the factorial of $",
cases: [
{
input: 5,
output: 120
},
{
input: 17,
output: 355687428096000
},
{
input: 0,
output: 1
},
{
input: 1,
output: 1
}
]
},
{
prompt: "return the $th prime number (0 indexed!)",
cases: [
{
input: 0,
output: 2
},
{
input: 19,
output: 29
},
{
input: 999,
output: 7919
},
{
input: 1,
output: 3
}
]
},
{
prompt: "return unique elements from an array $",
cases: [
{
input: [],
output: []
},
{
input: [1],
output: [1]
},
{
input: [1, 1, 3, 2, 12, 2],
output: [1, 3, 2, 12]
},
{
input: [5, 1, 2, 3, 4, 1, 3, 4, 2],
output: [5, 1, 2, 3, 4]
}
]
},
{
prompt: "do FIZZBUZZ for the first $ numbers (onecontinuouslinenospaces)",
cases: [
{
input: 0,
output: ""
},
{
input: 1,
output: "1"
},
{
input: 3,
output: "12FIZZ"
},
{
input: 5
output: "12FIZZ4BUZZ"
},
{
input: 15
output: "12FIZZ4BUZZFIZZ78FIZZBUZZ11FIZZ1314FIZZBUZZ"
}
]
},
{
prompt: "true/false: the given string contains the first name of a lead character from Friends ",
cases: [
{
input: "sampleMonicasample",
output: true
},
{
input: "caseinsensitivechandleryes",
output: true
},
{
input: "",
output: false
},
{
input: "frasierseinfeldblossom",
output: false
},
{
input: "jo ey",
output: false
},
{
input: "rOssrAchelPhoebE",
output: true
}
]
},
{
prompt: "convert a based 10 number $ to its binary string",
cases: [
{
input: 2,
output: "10"
},
{
input: 0,
output: "0"
},
{
input: 1,
output: "1"
},
{
input: 100,
output: "1100100"
}
]
},
{
prompt: "given an array $ of cards, return the blackjack score, or 'BUST!' if busted, or 'BLACKJACK!' if blackjack",
cases: [
{
input: ["A", 1, "K", 4, "Q"],
output: "BUST!"
},
{
input: ["A", "K"],
output: "BLACKJACK!"
},
{
input: [1, 2, 3],
output: "6"
},
{
input: [1, "A", 9],
output: "21"
},
{
input: [2, "A", 9],
output: "12"
},
{
input: ["K", "J"],
output: "20"
}
]
},
{
prompt: "ROCK PAPER SCISSORS: given an array $ with RPS hands, return index of winner or nil if draw",
cases: [
{
input: ["rock", "paper"],
output: 1
},
{
input: ["scissors", "paper"],
output: 0
},
{
input: ["scissors", "rock"],
output: 1
},
{
input: ["rock", "rock"],
output: nil
}
]
},
{
prompt: "apply a ROT-13 cipher to the input string $",
cases: [
{
input: "test",
output: "grfg"
},
{
input: "a bunch of words",
output: "n ohapu bs jbeqf"
},
{
input: "Varying CaSes Oh MY!!!",
output: "Inelvat PnFrf Bu ZL!!!"
},
{
input: "numb3r5_t0O",
output: "ahzo3e5_g0B"
},
{
input: "",
output: ""
}
]
}
]
@coleww
Copy link
Author

coleww commented Jul 20, 2014

!!!!!!!!!!!! if it had access to a mongodb it could compute the "par" for each problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment