Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: egonSchiele/grokking_algorithms
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: edandresvan/grokking_algorithms
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Sep 3, 2023

  1. Ch03 Countdown: Print numbers on the same line avoiding invalid integers

    The current function `countdown()` prints integers equal and lesser than zero, which is not desired as shown in the book:
    
    ```text
    > 3...2...1
    ```
    
    I propose printing the numbers on the same line separated with ellipsis (...), except for number 1, which should be finished with a new line. Additionally, the base case should stop if the current number `i` is lesser than one.
    
    -	modified:   01_countdown.py
    
    ```python
    def countdown(i):
      # base case
      if i < 1:
        # Finish decreasing and printing the numbers
        print()
        return
      # recursive case
      else:
        # Separate each number with ellipsis (...), except for the number 1.
        element_separator = "..." if i > 1 else ""
        # Print the numbers on the same line
        print(i, end=element_separator)
        return countdown(i - 1)
    ```
    edandresvan committed Sep 3, 2023
    Configuration menu
    Copy the full SHA
    f482a8b View commit details
    Browse the repository at this point in the history
Loading