Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --What is the first digit of the number five hundred seventy-five million three hundred seventy-eight thousand eight hundred sixty-one?
- --I DON'T KNOW !
- --This is easier to do for a computer than a human
- --This is the worst captcha i've ever seen
- --please, don't use that kind of captcha
- units = {}
- units.one = 1
- units.two = 2
- units.three = 3
- units.four = 4
- units.five = 5
- units.six = 6
- units.seven = 7
- units.eight = 8
- units.nine = 9
- deci = {}
- deci.twenty = 2
- deci.thirty = 3
- deci.forty = 4
- deci.fifty = 5
- deci.sixty = 6
- deci.seventy = 7
- deci.eighty = 8
- deci.ninety = 9
- special = {}
- special.ten = {1, 0}
- special.eleven = {1, 1}
- special.twelve = {1, 2}
- special.thirteen = {1, 3}
- special.fourteen = {1, 4}
- special.fifteen = {1, 5}
- special.sixteen = {1, 6}
- special.seventeen = {1, 7}
- special.eighteen = {1, 8}
- special.nineteen = {1, 9}
- function nullret()
- return "_","_","_","_","_","_","_","_","_"
- end
- function breakDown9d(tn)
- --tn: text number
- print(tn)
- --in case the whole captcha was inputted and not just the text number
- if string.find(tn, "of the number") then
- tn = string.match(tn, "of the number (.*)\?")
- elseif string.match(tn, "^ ") then
- tn = string.match(tn, "^ (.*)")
- end
- if string.find(tn, "\?") then
- tn = string.match(tn, "(.*)\?")
- end
- --now tn looks like:
- --five hundred seventy-five million three hundred seventy-eight thousand eight hundred sixty-one
- local a,b,c,d,e,f,g,h,i, rest
- local millions,thousands,hundreds
- millions, rest = string.match(tn, "(.*) million (.*)")
- if not rest then return nullret() end
- thousands, rest = string.match(rest, "(.*) thousand (.*)")
- hundreds = rest
- --split "five hundred seventy-five million three hundred seventy-eight thousand eight hundred sixty-one"
- --millions = five hundred seventy-five
- --thousands = three hundred seventy-eight
- --hundreds = eight hundred sixty-one
- a,b,c = breakDown3d(millions)
- d,e,f = breakDown3d(thousands)
- g,h,i = breakDown3d(hundreds)
- return a,b,c,d,e,f,g,h,i
- end
- function breakDown3d(tn)
- --tn looks like something like
- --"five hundred seventy-five"
- local a,b,c
- --split "one hundred twenty-six" -> "one", "twenty-six"
- --the ? is for the 9/100 chance of just getting "x hundred". Makes the space optional.
- a, rest = string.match(tn, "(.*) hundred ?(.*)")
- a = units[a] or "_"
- --because units["one"] is 1
- --if units[a] is undefined, or sets the value to "_"
- --if not rest then
- -- --"one hundred"
- -- a = 0
- -- rest = tn
- --end
- --parsing the last two digits. Lots of cases.
- if string.find(rest, "-") then
- --ex case: "one hundred [twenty-six]"
- b, c = string.match(rest, "(.*)\-(.*)")
- b = deci[b]
- c = units[c]
- elseif special[rest] then
- --ex case: "one hundred [twelve,thirteen...]"
- b, c = unpack(special[rest])
- elseif units[rest] then
- --ex case: "one hundred [four,five,six...]"
- b = 0
- c = units[rest]
- elseif deci[rest] then
- --ex case: "one hundred [twenty,thirty...]"
- b = deci[rest]
- c = 0
- elseif rest == "" then
- --ex case: "one hundred[]"
- b = 0
- c = 0
- end
- return a or "_", b or "_", c or "_"
- end
- --example of use
- local captcha = "What is the fifth digit of the number six hundred seventy-six million seven hundred eighty-two thousand five hundred seventeen? "
- local n = {breakDown9d(captcha)}
- print(table.concat(n, " "))
- print("1 2 3 4 5 6 7 8 9")
Add Comment
Please, Sign In to add comment