#title: Interlock Sheet (plain python)
# Knit a sheet with alternating rows of back/front and front/back knits; effectively two [[1x1 rib]] sheets interlocked with each-other.

#Write header:
print(';!knitout-2')
print(';;Machine: SWGN2')
print(';;Carriers: 1 2 3 4 5 6 7 8 9 10')

#Parameters:
min = 1 #needle number of left edge
max = 20 #needle number of right edge
rows = 20 #number of rows to knit
carrier = "3" #carrier name

#Because of its structure, interlock does not require a [[cast-on]].
#Instead, we just bring the yarn in and start knitting:
print(f"inhook {carrier}")
print(f"x-stitch-number 105")

# ---- interlock sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#Even, left-going row:
		for n in range(max, min-1, -1):
			if r == 0 and n == min:
				#Skip the leftmost stitch in the first row to prevent leftmost column from unravelling:
				continue
			if (max - n) % 2 == 0:
				print(f"knit - f{n} {carrier}")
			else:
				print(f"knit - b{n} {carrier}")
	else:
		#Odd, right-going row:
		for n in range(min, max+1, 1):
			if (max - n) % 2 == 0:
				print(f"knit + b{n} {carrier}")
			else:
				print(f"knit + f{n} {carrier}")
	
	#The yarn inserting hook can stop holding the yarn tail after two rows have been knit:
	if r == 1:
		print(f"releasehook {carrier}")

# ---- take carrier out and drop remaining loops ----
#Take carrier out with yarn inserting hook:
print(f"outhook {carrier}")

#drop loops:
for n in range(min, max+1, 1):
	print(f"drop f{n}")
	print(f"drop b{n}")
