Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Python 2, 139 133 129 bytes

n=input() for i in range(9):w=' ?|'[i&2];s=' / /\/ /\_ /\ \/\__ \/\ \/_ \/ /\/ /'[i::9]*n;s=(s,' %s '%s[1:-1])[i%4>1];print w+s+w 

This one just builds and prints line by line.

Here's the code in ungolfed form:

n=int(input()) # The list with all the knot pieces l= [' __ ', '/ \\', ' /\/', '/\/ ', '\ \/', '/\ \\', ' /\/', '/\/ ', '\__/'] # The first and last columns w = ' || || ' # Loop for each row for i in range(9): # Exception for the first and last character in the knot (in some rows) s = l[i]*n if i % 4 > 1: s = ' ' + s[1:-1] + ' ' # Print the knot for this row print(w[i] + s + w[i]) 

Edit: I changed the language to python 2, to be compatible with my answer for #3my answer for #3 (and it also saves 6 more bytes)

Python 2, 139 133 129 bytes

n=input() for i in range(9):w=' ?|'[i&2];s=' / /\/ /\_ /\ \/\__ \/\ \/_ \/ /\/ /'[i::9]*n;s=(s,' %s '%s[1:-1])[i%4>1];print w+s+w 

This one just builds and prints line by line.

Here's the code in ungolfed form:

n=int(input()) # The list with all the knot pieces l= [' __ ', '/ \\', ' /\/', '/\/ ', '\ \/', '/\ \\', ' /\/', '/\/ ', '\__/'] # The first and last columns w = ' || || ' # Loop for each row for i in range(9): # Exception for the first and last character in the knot (in some rows) s = l[i]*n if i % 4 > 1: s = ' ' + s[1:-1] + ' ' # Print the knot for this row print(w[i] + s + w[i]) 

Edit: I changed the language to python 2, to be compatible with my answer for #3 (and it also saves 6 more bytes)

Python 2, 139 133 129 bytes

n=input() for i in range(9):w=' ?|'[i&2];s=' / /\/ /\_ /\ \/\__ \/\ \/_ \/ /\/ /'[i::9]*n;s=(s,' %s '%s[1:-1])[i%4>1];print w+s+w 

This one just builds and prints line by line.

Here's the code in ungolfed form:

n=int(input()) # The list with all the knot pieces l= [' __ ', '/ \\', ' /\/', '/\/ ', '\ \/', '/\ \\', ' /\/', '/\/ ', '\__/'] # The first and last columns w = ' || || ' # Loop for each row for i in range(9): # Exception for the first and last character in the knot (in some rows) s = l[i]*n if i % 4 > 1: s = ' ' + s[1:-1] + ' ' # Print the knot for this row print(w[i] + s + w[i]) 

Edit: I changed the language to python 2, to be compatible with my answer for #3 (and it also saves 6 more bytes)

Golfed 4 more bytes (thanks Sp3000!)
Source Link
Matty
  • 511
  • 4
  • 7

Python 2, 133139 133 129 bytes

n=input() for i in range(9):w=(3*' w=' ||')[i];s='?|'[i&2];s=' / /\/ /\_ /\ \/\__ \/\ \/_ \/ /\/ /'[i::9]*n;s=(s,' '+s[1%s '%s[1:-1]+' '1])[i%4>1];print w+s+w 

This one just builds and prints line by line.

Here's the code in ungolfed form:

n=int(input()) # The list with all the knot pieces l= [' __ ', '/ \\', ' /\/', '/\/ ', '\ \/', '/\ \\', ' /\/', '/\/ ', '\__/'] # The first and last columns w = ' || || ' # Loop for each row for i in range(9): # Exception for the first and last character in the knot (in some rows) s = l[i]*n if i % 4 > 1: s = ' ' + s[1:-1] + ' ' # Print the knot for this row print(w[i] + s + w[i]) 

Edit: I changed the language to python 2, to be compatible with my answer for #3 (and it also saves 6 more bytes)

Python 2, 133 bytes

n=input() for i in range(9):w=(3*'  ||')[i];s=' / /\/ /\_ /\ \/\__ \/\ \/_ \/ /\/ /'[i::9]*n;s=(s,' '+s[1:-1]+' ')[i%4>1];print w+s+w 

This one just builds and prints line by line.

Here's the code in ungolfed form:

n=int(input()) # The list with all the knot pieces l= [' __ ', '/ \\', ' /\/', '/\/ ', '\ \/', '/\ \\', ' /\/', '/\/ ', '\__/'] # The first and last columns w = ' || || ' # Loop for each row for i in range(9): # Exception for the first and last character in the knot (in some rows) s = l[i]*n if i % 4 > 1: s = ' ' + s[1:-1] + ' ' # Print the knot for this row print(w[i] + s + w[i]) 

Edit: I changed the language to python 2, to be compatible with my answer for #3 (and it also saves 6 more bytes)

Python 2, 139 133 129 bytes

n=input() for i in range(9):w=' ?|'[i&2];s=' / /\/ /\_ /\ \/\__ \/\ \/_ \/ /\/ /'[i::9]*n;s=(s,' %s '%s[1:-1])[i%4>1];print w+s+w 

This one just builds and prints line by line.

Here's the code in ungolfed form:

n=int(input()) # The list with all the knot pieces l= [' __ ', '/ \\', ' /\/', '/\/ ', '\ \/', '/\ \\', ' /\/', '/\/ ', '\__/'] # The first and last columns w = ' || || ' # Loop for each row for i in range(9): # Exception for the first and last character in the knot (in some rows) s = l[i]*n if i % 4 > 1: s = ' ' + s[1:-1] + ' ' # Print the knot for this row print(w[i] + s + w[i]) 

Edit: I changed the language to python 2, to be compatible with my answer for #3 (and it also saves 6 more bytes)

Changed language to python2 (from python3), to have the same language in all answers (and it saves bytes).
Source Link
Matty
  • 511
  • 4
  • 7

Python 32, 139133 bytes

n=int(inputn=input()) for i in range(9):w=(3*' ||')[i];s=' / /\/ /\_ /\ \/\__ \/\ \/_ \/ /\/ /'[i::9]*n;s=(s,' '+s[1:-1]+' ')[i%4>1];print( w+s+w) 

This one was pretty easy, just buildbuilds and print at onceprints line by line.

HeresHere's the code in ungolfed form:

n=int(input()) # The list with all the knot pieces l= [' __ ', '/ \\', ' /\/', '/\/ ', '\ \/', '/\ \\', ' /\/', '/\/ ', '\__/'] # The first and last columns w = ' || || ' # Loop for each row for i in range(9): # Exception for the first and last character in the knot (in some rows) s = l[i]*n if i % 4 > 1: s = ' ' + s[1:-1] + ' ' # Print the knot for this row print(w[i] + s + w[i]) 

Edit: I changed the language to python 2, to be compatible with my answer for #3 (and it also saves 6 more bytes)

Python 3, 139 bytes

n=int(input()) for i in range(9):w=(3*' ||')[i];s=' / /\/ /\_ /\ \/\__ \/\ \/_ \/ /\/ /'[i::9]*n;s=(s,' '+s[1:-1]+' ')[i%4>1];print(w+s+w) 

This one was pretty easy, just build and print at once line by line

Heres the code in ungolfed form:

n=int(input()) # The list with all the knot pieces l= [' __ ', '/ \\', ' /\/', '/\/ ', '\ \/', '/\ \\', ' /\/', '/\/ ', '\__/'] # The first and last columns w = ' || || ' # Loop for each row for i in range(9): # Exception for the first and last character in the knot (in some rows) s = l[i]*n if i % 4 > 1: s = ' ' + s[1:-1] + ' ' # Print the knot for this row print(w[i] + s + w[i]) 

Python 2, 133 bytes

n=input() for i in range(9):w=(3*' ||')[i];s=' / /\/ /\_ /\ \/\__ \/\ \/_ \/ /\/ /'[i::9]*n;s=(s,' '+s[1:-1]+' ')[i%4>1];print w+s+w 

This one just builds and prints line by line.

Here's the code in ungolfed form:

n=int(input()) # The list with all the knot pieces l= [' __ ', '/ \\', ' /\/', '/\/ ', '\ \/', '/\ \\', ' /\/', '/\/ ', '\__/'] # The first and last columns w = ' || || ' # Loop for each row for i in range(9): # Exception for the first and last character in the knot (in some rows) s = l[i]*n if i % 4 > 1: s = ' ' + s[1:-1] + ' ' # Print the knot for this row print(w[i] + s + w[i]) 

Edit: I changed the language to python 2, to be compatible with my answer for #3 (and it also saves 6 more bytes)

Fixed typo
Source Link
Matty
  • 511
  • 4
  • 7
Loading
Source Link
Matty
  • 511
  • 4
  • 7
Loading