12
\$\begingroup\$

Damn, that's a lot of carrots.

The Inspiration

inspiration

The Task

You must create a program, that, in as many languages as possible, replaces every instance of ^ with a markdown formatted link (meaning that if I was to post it in an answer, it would automatically read it as an image and place the image instead of the words) of this upward facing carrot.

How to Use Said Formatting:

First, anywhere in the file, put in the link like so (this is what I did for this question):

[1]: http://i.stack.imgur.com/mecHl.png

And then, wherever you want it:

[![][1]][1]

Rules

  • Standard Loopholes apply.
  • Input will be through STDIN or equivalent.
  • Output will be through STDOUT or equivalent.
  • Your code must be a fully operating program in all languages that you use.
  • The URL that you use for your carrot does not have to be the one in this answer. This was just an example. You may use any URL, provided that SE's Markdown shows this specific carrot with it.
  • This is a challenge, so the answer with the greatest amount of carrots languages wins!
    • In the case of a tie, the shortest code size of the entries with the largest number of languages wins.

EDIT:

  • Also, do NOT use trivial derivatives of languages! This means using a substitution language (Brainfuck vs. ShadyAsFuck) and different language versions (Python 2 vs. Python 3).

There's a lot trivial esolangs to fit... (including 9001 BF variants)

Don't be that guy.

Note: Yes, this program will be slightly trivial in languages with regex support. However, the competition is to see how many languages the competitors can use.

\$\endgroup\$
  • \$\begingroup\$ I don't understand the replacement (this part: [![http://i.stack.imgur.com/mecHl.png][1]][1]) \$\endgroup\$ – Zereges Oct 30 '15 at 8:35
  • \$\begingroup\$ @Zereges What don't you understand about it? If you want another example of this, click on "Add an Answer" and then hit the image button. It'll auto construct the image markdown for you, just as shown in this question. \$\endgroup\$ – Addison Crump Oct 30 '15 at 8:38
  • 4
    \$\begingroup\$ Carrots forever! ^^^ \$\endgroup\$ – Cows quack Oct 30 '15 at 11:40
  • 1
    \$\begingroup\$ First, anywhere in the , I'm not sure which word is missing there. \$\endgroup\$ – trichoplax Oct 30 '15 at 15:09
  • 2
    \$\begingroup\$ @FryAmTheEggman, it makes no sense for a question to be tagged both polyglot and rosetta-stone. \$\endgroup\$ – Peter Taylor Oct 30 '15 at 16:50
6
\$\begingroup\$

Python, Befunge 98, Lisp, and Javascript - 829 827 +2 (-x flag in python) = 831 829 bytes

"^\
";/*";
""""(defun q (string part replacement &key (test #'char=))(with-output-to-string (out) (loop with part-length = (length part) for old-pos = 0 then (+ pos part-length) for pos = (search part string :start2 old-pos :test test) do (write-string string out :start old-pos :end (or pos (length string))) when pos do (write-string replacement out) while pos)))(princ "[1]:http://tinyurl.com/qczsjtl
")(ignore-errors (loop (princ (q (read-line) "^" "[![][1]][1]"))))""";import sys;i=sys.stdin.read();print '[1]:http://tinyurl.com/qczsjtl\n'+i.replace('^','[![][1]][1]');"""" """
1;'''
;#<v"[1]:http://tinyurl.com/qczsjtl"$$$
;X v,<
;X >:|XXXXX>v
;vXXX>a,#
;>#@~>:10g-|>,#
;^ XXXXXXXX>$"]1[]]1[][![">:# ,# _#
;X */alert("[1]:http://tinyurl.com/qczsjtl\n"+prompt().split("^").join("[![][1]][1]"));/*
;>^"'''#*/

Requires the -x command line flag when run with python. the Xs can be replaced with any character. The end-of-line number signs (and the number sign at the beginning of the first line that starts with a semicolon) are present to avoid befunge trying to execute the invalid instruction ; (which starts a comment in lisp). There is no trailing space on any of the lines.

Saved two bytes by replacing 55+ with a to print a newline.

\$\endgroup\$
  • \$\begingroup\$ So fancy, so clean. I like. +1 Well done on completing with more than 3 languages. :D \$\endgroup\$ – Addison Crump Nov 24 '15 at 11:28
19
\$\begingroup\$

Minkolang 0.10, Befunge-93, ><>; 3 2D languages, 321 bytes

v[1]: http://i.stack.imgur.com/mecHl.png
v[![][1]][1] 
>\$$>~:1+!#v_:"^"-#v_1>:34*`#v_v
//  ^             ,<0        <    >:0g,1+v
v#   ,,:*52<          ^+1  ,g1:<@_^#`*85:<1
>!v#(od"^"=,34*&34*[i1+1qO]!O$I)lO58*[i1+0qO].
  >i:0(?v:"^"-?v1>:34*)?vv
  ^           o<0       < > :0go1+v
  oo:*52<        ^+1og1: <^;?)*85:<1

Interpreters: Minkolang, Befunge-93, ><>.

I'll go into detail on each component if anyone wants, but what's important is that all of them read the first and second lines of the codebox and output the characters at the appropriate times. Also, I decide between Befunge and Minkolang/><> by the use of \, which swaps the top two values of the stack in the first and is a mirror in the other two. To separate Minkolang and ><>, I use !v#. ! is an unconditional trampoline in both languages, but # is an omni-directional mirror in ><> and a no-op in Minkolang. From then on, each language executes code in its own component.

\$\endgroup\$
4
\$\begingroup\$

Carrot, 60 58 bytes

#^A^S"[![][1]][1]"^[1]: http://i.stack.imgur.com/mecHl.png

I know it is only one language at the moment but I thought we can't really have a challenge about carrots that isn't answered in Carrot.

Saved 2 bytes thanks to @KritixiLithos.

Explanation:

#                                          // Set the stack to the input
^                                          // Change to operations mode
A^                                         // Convert to array mode by splitting on ^
S"[![][1]][1]"                             // Convert to string mode by joining on
                                           // the literal string supplied
^[1]: http://i.stack.imgur.com/mecHl.png   // Switch back to stack mode and
                                           // append the string literal
\$\endgroup\$
  • \$\begingroup\$ I'm not familiar with any languages with # comments but you could easily make a polyglot with one of those just add that code at the start then substring in the carrot code to leave only the # in the input. \$\endgroup\$ – TheLethalCoder Jul 5 '17 at 10:25
  • 2
    \$\begingroup\$ I did not even know why this code worked (the A^ part, partly because I had long forgotten about its implementation), but then I realised it was because of my terribly-written interpreter that lacks a proper parser. Here, have a +1 for confusing the creator of the language. \$\endgroup\$ – Cows quack Jul 6 '17 at 3:04
  • \$\begingroup\$ @KritixiLithos To be honest I was trying to get it working with a regex and failed miserably and was surprised myself when A^ ended up working! I'm guessing when you split, you leave empty elements so ^^ gives [ "", "", "" ]. \$\endgroup\$ – TheLethalCoder Jul 6 '17 at 8:27
  • \$\begingroup\$ You can remove the +" at the end and change it to ^ while dropping the ending " like so, #^A^S"[![][1]][1]"^[1]: http://i.stack.imgur.com/mecHl.png. Essentially, + with a string argument prepends the string to the stack, but ^ does the same thing for a shorter bytecount. \$\endgroup\$ – Cows quack Jul 6 '17 at 8:31
  • \$\begingroup\$ @KritixiLithos Of course thanks! \$\endgroup\$ – TheLethalCoder Jul 6 '17 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.