1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
function Bad (a)
local new_str = ""
local need = false
for i = 1, string.len(a)-1 do
local char = string.sub(a, i, i)
local char_next = string.sub(a, i+1, i+1)
if string.match(char, "%u") and string.match(char_next, "%l") then
if char == string.lower(char_next) then
local new = {}
for j = 0,string.len(a) do
if j ~= i and j~= i+1 then
table.insert(new,string.sub(a, j, j))
end
end
new_str = table.concat(new)
-- print ("maybe not here ", new_str)
need= true
break
end
elseif string.match(char, "%l") and string.match(char_next, "%u") then
if string.upper(char) == char_next then
local new = {}
for j = 0,string.len(a) do
if j ~= i and j~= i+1 then
table.insert(new,string.sub(a, j, j))
end
end
new_str = (table.concat(new))
--print ("maybe not ", new_str)
need=true
break
end
end
end
-- print ("new " , new_str)
if need then
Bad(new_str)
else
print(a)
end
end
Bad("WeEeekly")
Bad("abc")
Bad("abBAdD")
|