Skip to content

Python3 solutions for Codewars.com problems

License

Notifications You must be signed in to change notification settings

qamine-test/codewars

 
 

Repository files navigation

License: Unlicense HitCount GitHub forks GitHub commit activity Dependabot Status Documentation Status Netlify Status CircleCI Build Status codecov Codacy Badge Codacy Badge Maintainability Test Coverage Maintenance GitHub issues GitHub closed issues Checked with mypy 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

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

cd C:\Users\superadmin\Desktop\Python\CodinGame
  1. run following command:
pip install virtualenv
  1. run following command:
virtualenv venv --python=python
Setting up Python3 virtual environment on Linx (Ubuntu) machine

How to install virtualenv

  1. Install pip first
    sudo apt-get install python3-pip
  1. Then install virtualenv using pip3
    sudo pip3 install virtualenv
  1. Now create a virtual environment (>you can use any name insted of venv)
    virtualenv venv
  1. You can also use a Python interpreter of your choice:
    virtualenv -p /usr/bin/python2.7 venv
  1. Active your virtual environment:
    source venv/bin/activate
  1. Using fish shell:
    source venv/bin/activate.fish
  1. To deactivate:
    deactivate
  1. Create virtualenv using Python3:
    virtualenv -p python3 myenv
  1. Instead of using virtualenv you can use this command in Python3:
    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('.'))
  1. Update extensions list as following:
extensions = ['sphinx.ext.todo', 'sphinx.ext.viewcode', 'sphinx.ext.autodoc']
  1. Update template as following:
html_theme = 'sphinx_rtd_theme'
  1. Update sys.path.insert as following:
sys.path.insert(0, os.path.abspath('..'))
  1. Go to docs/index.rst > add modules, see example below:
.. toctree::
   :maxdepth: 2
   :caption: Contents:

   modules
  1. Open cmd > run:
sphinx-apidoc -o . ..
  1. cmd > Run: make html

  2. Install html template:

pip install sphinx_rtd_theme

Video Tutorial Sphinx Documentation 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 -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

About

Python3 solutions for Codewars.com problems

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.4%
  • JavaScript 1.4%
  • Other 0.2%