ciarand / goal

g()()()()('al') → "gooooal"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This project is deprecated and unmaintained. Proceed with caution!

g()('al')

g()('al') is a challenge whereby you need to write in as many languages as possible code which enables the code g()('al') to return the string "goal", the code g()()('al') to return the string "gooal", the code g()()()('al') return the string "goooal", etc.

g()('al') is the creation of acruikshank who originally posed it as a functional programming challenge. Extensive stubbornness and misinterpretation led to its current form.

Rules

  1. You are encouraged to break the rules, cleverly.
  2. When executed, the solution must print "goal" with sufficient o's to demonstrate the program's functionality.
  3. The code g()('al') must appear in the source.
  4. g()('al') must not be a string literal.
  5. 'al' must be a string, or your language's equivalent thereof. You may use your language's standard method of creating a string (e.x. C should use ", ruby may use either " or ').
  6. g()('al') may not print the string. If returning a string cannot be done in your language, you should submit rationale as to why this is impossible for a solution which prints a string to be accepted.
  7. You must be able to insert an arbitrary number of () calls without modification to your solution. Therefore solutions like this are incorrect.
  8. g()('al') must be a valid rvalue if applicable in your language.
  9. g('al') must return "gal".
  10. If you have a solution that is close, but does not meet these rules, submit it anyway. A close and interesting solution is better than no solution.

Previous Solutions

The more exciting solutions are original, not applying techniques that have already been discovered. The following broadly applicable techniques have already been discovered:

Languages

Solved Incomplete Improbable
Brainfuck
C
C#
C++
Clojure
Common Lisp
D
Go
Groovy
English
Haskell
Java
JavaScript
Julia
Lua
Nimrod
Objective-J
OCaml
Perl
Perl 6
PHP
Python
R
Ruby
Scala
Scheme
Sed
Shell
ZSH

Help out, add some more languages!

Editor's Picks

These are some of the editor's favorite submissions:

Editor's Note

This got A LOT more popular than I expected. At the moment, there are 37 pull requests that I need to look at. Please be patient as it may take me a few days to get through them all. I'm prioritizing pull requests for new languages above ones for existing languages.

It would be super helpful if people wanted to help out by:

  1. Running other's submissions and confirming that they work correctly.
  2. Checking that the submissions aren't too similar to existing solutions.
  3. Checking that they follow all the rules.
  4. Calling out particularly clever solutions.

Just leave a comment on the pull request with your findings and I'll see it. Thanks!

About

g()()()()('al') → "gooooal"


Languages

Language:C 21.3%Language:C# 15.5%Language:C++ 7.2%Language:Python 6.4%Language:JavaScript 6.4%Language:PHP 5.1%Language:Java 4.9%Language:Brainfuck 4.8%Language:Perl 6 4.4%Language:D 4.1%Language:Ruby 3.6%Language:Shell 2.1%Language:Lua 2.1%Language:Haskell 1.9%Language:Common Lisp 1.7%Language:Go 1.2%Language:Objective-J 1.1%Language:Clojure 0.9%Language:Julia 0.8%Language:OCaml 0.8%Language:Nim 0.7%Language:Scheme 0.7%Language:R 0.7%Language:Scala 0.6%Language:Groovy 0.5%Language:Perl 0.5%