Giter Club home page Giter Club logo

codewars's Introduction

License: Unlicense made-with-Markdown made-with-python PEP8 Checked with mypy HitCount GitHub forks GitHub commit activity Dependabot Status Documentation Status Netlify Status CircleCI Build Status codecov CodeFactor Codacy Badge Codacy Badge Maintainability Test Coverage Maintenance GitHub issues GitHub closed issues Known Vulnerabilities

Python3 solutions for codewars problems

About Codewars

Codewars is a collective effort by its users. They are creators - authoring kata to teach various techniques, solving kata with solutions that enlighten others, and commenting with constructive feedback. The leaders among them moderate the content and community.

  • Codewars supports Python 2.7.6, Python 3.4.3 and Python 3.6.0.
  • Since Python 3 support is relatively new to Codewars, a lot of the Python katas are only available for Python 2.

Difficulty

My profile on Codewars

8 - 7 kyu │ Beginner
6 - 5 kyu │ Novice
4 - 3 kyu │ Competent
2 - 1 kyu │ Proficient
1 - 5 dan │ Expert
5 - 8 dan │ Master

Note: For each completed kata, there is a corresponding unittest file.

Dev Environment

  1. Python 3.7.4
  2. PyTest
  3. Allure Framework
  4. Win 10 (64 bit)
  5. PyCharm 2019.2 (Community Edition)
  6. GitHub Desktop
  7. GIT 2.22.0.windows.1

Python Packages

Full list of dependencies see here.

Online Documentation

Python3 solutions for codewars problems’s documentation is built with Sphinx using a theme provided by Read the Docs.

Sphinx is a tool that makes it easy to create intelligent and beautiful documentation, written by Georg Brandl and licensed under the BSD license.

Online version of the latest tech documentation

Allure Report

Allure is based on standard xUnit results output but adds some supplementary data. Any report is generated in two steps. During test execution (first step), a small library called adapter attached to the testing framework saves information about executed tests to XML files.

During report generation (second step), the XML files are transformed to a HTML report. This can be done with a command line tool, a plugin for CI or a build tool.

Online version of the latest Allure report

Tech Issues and Problem Solving

Changing the project interpreter in the PyCharm project settings
  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Project | Project Interpreter.

  2. Expand the list of the available interpreters and click the Show All link.

  3. Select the target interpreter. When PyCharm stops supporting any of the outdated Python versions, the corresponding project interpreter is marked as unsupported.

  4. The Python interpreter name specified in the Name field, becomes visible in the list of available interpreters. Click OK to apply the changes.

For more info please check here

PyCharm - Choosing Your Testing Framework
  1. Open the Settings/Preferences dialog, and under the node Tools, click the page Python Integrated Tools.

  2. On this page, click the Default Test Runner field.

  3. Choose the desired test runner:

For more info please see Enable Pytest for you project

Setting up Python3 virtual environment on Windows machine
  1. open CMD
  2. navigate to project directory, for example: bash cd C:\Users\superadmin\Desktop\Python\CodinGame
  3. run following command: bash pip install virtualenv
  4. run following command:bash virtualenv venv --python=python
Setting up Python3 virtual environment on Linx (Ubuntu) machine

How to install virtualenv

  1. Install pip first: bash sudo apt-get install python3-pip

  2. Then install virtualenv using pip3: bash sudo pip3 install virtualenv

  3. Now create a virtual environment (>you can use any name insted of venv): bash virtualenv venv

  4. You can also use a Python interpreter of your choice: bash virtualenv -p /usr/bin/python2.7 venv

  5. Active your virtual environment: bash source venv/bin/activate

  6. Using fish shell: bash source venv/bin/activate.fish

  7. To deactivate: bash deactivate

  8. Create virtualenv using Python3: bash virtualenv -p python3 myenv

  9. Instead of using virtualenv you can use this command in Python3: bash python3 -m venv myenv

Source

Activate Virtual Environment

In a newly created virtualenv there will be a bin/activate shell script. For Windows systems, activation scripts are provided for CMD.exe and Powershell.

  1. Open Terminal

  2. Run: \path\to\env\Scripts\activate

Source

Auto generate requirements.txt

Any application typically has a set of dependencies that are required for that application to work. The requirements file is a way to specify and install specific set of package dependencies at once.
Use pip’s freeze command to generate a requirements.txt file for your project:

pip freeze > requirements.txt

If you save this in requirements.txt, you can follow this guide: PyCharm - Manage dependencies using requirements.txt, or you can:

pip install -r requirements.txt

Source

error: RPC failed; curl 56 Recv failure: Connection was reset
  1. Open Git Bash

  2. Run: "git config --global http.postBuffer 157286400"

Source

How to fix in case .gitignore is ignored by Git

Even if you haven't tracked the files so far, Git seems to be able to "know" about them even after you add them to .gitignore

NOTE:

  • First commit your current changes, or you will lose them.
  • Then run the following commands from the top folder of your Git repository:
git rm -r --cached .
git add .
git commit -m "fixed untracked files"
How to generate Allure report with history trends (Windows OS)


Step by step:

  1. Run tests from pytest using following arguments: -v --alluredir=allure-results

  2. Copy '.\allure-report\history' folder into '.\allure-results\history'

  3. Run: allure generate .\allure-results\ -o .\allure-report\ --clean

  4. Following output should appear: Report successfully generated to .\allure-report

  5. Run: allure open .\allure-report\

Source

Sphinx Documentation Set Up


Step by step:

  1. Create docs directory.

  2. Open cmd > Go to docs directory.

  3. cmd > Run: sphinx-quickstart. Note: run with default answers.

  4. Go to docs/conf.py.

  5. Uncomment following lines:

    import os
    import sys
    sys.path.insert(0, os.path.abspath('.'))
  6. Update extensions list as following:

    extensions = ['sphinx.ext.todo', 'sphinx.ext.viewcode', 'sphinx.ext.autodoc']
  7. Update template as following:

    html_theme = 'sphinx_rtd_theme'
  8. Update sys.path.insert as following:

    sys.path.insert(0, os.path.abspath('..'))
  9. Go to docs/index.rst > add modules, see example below:

    .. toctree::
       :maxdepth: 2
       :caption: Contents:
    
       modules
  10. Open cmd > run: bash sphinx-apidoc -F -o . ..

  11. cmd > Run:

    make html
  12. Install html template:

    pip install sphinx_rtd_theme

More info:

Auto-Generated Python Documentation with Sphinx


Step by step:

  1. Open CMD
  2. Go to docs directory
  3. Run: make clean
  4. Run: sphinx-apidoc -F -P -o . ..
  5. Add doc files name into relevant doc rst file
  6. Run: make html

Source

Read-the-docs build fails with “cannot import name 'PackageFinder' from 'pip._internal.index'

The issue and the fix are described in read-the-docs issue [#6554](readthedocs/readthedocs.org#6554):

The fix is to wipe out the build environment as follows (this is taken from here):

  • Log in to read-the-docs
  • Go to Versions
  • Click on the Edit button of the version you want to wipe on the right side of the page
  • Go to the bottom of the page and click the wipe link, next to the “Save” button
  • Now you can re-build the version with a fresh build environment!

This fix worked for me (but as of 26-Jan-2020 you have to wipe out the environment for every build -- see comment from Grimmy below).

Source

How to use requirements.txt to install all dependencies in a python project
  1. Run pip install -r requirements.txt
  2. Run pip freeze > requirements.txt

Source

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.