Giter Site home page Giter Site logo

wzhouwzhou / one-line-wonders Goto Github PK

View Code? Open in Web Editor NEW
96.0 6.0 194.0 1012 KB

OneLineWondersCode | 1000+ Commits | 279/300 One Liners | 200+ Forks | Actively maintained open-source collection of "one-line" programs performing various tasks in different languages

Home Page: https://hacktoberfest2018.suya.moe

License: GNU General Public License v3.0

JavaScript 7.86% Haskell 1.42% Python 31.95% PHP 0.90% Brainfuck 0.06% C++ 11.98% CoffeeScript 3.66% Rebol 0.02% Shell 1.47% PowerShell 1.63% Pascal 0.03% R 0.83% Perl 0.19% C 34.21% Go 1.70% TypeScript 0.03% Crystal 0.24% Groovy 1.41% Common Lisp 0.17% HTML 0.27%
hacktoberfest one-line open-source maintained help-wanted javascript cpp php python haskell

one-line-wonders's Introduction

One Line Wonders

A collection of one-line programs in various languages, performing various tasks. "One-Line" is for those languages that support it; the aim is to create a runnable file the shortest a language can allow (i.e. no using ; instead of a new line and "minifying" it to be one line).

Why?

Have some fun with coding every once in a while, and see how you can abuse the semantics of a language.

Contributing

Anyone can contribute to this repo by opening a PR, your contribution will be open-source on Github. Don't know what to make? Try coding something that logs "Hello, world!" to the console!

Hacktoberfest 2021

Celebrate Hacktoberfest together with a diverse community of developers from around the world!

PRs not marked as spam will be counted towards 4 PRs in the month of October for your free Hacktoberfest T-Shirt!

Let's Get Started

  1. Fork this repository
  • Click the Fork button in the top right of this page, then click on your profile image.
  1. Clone to desktop git clone https://github.com/your-username/one-line-wonders.git
  2. Checkout a branch git checkout -b feature/branch-name
  3. Make yourself known
  • Add your bio to the CONTRIBUTORS.md file

    Name: [YOUR NAME](Github Link)
    Place: Where are you from?
    Coding Experience: Which programming languages do you know? What projects have you/do you worked on?
    Email: [email protected]

  1. Add your one-line program's files of the form [username]_[filename], i.e., wzhouwzhou_approximating_e.cc. If a folder for your code's language does not exist, feel free to create it.
  2. Commit and push git add .; git commit -m "commit message"; git push origin branch-name;
  3. Create a new Pull Request from your fork
  • Click on the New Pull Request button located near the top of your repository.
  1. Wait for your PR to be reviewed!

Star this repository if you had fun โญ๐ŸŽ‰

one-line-wonders's People

Contributors

benjaminurquhart avatar bigboynaruto avatar blitzh0t avatar earvingemenez avatar ernesoglu avatar henning-k avatar jackkav avatar jagw1re avatar jamlamberti avatar kannagikazuko avatar kartikaggarwal98 avatar kblicharski avatar kennedy avatar kmek avatar matankb avatar melissachen2000 avatar mspatel927 avatar ngweihow avatar niralpokal avatar ojaswy avatar pbootly avatar pluckyporcupine avatar priultimus avatar romellogoodman avatar rpxs avatar shweta0310 avatar veena-v-g avatar wzhouwzhou avatar yashagarwal1999 avatar zombiechibixd avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

one-line-wonders's Issues

Approximating e

Approximating the number e (2.718281828459045...)

#119 Approximates e in python, do other people have other solutions like it or in different languages?

More open licence?

Imho that kind of collection could benefit from more permissive license like MIT-like licenses.

Does this count?

I was wondering, do these count as a "one liner" ...

git checkout $(echo "tree $(git hash-object -t tree -w /dev/null)
author nobody <> 1 +0000
committer nobody <> 1 +0000

ย 
" | git hash-object -t commit -w --stdin )
openssl req -keyout sssan.key -out sssan.crt -new -x509 -nodes -newkey rsa -config <( echo -e "[req]\ndistinguished_name = rdn\nprompt = no\nx509_extensions = x509v3\n[rdn]\nCN=host1.dom.xy\n[x509v3]\nsubjectAltName=DNS:host1.dom.xy,DNS:www.host1.dom.xy" )

Hacktoberfest 2019

One line wonders

A collection of one-line programs in various languages, performing various tasks.
"One-Line" is for those languages that support it; the aim is to create a runnable file the shortest a language can allow (i.e. no using ; instead of a new line and "minifying" it to be one line).

Why?

Have some fun with coding every once in a while, and see how you can abuse the semantics of a language.

Contributing

Anyone can contribute to this repo by opening a PR, your contribution will be open-source on Github. Don't know what to make? Try coding something that logs "Hello, world!" to the console!

Hacktoberfest

Celebrate Hacktoberfest together with a diverse community of developers from around the world!

PRs not marked as spam will be counted towards 4 PRs in the month of October for your free Hacktoberfest T-Shirt!

Let's Get Started

  1. Fork this repository
  • Click the Fork button in the top right of this page, then click on your profile image.
  1. Clone to desktop git clone https://github.com/your-username/one-line-wonders.git
  2. Checkout a branch git checkout -b feature/branch-name
  3. Make yourself known
  • Add your bio to the CONTRIBUTORS.md file

    Name: [YOUR NAME](Github Link)

    Place: Where are you from?

    Coding Experience: Which programming languages do you know? What projects have you/do you worked on?

    Email: [email protected]

  1. Add your one-line program's files of the form [username]_[filename], i.e., wzhouwzhou_approximating_e.cc. If a folder for your code's language does not exist, feel free to create it.
  2. Commit and push git add .; git commit -m "commit message"; git push origin branch-name;
  3. Create a new Pull Request from your fork
  • Click on the New Pull Request button located near the top of your repository.
  1. Wait for your PR to be reviewed!

Star this repository if you had fun โญ๐ŸŽ‰

Fibonacci

Task: Create a program that generates or involves fibonacci numbers

There's been quite a few programs now that involve fibonacci number sequence generation, including #66 #203 #185 #186 #184 #124

What other solutions do people have? (Good starting point for new contributors)

Bonus points for "one-liners" (the inspiration for this repository)

Combinations

You are given an array with random integers. Design an algorithm that returns a list of arrays with all the possible combinations of the numbers in the array.
This means if the input is [1,2,3], the output will be [[1],[2],[3],[12],[13],[23],[123]].

Some solutions might be faster than others but speed does not matter.

Add links to references in PR template

I think it would be useful to add reference to the one liner PRs to give more context for the reviewer. Using [title](url)

Examples of prior work, reference or inspiration include:

  • example input and output
  • use case, or problem it solves
  • similar solution in another language

Hacktoberfest 2018

One line wonders

A collection of one-line programs in various languages, performing various tasks.
"One-Line" is for those languages that support it; the aim is to create a runnable file the shortest a language can allow (i.e. no using ; instead of a new line and "minifying" it to be one line).

Why?

Have some fun with coding every once in a while, and see how you can abuse the semantics of a language.

Contributing

Anyone can contribute to this repo by opening a PR, your contribution will be open-source on Github. Don't know what to make? Try coding something that logs "Hello, world!" to the console!

Hacktoberfest

Celebrate Hacktoberfest together with a diverse community of developers from around the world!

PRs marked as spam will not be counted towards 5 PRs in the month of October for your free Hacktoberfest T-Shirt!

Let's Get Started

  1. Fork this repository
  • Click the Fork button in the top right of this page, then click on your profile image.
  1. Clone to desktop git clone https://github.com/your-username/one-line-wonders.git
  2. Checkout a branch git checkout -b feature/branch-name
  3. Make yourself known
  • Add your bio to the CONTRIBUTORS.md file

    Name: [YOUR NAME](Github Link)

    Place: Where are you from?

    Coding Experience: Which programming languages do you know? What projects have you/do you worked on?

    Email: [email protected]

  1. Add your one-line program's files. If a folder for your code's language does not exist, feel free to create it.
  2. Commit and push git add .; git commit -m "commit message"; git push origin branch-name;
  3. Create a new Pull Request from your fork
  • Click on the New Pull Request button located near the top of your repository.
  1. Wait for your PR to be reviewed!

Star this repository if you had fun โญ๐ŸŽ‰

One-Line Sort Algorithms

This was first demonstrated in #5 (1 line quicksort in haskell) but are other sorting algorithms (ie merge, bubble, heap, bucket, radix, selection, etc) also possible in "one line" (in any language)? If not "one line", what's the shortest you think you can make it? I think this would be a cool task for people to try and complete.

Hacktoberfest 2021

One line wonders

A collection of one-line programs in various languages, performing various tasks.
"One-Line" is for those languages that support it; the aim is to create a runnable file the shortest a language can allow (i.e. no using ; instead of a new line and "minifying" it to be one line).

Why?

Have some fun with coding every once in a while, and see how you can abuse the semantics of a language.

Contributing

Anyone can contribute to this repo by opening a PR, your contribution will be open-source on Github. Don't know what to make? Try coding something that logs "Hello, world!" to the console!

Hacktoberfest

Celebrate Hacktoberfest together with a diverse community of developers from around the world!

PRs not marked as spam will be counted towards 4 PRs in the month of October for your free Hacktoberfest T-Shirt!

Let's Get Started

  1. Fork this repository
  • Click the Fork button in the top right of this page, then click on your profile image.
  1. Clone to desktop git clone https://github.com/your-username/one-line-wonders.git
  2. Checkout a branch git checkout -b feature/branch-name
  3. Make yourself known
  • Add your bio to the CONTRIBUTORS.md file

    Name: [YOUR NAME](Github Link)

    Place: Where are you from?

    Coding Experience: Which programming languages do you know? What projects have you/do you worked on?

    Email: [email protected]

  1. Add your one-line program's files of the form [username]_[filename], i.e., wzhouwzhou_approximating_e.cc. If a folder for your code's language does not exist, feel free to create it.
  2. Commit and push git add .; git commit -m "commit message"; git push origin branch-name;
  3. Create a new Pull Request from your fork
  • Click on the New Pull Request button located near the top of your repository.
  1. Wait for your PR to be reviewed!

Star this repository if you had fun โญ๐ŸŽ‰

Pi Computation in One Line

#76 was a very cool and concise solution. I was wondering if anyone else able to achieve this with other methods or other languages?

Valid Anagram Problem

Useful for new contributors as well as seasoned developers; #249 takes a stab at this problem, do other people have solutions as well?

Given two strings s and t , write a function to determine if t is an anagram of s.

Example 1:

Input: s = "anagram", t = "nagaram"
Output: true
Example 2:

Input: s = "rat", t = "car"
Output: false
Note:
You may assume the string contains only lowercase alphabets.

Follow up:
What if the inputs contain unicode characters? How would you adapt your solution to such case?

Source: https://leetcode.com/problems/valid-anagram/

(N.B. Existing solutions already exist on that page, so if you choose to copy them here instead of writing, testing, and contributing a working attempt here, please try to credit the authors. If you want some extra challenge to it, try to make your program a "one-liner")

Add docstrings

In a lot of these one liners, it is somewhat unclear how we should run these programs. While the respective pull requests have all the documentation we need, it doesnt appear in the actual programs. I think we should add docstrings or comments to all the programs so that it will be clear how one should run them.

Unique Array

You are given an array with random integers. Design an algorithm that returns the array with duplicates removed. This means if the input is [1,10,7,1,4], the output will be [1,10,7,4].

Some solutions might be faster than others but speed does not matter

Golden Ratio Approximation

Golden ratio approximation

#170 approximates the golden ratio in a "one liner" in python
Can this be done in other languages? Do other people have different solutions in python?

Largest sum of consecutive numbers in an array

You are given an array with n distinct integers. Design an algorithm that returns two integers i and j, where i <= j, for which the sum of the elements at positions i, (i+1), ....(j-1), j is maximum.
eg. [1, 4, -2, 6, -5, 3] would return 0 and 3, for i and j respectively. The largest sum of consecutive numbers we can get from this array is 9, 1 + 4 - 2 + 6 = 9.

I haven't seen any one line wonders of this yet, but it can be done in O(n) time when solved normally.

Should we add a .gitignore?

Should we add a gitignore to catch files such as .DS_Store? (even though people will be pulling individual "one-line" code files) and what would need to be in it?

String Reversal

Originally a javascript "code golf" type question

Create a one-line arrow function that, given a string, reverses it
reverse('Hello') -> 'olleH'

โ€ข Under 75 characters
โ€ข Does not use any .reverse .reduce .substring, .substr, .split, any loops, or list/array work
โ€ข Does not use any bit shifts, "mathy" operators + - * / = or conditional operator
Hint: Recursion appreciated

My solution is here

Can this be done in other languages? Do other people have different solutions in javascript?

Multiply ints without arithmetic/bitwise operators

#1 solves this problem:

I have two variables a and b containing ints i want to multiply
the task is to make a one-line function in js that multiplies these numbers without any arithmetic/bitwise operators
ie use of + - = | & >> * / etc

Do other people have solutions, perhaps in other languages, that accomplish this?

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.