Jump to content

Module:USHRseats

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Swpb (talk | contribs) at 20:54, 5 February 2019. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

function p.USHRseats(frame)
	state = frame.args[1]
	if mw.ustring.len(state)>2 then
		state = frame:expandTemplate{ title = 'ConvertAbbrev/ISO 3166-2/US', args = {state} }
	end

	year = frame.args[2]
	if year then
		census_number = (year - math.fmod(year,10))/10 - 177
	end
		
	states = {
	AK = {'-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-',  1,  1,  1,  1,  1,  1},
	AL = {'-','-','-','-',  3,  5,  7,  7,  6,  8,  8,  9,  9, 10,  9,  9,  9,  8,  7,  7,  7,  7,  7},
	AR = {'-','-','-','-','-','-',  1,  2,  3,  4,  5,  6,  7,  7,  7,  7,  6,  4,  4,  4,  4,  4,  4},
	AZ = {'-','-','-','-','-','-','-','-','-','-','-','-','-',  1,  1,  2,  2,  3,  4,  5,  6,  8,  9},
	CA = {'-','-','-','-','-','-','-',  2,  3,  4,  6,  7,  8, 11, 20, 23, 30, 38, 43, 45, 52, 53, 53},
	CO = {'-','-','-','-','-','-','-','-','-','-',  1,  2,  3,  4,  4,  4,  4,  4,  5,  6,  6,  7,  7},
	CT = {},
	DE = {},
	FL = {},
	GA = {},
	HI = {},
	IA = {},
	ID = {},
	IL = {},
	IN = {},
	KS = {},
	KY = {},
	LA = {},
	MA = {},
	MD = {},
	ME = {},
	MI = {},
	MN = {},
	MO = {},
	MS = {},
	MT = {},
	NC = {},
	ND = {},
	NE = {},
	NH = {},
	NJ = {},
	NM = {},
	NV = {},
	NY = {},
	OH = {},
	OK = {},
	OR = {},
	PA = {},
	RI = {},
	SC = {},
	SD = {},
	TN = {},
	TX = {},
	UT = {},
	VA = {},
	VT = {},
	WA = {},
	WI = {},
	WV = {},
	WY = {}
	}

	if census_number then
		seats = states[state][census_number]
	else
		seats = states[state][#states[state]]
	end

	return seats
end

return p