Skip to content

Instantly share code, notes, and snippets.

@qmmr
Last active July 29, 2021 04:29
Show Gist options
  • Save qmmr/ace1346a55101a7cc4f6df9fe24c945e to your computer and use it in GitHub Desktop.
Save qmmr/ace1346a55101a7cc4f6df9fe24c945e to your computer and use it in GitHub Desktop.

Revisions

  1. qmmr revised this gist Mar 3, 2019. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion main.py
    Original file line number Diff line number Diff line change
    @@ -15,9 +15,11 @@


    def create_board(rows, columns):
    max_columns = 130
    max_rows = 11
    rows = int(rows)
    columns = int(columns)
    if columns <= 130:
    if columns <= max_columns and rows <= max_rows:
    for row in range(rows):
    if row % 2 == 0:
    for col in range(1, columns):
    @@ -34,6 +36,14 @@ def create_board(rows, columns):
    return True
    else:
    # Return False when matrix is not fitting the screen
    reason = ""
    if columns > max_columns and rows > max_rows:
    reason = "columns and rows"
    elif columns > max_columns:
    reason += "columns"
    elif rows > max_rows:
    reason += "rows"
    print("Sorry, cannot create the board, too many {0:s}.".format(reason))
    return False


  2. qmmr revised this gist Mar 1, 2019. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions main.py
    Original file line number Diff line number Diff line change
    @@ -15,10 +15,12 @@


    def create_board(rows, columns):
    rows = int(rows)
    columns = int(columns)
    if columns <= 130:
    for row in range(int(rows)):
    for row in range(rows):
    if row % 2 == 0:
    for col in range(1, int(columns)):
    for col in range(1, columns):
    if col % 2 == 1:
    if col != columns - 1:
    print(" ", end="")
  3. qmmr revised this gist Mar 1, 2019. 1 changed file with 28 additions and 4 deletions.
    32 changes: 28 additions & 4 deletions main.py
    Original file line number Diff line number Diff line change
    @@ -4,11 +4,35 @@
    Python Homework Assignment #6: Advanced Loops
    Details:
    Create a function that takes in two parameters: rows, and columns, both of which are integers.
    The function should then proceed to draw a playing board (as in the examples from the lectures)
    Create a function that takes in two parameters: rows, and columns, both of which are integers.
    The function should then proceed to draw a playing board (as in the examples from the lectures)
    the same number of rows and columns as specified. After drawing the board, your function should return True.
    Extra Credit:
    Try to determine the maximum width and height that your terminal and screen can comfortably fit without wrapping.
    Try to determine the maximum width and height that your terminal and screen can comfortably fit without wrapping.
    If someone passes a value greater than either maximum, your function should return Talse.
    """
    """


    def create_board(rows, columns):
    if columns <= 130:
    for row in range(int(rows)):
    if row % 2 == 0:
    for col in range(1, int(columns)):
    if col % 2 == 1:
    if col != columns - 1:
    print(" ", end="")
    else:
    print(" ")
    else:
    print("|", end="")
    else:
    print("-" * columns)
    # After drawing is done return True
    return True
    else:
    # Return False when matrix is not fitting the screen
    return False


    create_board(11, 130)
  4. qmmr created this gist Feb 28, 2019.
    14 changes: 14 additions & 0 deletions main.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    """
    pirple.com/python
    Python Homework Assignment #6: Advanced Loops
    Details:
    Create a function that takes in two parameters: rows, and columns, both of which are integers.
    The function should then proceed to draw a playing board (as in the examples from the lectures)
    the same number of rows and columns as specified. After drawing the board, your function should return True.
    Extra Credit:
    Try to determine the maximum width and height that your terminal and screen can comfortably fit without wrapping.
    If someone passes a value greater than either maximum, your function should return Talse.
    """