num1=0
num2=0
num3=0

green=Color.new(0,255,0)
red = Color.new(255,0,0)

select1=red
select2=red
select3=red
select=1

oldpad=Controls.read()
while true do
screen:clear()
pad = Controls.read()

if select==1 then
	select1=green
	select2=red
	select3=red
end
if select==2 then
	select2=green
	select3=red
	select1=red
end

if select==3 then
	select3=green
	select2=red
	select1=red
end


if pad:right() and pad:right() ~= oldpad:right() and select==1 then
	num1 = num1+1
end
if pad:left() and pad:left() ~= oldpad:left() and select==1 then
	num1=num1-1
end

if pad:right() and pad:right() ~= oldpad:right() and select==2 then
	num2 = num2+1
end
if pad:left() and pad:left() ~= oldpad:left() and select==2 then
	num2=num2-1
end

if pad:right() and pad:right() ~= oldpad:right() and select==3 then
	num3 = num3+1
end
if pad:left() and pad:left() ~= oldpad:left() and select==3 then
	num3=num3-1
end

if pad:up() and pad:up() ~= oldpad:up() then
	select = select-1
end
if pad:down() and pad:down() ~= oldpad:down() then
	select = select+1
end
if select>3 then
	select=1
end
if select<1 then
	select=3
end
if pad:start() then
	dofile("./System/poloptions.lua")
	break;
end
screen:print(100,100,"UN-Foiled:  (" .. num1 .. "x+" .. num2 .. ")(" .. num1 .. "x+" .. num3 .. ")",Color.new(0,255,255))
screen:print(100,120,"Foiled:     " .. num1 .. "x^2+" .. num2+num3 .. "x+" .. (num3*num2)/3, green)
screen:print(100,140,num1,select1)
screen:print(100,160,num2,select2)
screen:print(100,180,num3,select3)

screen.waitVblankStart()
screen.flip()
oldpad=pad
end
