Ryan Noonan
Ryan Noonan
  • 310
  • 1 963 103
Python Puzzlers Series - Create Combination and Permutation Functions
Welcome back everybody.
Today, our python puzzler challenge is to create functions that can answer the following two questions:
1. Jerry needs to choose 3 friends from a group of 9 friends to be on his bobsled team. How many ways can the selection be made? Hint: Order is not important.
2. Seven cars enter a race. How many possibilities are there for the first through third place finishers? Hint: Order is important.
This puzzler is just to get the brain going and thinking about how to solve problems relating to combinations and permutations and the algorithms. There are probably more complicated but better ways to implement this in python.
If you are not concerned about the algorithm - for large numbers/calculations - I would suggest using a package such as math, scipy, and/or gmpy2 for combinations and permutations and NOT using the python formula implementation.
Examples:
import itertools
import math
import gmpy2
from scipy.special import comb
from scipy.special import perm
print(len(list(itertools.combinations(range(1,10),3))))
print(math.comb(9,3))
print(comb(9,3, exact=True))
print(gmpy2.comb(9,3))
print(len(list(itertools.permutations(range(1,8),3))))
print(math.perm(7,3))
print(perm(7,3, exact=True))
itertools.permutations with big numbers might not run.
Only the standard formulas are covered here. Does not include with replacement/with repetition, all possible, etc. Also, this function does not account for corner cases (error checking) like if you enter a larger choose number (r) than the total number (n), etc.
math.comb and math.perm are new in version 3.8.
Combinations are the number of different ways in which objects can be arranged without regard to order.
Permutations are the number of different ways in which objects can be arranged in order.
This puzzler level is easy.
In this series we will include: data structures, algorithms, brain teasers, puzzles, and coding challenges.
The purpose of these tutorials will be to:
* Help you improve your coding skills or knock off the rust.
* Help to improve your problem solving skills.
* Help you answer questions on sites like LeetCode, Codewars, HackerRank, etc.
* Help you prepare for interviews - if needed.
* And most importantly - have fun coding by solving brain teasers and puzzles.
Переглядів: 711

Відео

Python Puzzlers Series - Create Function to Find Factorial
Переглядів 143Рік тому
Welcome back everybody. Today, our python puzzler challenge is to create a function that takes in a number and returns the factorial. We will also cover using the math package factorial. A factorial is the product of an integer and all the integers below it. 5! = 5 x 4 x 3 x 2 x 1. You might be familiar with factorials as they are used in the formulas to calculate combinations and permutations....
Python Puzzlers Series - Check if String is Palindrome
Переглядів 140Рік тому
Today, we are going to start a new series called Python Puzzlers. In this series we will include: data structures, algorithms, brain teasers, puzzles, and coding challenges. We will start out with some easy to medium level challenges and eventually move to more difficult problems. We will consider Big O time and space later, when the puzzlers get more challenging. The purpose of these tutorials...
How to Get Microsoft Office (Excel, Word, PowerPoint) for Free
Переглядів 874Рік тому
Microsoft Office can be used for free at office.com if you have a Microsoft account. Get Excel for free.
Web Development Getting Started with HTML Frequently Asked Questions
Переглядів 69Рік тому
HTML Frequently Asked Questions Answers on GitHub: github.com/groundhogday321/HTML-Frequently-Asked-Questions In this web development tutorial we will go over the basics on how to get started with learning HTML. The following topics will be covered: What is HTML and what is it used for? What are some good resources for HTML? What browser can I use to view HTML? What are some good text editors t...
Python Plotly Dash Dashboards Introduction to Callbacks
Переглядів 8042 роки тому
In this python tutorial, we will continue our plotly dash series with examples of how to use callbacks in your plotly dash dashboards. This tutorial builds on the previous dash tutorials - specifically, check out the core components tutorial and code files. Python example code on GitHub: github.com/groundhogday321/plotly-dash-examples
Python Plotly Dash Dashboards Core Components (Widgets)
Переглядів 7862 роки тому
In this python tutorial, we will continue our plotly dash series with several examples of core components or widgets that you can use in your plotly dash dashboards. Python example code on GitHub: github.com/groundhogday321/plotly-dash-examples
Python Plotly Dash Dashboards Layout & Styling
Переглядів 3,7 тис.2 роки тому
In this python tutorial, we will continue our Plotly Dash series with how to layout an app or dashboard and position and style the different elements. Code on GitHub: github.com/groundhogday321/plotly-dash-examples This sample Dash dashboard shows examples of how to layout HTML, markup, a text box, a slider, a dropdown menu and some charts. For the hello world HTML we have used css to style the...
Python Plotly Dash Dashboards Hello World
Переглядів 1,3 тис.2 роки тому
In this python tutorial, we will go over how to get started with the Dash package (framework) to build interactive dashboards. Code files on GitHub: github.com/groundhogday321/plotly-dash-examples Tutorials in this Dash series will include: Hello World Layout Core Components/Widgets Basic Callbacks Interactive Dashboards More Additional Notes: To open VS code from terminal using 'code .' - Open...
Python Introduction to Plotly
Переглядів 2,1 тис.2 роки тому
In this python tutorial, we will go over the plotly package. Jupyter notebook on GitHub: github.com/groundhogday321/python-plotly The first part of the tutorial covers frequently asked questions (FAQs). To skip the FAQs, the tutorial starts around 7:58, however the details covered in the FAQ section can be very helpful in understanding the package. Topics covered include: plotly FAQs plotly plo...
Python openpyxl Filter, Sort, Data Validation
Переглядів 6 тис.2 роки тому
In this python tutorial, we are going to go over how to use the openpyxl package to apply data validation to spreadsheets with LibreOffice Calc. We will also briefly go over some filter and sort examples. For the examples of how to add a filter and sort condition - it is important to note that this will add the relevant instructions to the Excel file but it will not actually filter or sort the ...
Python openpyxl Conditional Formatting
Переглядів 6 тис.2 роки тому
In this python tutorial, we are going to go over how to use the openpyxl package to apply conditional formatting to spreadsheets with Excel or LibreOffice Calc. Topics covered: color scale, icon sets, data bar, highlight cells if equal to some number, highlight even numbers. openpyxl is a python library to read/write Excel files. openpyxl can help automate Excel with python (python excel tutori...
Python openpyxl Font & Cell Format Styles
Переглядів 7 тис.2 роки тому
In this python tutorial, we are going to go over how to use the openpyxl package to apply different formatting styles to spreadsheets with Excel or LibreOffice Calc. The examples we will cover include: openpyxl changing font styles, openpyxl fill cell color, openpyxl resizing cells, openpyxl changing cell border styles, and openpyxl how to change the styles of many cells all at once. openpyxl i...
Python openpyxl Charts
Переглядів 3,9 тис.2 роки тому
In this python tutorial, we are going to go over how to use the openpyxl package to create charts with Excel or LibreOffice Calc (plots with openpyxl). I made a correction to the code. It is in the Jupyter Notebook on GitHub. openpyxl is a python library to read/write Excel files. openpyxl can help automate Excel with python (python excel tutorial with openpyxl). The worksheets can be opened wi...
Python openpyxl Pandas and Numpy
Переглядів 2,7 тис.2 роки тому
In this python tutorial, we will go over the following topics: Convert a pandas dataframe to a spreadsheet with openpyxl (Pandas to Excel or LibreOffice Calc) Convert a spreadsheet to a pandas dataframe with openpyxl (Excel or LibreOffice Calc to Pandas) How to create a list or numpy array from spreadsheet column values with Excel or LibreOffice Calc. openpyxl is a python library to read/write ...
Python openpyxl Insert, Delete, Move Rows and Columns
Переглядів 11 тис.2 роки тому
Python openpyxl Insert, Delete, Move Rows and Columns
Python openpyxl Insert Multiple Images
Переглядів 8 тис.2 роки тому
Python openpyxl Insert Multiple Images
Python openpyxl Functions / Formulas
Переглядів 4 тис.2 роки тому
Python openpyxl Functions / Formulas
Python openpyxl Load Spreadsheet / Load Excel Workbook
Переглядів 2,6 тис.2 роки тому
Python openpyxl Load Spreadsheet / Load Excel Workbook
Python openpyxl Append, Populate, Access Data
Переглядів 8 тис.2 роки тому
Python openpyxl Append, Populate, Access Data
Python Introduction to openpyxl Using LibreOffice Calc
Переглядів 8 тис.2 роки тому
Python Introduction to openpyxl Using LibreOffice Calc
QGIS Filter Map and Export as Shapefile
Переглядів 4,1 тис.2 роки тому
QGIS Filter Map and Export as Shapefile
Python Create Word Clouds with Image Outline, Frequencies, and Interactivity
Переглядів 1,6 тис.2 роки тому
Python Create Word Clouds with Image Outline, Frequencies, and Interactivity
Python Create Maps with GeoPandas
Переглядів 12 тис.2 роки тому
Python Create Maps with GeoPandas
Python Create Package Environments with Anaconda Navigator
Переглядів 2,7 тис.3 роки тому
Python Create Package Environments with Anaconda Navigator
Python NLP Word, Sentence, Phrase Counts, Spell Check, Sentiment Analysis with TextBlob
Переглядів 3,5 тис.3 роки тому
Python NLP Word, Sentence, Phrase Counts, Spell Check, Sentiment Analysis with TextBlob
Swift iOS Shake Gesture Example
Переглядів 7033 роки тому
Swift iOS Shake Gesture Example
Python Tkinter GUI Stopwatch
Переглядів 9 тис.3 роки тому
Python Tkinter GUI Stopwatch
Python Sankey Diagram, Pointplot, KDE, Choropleth, Cartogram Maps with geoplot
Переглядів 3,4 тис.3 роки тому
Python Sankey Diagram, Pointplot, KDE, Choropleth, Cartogram Maps with geoplot
Swift iOS Swipe Left & Right Gestures, Swipe to New View
Переглядів 9 тис.3 роки тому
Swift iOS Swipe Left & Right Gestures, Swipe to New View

КОМЕНТАРІ

  • @RonSheely
    @RonSheely 3 дні тому

    Thank you

  • @MinhNguyen-nx1pu
    @MinhNguyen-nx1pu 17 днів тому

    you save my day!🥰

  • @Outboxing13
    @Outboxing13 24 дні тому

    How can you copy and paste values removing formulas ?

  • @baghdadiabdellatif1581
    @baghdadiabdellatif1581 Місяць тому

    Thank you

  • @baghdadiabdellatif1581
    @baghdadiabdellatif1581 Місяць тому

    Wow inner outer polygon that what I've been looking for! Thank you

  • @giostechnologygiovannyv.ri489
    @giostechnologygiovannyv.ri489 Місяць тому

    Buddy, the like is very well earned (100th) because believe me the normal sort put my files like whatever XD I had to sort manually back (gladly I printed the new and old names together so I could rename them) but for future sortings it is helpful... Thanks for this tip/command! ;))

  • @LoafOfCat123
    @LoafOfCat123 Місяць тому

    Thanks mate

  • @aishushiva835
    @aishushiva835 Місяць тому

    Tmrw is my practicals and this video saved me! Thank you so much🥰

  • @multitaskprueba1
    @multitaskprueba1 Місяць тому

    Fantastic video! One of the best that I have seen my life! Thank you so much!

  • @duncans9685
    @duncans9685 2 місяці тому

    Thank you this is like a playground for me. Plan to use this for some NOAA aircraft and mobile measurements I had done around the salt lake area.

  • @koushika_askns
    @koushika_askns 2 місяці тому

    How to find lat, long value from excel sheet of particular column containing address?

  • @apexstudio2936
    @apexstudio2936 2 місяці тому

    This video really helped me during my exams, so thank u bro :)

  • @Caulin_
    @Caulin_ 2 місяці тому

    really helpful man!

  • @geraldinejones7116
    @geraldinejones7116 4 місяці тому

    OMG, you explain this better than the Develop in Swift Explorations, Fundamental books and the Gmetrix practice tests. Jeez now I can take the Swift Associate Exam with ease. Thank you.

  • @leonpardox7548
    @leonpardox7548 5 місяців тому

    Thank you

  • @PaulaArias-he4ug
    @PaulaArias-he4ug 5 місяців тому

    Thank you very much for the video! It's been really useful. But I have one question yet. Is it possible to integrate and show this maps on a tkinter frame, or in any other GUI library?

  • @DmytroLyvytskyi
    @DmytroLyvytskyi 7 місяців тому

    God bless You!

  • @imveryhungry112
    @imveryhungry112 7 місяців тому

    plotly dash is ridiculously powerful

  • @Mishramultiverse
    @Mishramultiverse 8 місяців тому

    Thanks allot ryan!! that's really helpful🙂

  • @harunausman8717
    @harunausman8717 8 місяців тому

    Thank you so much. This is amazing

    • @RyanNoonan
      @RyanNoonan 8 місяців тому

      You're very welcome!

  • @murrayhills706
    @murrayhills706 8 місяців тому

    I have tried to follow along but can't figure out how to lock the reference on my Mac and don't know how you copy it down. I'll keep trying but this my brain can't get a hold of this I think.

  • @theodorpaetzold8478
    @theodorpaetzold8478 8 місяців тому

    Hi Ryan, you created an environment "python_geopandas_env". Assume in Jupyter you also need to use Numpy and Scikit-learn with geopandas to create something unique, would you add them to the "python_geopandas_env" environment as well? I have them on my PC, each in its own environment. Please advise

    • @RyanNoonan
      @RyanNoonan 8 місяців тому

      In theory, it should work either way - adding the other needed packages to the geopandas environment or creating a new environment with all needed packages. Usually I just try to make sure I don’t have too many packages in one environment but I would think the example you listed would work fine.

  • @gurmanjotsingh4920
    @gurmanjotsingh4920 9 місяців тому

    Is there a way to display dates inside the blocks in the calendar?

  • @gajananacreations3804
    @gajananacreations3804 9 місяців тому

    Thanks ❤❤

  • @abdullahinadif6516
    @abdullahinadif6516 10 місяців тому

    Thanks man

  • @reinosint
    @reinosint 10 місяців тому

    thanks for this!

  • @oliveselow-bw3py
    @oliveselow-bw3py 10 місяців тому

    Like it.!!

  • @derrickmulwa
    @derrickmulwa 11 місяців тому

    How can I delete a formatting rule from a worksheet in a specified cell range?

  • @katarzynak9678
    @katarzynak9678 Рік тому

    Thank you!

  • @djbakerman
    @djbakerman Рік тому

    how do the update functions get called?

  • @tsrinivas2406
    @tsrinivas2406 Рік тому

    Thank you Ryan. Very useful Video. This was exactly the things I was looking to implement. And and you figured it 2 years back 🙂

  • @enkiimuto1041
    @enkiimuto1041 Рік тому

    This is magic to me. Thanks!

  • @enkiimuto1041
    @enkiimuto1041 Рік тому

    this is so cool, thank you!

  • @enkiimuto1041
    @enkiimuto1041 Рік тому

    thank you!

  • @enkiimuto1041
    @enkiimuto1041 Рік тому

    This is amazing, thank you so much!

  • @juancarloslucena9284
    @juancarloslucena9284 Рік тому

    im a beginner and im making a black jack game (so far it has everything except the ability to split). I'd like to use something like this for pretending dealer is shuffling and also to make the prompt more clear for the players (generates answers so fast people may find it confusing). Thank you so much!

  • @shobhitsingh2686
    @shobhitsingh2686 Рік тому

    Hi Ryan, it is very well explained, thank you. Can you please guide that how to save these maps as JPG or Png?

    • @pitruchhaya
      @pitruchhaya 9 місяців тому

      Selenium is an option but again, as EPSG of Folium is 4326 n if you want to save it along with a world file, then it is a real pain; honestly, I don’t know the solution yet but it is mandatory if you want it to be in the right projection as QGIS map layout does it automatically when you export it as a PNG.

  • @kartikay1593
    @kartikay1593 Рік тому

    Just a question. If i plot by Month_names and Month_num, The kde plots should be the same right?

  • @JoanneDiaz-mz1ks
    @JoanneDiaz-mz1ks Рік тому

    Hello! Is it possible to create KML files in Google Colab? I've tried the same lines of code in Google Colab with the file path connecting to a gdrive folder, but the KML file is not being saved in my gdrive folder. I wonder if this is possible.

  • @flair_projectsb
    @flair_projectsb Рік тому

    How do you do the reverse? I need cells with 0 to be blank so I can calculate an average value of few cells. If I have 0, it messes the average

  • @RakeshRajput-v8l
    @RakeshRajput-v8l Рік тому

    I have csv file with cordinate. How can i import these cordinate in python and create polygon

  • @user-su6js9po4l
    @user-su6js9po4l Рік тому

    is it possible to do in a regular vs code and not jupyter or does this only work with jupyter?

  • @CarlosMunoz-mt5jj
    @CarlosMunoz-mt5jj Рік тому

    Thanks!

  • @doop9134
    @doop9134 Рік тому

    Thank you! This helped!! ❤❤❤

  • @yuakai1995
    @yuakai1995 Рік тому

    hi ryan! thank you so much for this insightful video!! very helpful

  • @congdungnguyen7354
    @congdungnguyen7354 Рік тому

    Thank you very much for this tutorial. It reminds me to start easier to not overwhelm oneself.

    • @RyanNoonan
      @RyanNoonan Рік тому

      Glad it was helpful and I agree. I like to start simple and then add on little by little until I have something impressive.

  • @StefanoVerugi
    @StefanoVerugi Рік тому

    impressive work, your videos are packed with useful information, like super mini courses the fact that you use notebooks helps the viewer concentrate on the subject without the lengthy typing and long pauses one thing would be also useful is timestamps in the bottom slider to quickly go through chapters, thanks a lot for your help, truly appreciated

    • @RyanNoonan
      @RyanNoonan Рік тому

      Thanks a lot! I appreciate the feedback.

  • @theworld2754
    @theworld2754 Рік тому

    How to change back ground color while editing?

  • @leandroaugusto1195
    @leandroaugusto1195 Рік тому

    Amazing video, great value, thank you it was a lot of use to me. Finallyy someone!!!

  • @ContentRoomB
    @ContentRoomB Рік тому

    thank you!