Git Product home page Git Product logo

1linepython's Introduction

1linePython

A collection of one-liner Python answers on some online code challenges.

The idea of this repository came when I challenged shinez1997 to resolve code problems on binarysearch.com with only one line of Python code. He is better than me in every aspect of coding, and this is only way I can beat him somehow.

Rules

  • The answer is on the same line with the return.
  • No module is imported except defaults by code challenge platforms.
  • Must not reach the TLE of the code challenge platform.
  • Hacks, tricks, or whatever that fits in one line and pass the tests is accepted.

Example:

# functools is imported by default
class Solution: # default by online judge
    def minAddToMakeValid(self, s: str) -> int:  # default by online judge
        # answer fit in one line
        return len(functools.reduce(lambda c1, c2: c2 if not c1 else c1[:-1] if c2==")" and c1[-1] == "(" else c1 + c2, s)) if s else len(s)

Real life usage

  • Just don't.
  • When you hate your future self.
  • When you hate your company, you are willing to leave, you want your product run but be unmaintainable.
  • When the challenge is too simple to you, you want to make life complicate.

Notes

  • Many of the answers are not really 1-liner Python code, as they use functions from libraries.
  • Many of the answers are not the best optimized answers. They just fit under the requirement of the problem's Execute Time Limit.
  • Code challenge websites usually import some default Python libraries, but the list may vary between sites.

Resources

Contribution

Please use this template if you want to contribute to this list:


🧩 Problem Title

Source: Link

Description:

Description and example

Answer:

# Code in Python

Explanations:


Contributors:

1linepython's People

Contributors

dangsonbk avatar rohitsgh avatar runarmod avatar shinez1997 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.