text:
Mathematical Expression Showdown!
You are given 6 numbers: 5 digits [0-9] and a target number. Your goal is to intersperse operators between the digits to get as close as you can to the target. You have to use each digit exactly once, and can use the following operators  as many times as you want: + - * / () ^ sqrt sin cos tan. For example, if I'm given 8 2 4 7 2 65 I can output 82-(2*7)-4. This evaluates to 64, thus giving me a score of 1 since I was 1 away from the target. Note: You can not put a decimal point between digits.
I am using the code from this StackOverflow answer to evaluate the mathematical expressions. At the bottom of this question there are programs you can use to test it out.
Chaining Functions (Update!)
@mdahmoune has revealed a new level of complexity to this challenge. As such, I'm adding a new feature: chaining unary functions. This works on sin, cos, tan, and sqrt. Now instead of writing sin(sin(sin(sin(10)))), you can write sin_4(10). Try it out in the evaluator!
Input
200 line-separated test cases of 5 digits and a target number that are space-separated. You can use the program at the bottom of the question to make sample test cases, but I will have my own test cases for official scoring. The test cases are broken up into 5 sections of 40 tests with the following ranges for the target number:

Section 1: [0,1] (to 5 decimal points)
Section 2: [0,10] (to 4 decimal points)
Section 3: [0,1000] (to 3 decimal points)
Section 4: [0,106] (to 1 decimal point)
Section 5: [0,109] (to 0 decimal points)

Output
200 line separated mathematical expressions. For example, if the test case is 5 6 7 8 9 25.807, a possible output could be 78-59+6
Scoring
The goal each round is to get closer to the target number than the other competing programs. I'm going to use Mario Kart 8 scoring, which is: 1st: 15 2nd: 12 3rd: 10 4th: 9 5th: 8 6th: 7 7th: 6 8th: 5 9th: 4 10th: 3 11th: 2 12th: 1 13th+: 0. If multiple answers get the same exact score, the points are split evenly, rounded to the nearest int. For example, if the programs in 5th-8th place are tied, they each get (8+7+6+5)/4 = 6.5 => 7 points that round. At the end of 200 rounds, the program that got the most points wins. If two programs have the same number of points at the end, the tie-breaker is the program that finished running faster.
Rules

You can only use one of the languages commonly pre-installed on Mac like C, C++, Java, PhP, Perl, Python (2 or 3), Ruby, and Swift. If you have a language you want to use with a compiler/interpreter that is a relatively small download I may add it. You can also use a language with an online interpreter, but that will not run as fast.
Specify in your answer if you want trig functions to be calculated in degrees or radians.
Your program must output its solutions to all 200 test cases (to a file or STDOUT) within 60 seconds on my Mac.
Randomness must be seeded.
Your total output for all test cases can't be more than 1 MB.
If you have improved your solution and would like to be re-scored, add Re-Score at the top of your answer in bold.

Programs
(change the "deg" argument to "rad" if you want radians)

Test out evaluator
Score your program's output for test cases
Generate test cases:

document.getElementById("but").onclick = gen;
var checks = document.getElementById("checks");
for(var i = 1;i<=6;i++) {
var val = i<6 ? i : "All";
var l = document.createElement("label");
l.for = "check" + val;
l.innerText = " "+val+" ";
checks.appendChild(l);
  var check = document.createElement("input");
  check.type = "checkBox";
  check.id = "check"+val;
  if(val == "All") {
  check.onchange = function() {
  if(this.checked == true)  {
  for(var i = 0;i<5;i++) {
    this.parentNode.elements[i].checked = true;
  }
  }
};
  }
  else {
  check.onchange = function() {
    document.getElementById("checkAll").checked = false;
  }
  }
  checks.appendChild(check);

}

function gen() {
var tests = [];
var boxes = checks.elements;
if(boxes[0].checked)genTests(tests,1,5,40);
if(boxes[1].checked)genTests(tests,10,4,40);
if(boxes[2].checked)genTests(tests,1000,3,40);
if(boxes[3].checked)genTests(tests,1e6,1,40);
if(boxes[4].checked)genTests(tests,1e9,0,40);
document.getElementById("box").value =  tests.join("\n");
}

function genTests(testArray,tMax,tDec,n) {
for(var i = 0;i<n;i++) {
  testArray.push(genNums(tMax,tDec).join(" "));
}
}

function genNums(tMax,tDec) {
var nums = genDigits();
nums.push(genTarget(tMax,tDec));
return nums;
}

function genTarget(tMax,tDec) {
  return genRand(tMax,tDec);
}

function genRand(limit,decimals) {
  var r = Math.random()*limit;
  return r.toFixed(decimals);
}

function genDigits() {
  var digits = [];
   for(var i = 0;i<5;i++) {
    digits.push(Math.floor(Math.random()*10));
   }
   return digits;
}
textarea {
  font-size: 14pt;
  font-family: "Courier New", "Lucida Console", monospace;
}

div {
text-align: center;
}

Sections: <form id="checks"></form>
<input type="button" id="but" value="Generate Test Cases" />
<textarea id="box" cols=20 rows=15></textarea>

Leaderboard

user202729 (C++): 2856, 152 wins
mdahmoune (Python 2) [v2]: 2544, 48 wins

Section scores (# of wins):

[0-1] user202729: 40, mdahmoune: 0
[0-10] user202729: 40, mdahmoune: 0
[0-1000] user202729: 39, mdahmoune: 1
[0-106] user202729: 33, mdahmoune: 7
[0-109] user202729:0, mdahmoune: 40

Related: Generate a valid equation using user-specified numbers

Is there any specific reason the trigonometric functions have to use degrees? Could an option possibly be added for the answer to specify either radians or degrees?

Does the set of digits contain necessarily a non zero digit?

@mdahmoune The test cases are randomly generated, so the digits could be all 0. You'd just have to do your best in that situation. In degree mode I was able to get all the way up to 3283.14 with cos(0)/sin(0^0)/sin(0^0).

Thanx for your complete answer :)

Is it the same scoring method for the 5 different sections? Abs(target_value-generated_expression_value)? I

@mda It is, but you have to remember that the number of points you get is based on how your program scores compared to the other programs.

@geokavel The probability of at least 1 test case is all zero is actually 2‰. We can make the output arbitrarily long such that it output in time, correct?

@user202729 Do you mean outputting all the answers at the very end? Yeah, that works.

Is the concatenation considered as an operation? I means, for example for 8 2 4 7 2 : 65 can I produce 65 by concatenating the result of (8+2-4)=6 and (7-2)=5?

@mda No, it's not allowed. You can use program 1 to test out what's allowed.

@geokavel With the new evaluator the time limit is evaluate + compute <= 1 min or evaluate <= 1 min, compute <= 1 min?

@geokavel So each test case is a round (independent of each other?)

@user202729 Sorry, I think I mis-answered one of your previous questions. The 60s time limit is just for producing the outputs, not evaluating them.

Is it possible to give the number of cores in your test cpu machine?

@mdahmoune Yeah, two.

@mdahmoune , geokavel Unfortunately, despite the bounty, no one had a better answer than mine yet. Anyone consider writing one?

@user202729, geokavel Yes, I'm working on a second draft version..

Perhaps merge the two solutions :D

@user202729 feel free to use my function's solution to improve yours

@mdahmoune I think using other's idea is cheating.

I reimplemented the evaluator here (TIO link) in C++, but it gives different result for that test case to your Java evaluator. So my score may be worse if the Java evaluator is used. Even on different computers the C++ evaluator return different results.

@user202729 On the TIO version of the Java evaluator I get 0.999999 for that input. However, on the version of the Java evaluator on my computer I get almost the same answer as your TIO C++ link. So I think you're good.

On the TIO Java I get 6.06058941675148E8 , while on TIO C++ I get 606058696.99925720691681, which have difference of about 1000. How can you get 0.999999? (remember to use rad) Because now mdahmoune 's score is ~ 1e-4 now the precision is very important. How about rescore both answer with the C++ evaluator?

@user202729 The difference is only 245. Yes I forgot to change to rad. How do I know whether Java or C++ version is more accurate? Especially since C++ evaluator returns different results on different computers.

@user202729 I'll try to run both with C++ evaluator, but I'm not really skilled with C++ so it might take me a little bit.

Who knows? (we can try evaluate both on Mathematica with a lot of digits of precision) Does Java evaluator returns different results on different computers?

@user202729 I get same exact result on TIO as on my computer for Java version.

@user202729 I get 606058289.20654487609863 when I run C++ version on my computer, compiled with clang.

TIO get 606058696.999... and I (gcc) get exactly 606058697. I think I will move to Java for accuracy.

C++
// This program use radian mode

//#define DEBUG

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#include <cassert>
#else
#define assert(x) void(0)
#endif

namespace std {
    /// Used for un-debug.
    struct not_cerr_t {
    } not_cerr;
}

template <typename T>
std::not_cerr_t& operator<<(std::not_cerr_t& not_cerr, T) {return not_cerr;}

#include <iostream>
#include <iomanip>
#include <cmath>
#include <limits>
#include <array>
#include <bitset>
#include <string>
#include <sstream>

#ifndef DEBUG
#define cerr not_cerr
#endif // DEBUG

// String conversion functions, because of some issues with MinGW
template <typename T>
T from_string(std::string st) {
    std::stringstream sst (st);
    T result;
    sst >> result;
    return result;
}

template <typename T>
std::string to_string(T x) {
    std::stringstream sst;
    sst << x;
    return sst.str();
}

template <typename T> int sgn(T val) {
    return (T(0) < val) - (val < T(0));
}

const int N_ITER = 1000, N_DIGIT = 5, NSOL = 4;
std::array<int, N_DIGIT> digits;
double target;

typedef std::bitset<N_ITER> stfunc; // sin-tan expression
// where sin = 0, tan = 1

double eval(const stfunc& fn, int length, double value) {
    while (length --> 0) {
        value = fn[length] ? std::tan(value) : std::sin(value);
    }
    return value;
}

struct stexpr { // just a stfunc with some information
    double x = 0, val = 0; // fn<length>(x) == val
    int length = 0;
    stfunc fn {};
//    bool operator[] (const int x) {return fn[x];}
    double eval() {return val = ::eval(fn, length, x);}
};

struct expr { // general form of stexpr
    // note that expr must be *always* atomic.
    double val = 0;
    std::string expr {};

    void clear() {
        val = 0;
        expr.clear();
    }

    // cos(cos(x)) is in approx 0.5 - 1,
    // so we can expect that sin(x) and tan(x) behaves reasonably nice
    private: void wrapcos2() {
        expr = "(cos_2 " + expr + ")"; // we assume that all expr is atomic
        val = std::cos(std::cos(val));
    }

    public: void wrap1() {
        if (val == 0) {
            expr = "(cos " + expr + ")"; // we assume that all expr is atomic
            val = std::cos(val);
        }
        if (val == 1) return;
        wrapcos2(); // range 0.54 - 1
        int cnt_sqrt = 0;
        for (int i = 0; i < 100; ++i) {
            ++cnt_sqrt;
            val = std::sqrt(val);
            if (val == 1) break;
        }
        expr = "(sqrt_" + to_string(cnt_sqrt) + " " + expr + ")"; // expr must be atomic
    }
};

stexpr nearest(double initial, double target) {
    stexpr result; // built on the fn of that
    result.x = initial;
    double value [N_ITER + 1];
    value[0] = initial;
    for (result.length = 1; result.length <= N_ITER; ++result.length) {
        double x = value[result.length-1];
        if (x < target) {
            result.fn[result.length-1] = 1;
        } else if (x > target) {
            result.fn[result.length-1] = 0;
        } else { // unlikely
            --result.length;
//            result.val = x;
            result.eval();
            assert(result.val == x);
            return result;
        }
        value[result.length] = result.eval(); // this line takes most of the time
        if (value[result.length] == value[result.length-1])
            break;
    }

//    for (int i = 0; i < N_ITER; ++i) {
//        std::cerr << i << '\t' << value[i] << '\t' << (value[i] - target) << '\n';
//    }

    double mindiff = std::numeric_limits<double>::max();
    int resultlength = -1;
    result.length = std::min(N_ITER, result.length);
    for (int l = 0; l <= result.length; ++l) {
        if (std::abs(value[l] - target) < mindiff) {
            mindiff = std::abs(value[l] - target);
            resultlength = l;
        }
    }

    result.length = resultlength;
    double val = value[resultlength];
    assert(std::abs(val - target) == mindiff);
    if (val != target) { // second-order optimization
        for (int i = 1; i < result.length; ++i) {
            // consider pair (i-1, i)
            if (result.fn[i-1] == result.fn[i]) continue; // look for (sin tan) or (tan sin)
            if (val < target && result.fn[i-1] == 0) { // we need to increase val : sin tan -> tan sin
                result.fn[i-1] = 1;
                result.fn[i] = 0;
                double newvalue = result.eval();
//                if (!(newvalue >= val)) std::cerr << "Floating point sin-tan error 1\n";
                if (std::abs(newvalue - target) < std::abs(val - target)) {
//                    std::cerr << "diff improved from " << std::abs(val - target) << " to " << std::abs(newvalue - target) << '\n';
                    val = newvalue;
                } else {
                    result.fn[i-1] = 0;
                    result.fn[i] = 1; // restore
                    #ifdef DEBUG
                    result.eval();
                    assert(val == result.val);
                    #endif // DEBUG
                }
            } else if (val > target && result.fn[i-1] == 1) {
                result.fn[i-1] = 0;
                result.fn[i] = 1;
                double newvalue = result.eval();
//                if (!(newvalue <= val)) std::cerr << "Floating point sin-tan error 2\n";
                if (std::abs(newvalue - target) < std::abs(val - target)) {
//                    std::cerr << "diff improved from " << std::abs(val - target) << " to " << std::abs(newvalue - target) << '\n';
                    val = newvalue;
                } else {
                    result.fn[i-1] = 1;
                    result.fn[i] = 0; // restore
                    #ifdef DEBUG
                    result.eval();
                    assert(val == result.val);
                    #endif // DEBUG
                }
            }
        }
    }
    double newdiff = std::abs(val - target);
    if (newdiff < mindiff) {
        mindiff = std::abs(val - target);
        std::cerr << "ok\n";
    } else if (newdiff > mindiff) {
        std::cerr << "Program error : error value = " << (newdiff - mindiff) << " (should be <= 0 if correct) \n";
        std::cerr << "mindiff = " << mindiff << ", newdiff = " << newdiff << '\n';
    }
    result.eval(); // set result.result
    assert(val == result.val);

    return result;
}

expr nearest(const expr& in, double target) {
    stexpr tmp = nearest(in.val, target);
    expr result;
    for (int i = 0; i < tmp.length; ++i)
        result.expr.append(tmp.fn[i] ? "tan " : "sin ");

    result.expr = "(" + result.expr + in.expr + ")";
    result.val = tmp.val;
    return result;
}

int main() {
    double totalscore = 0;

    assert (std::numeric_limits<double>::is_iec559);
    std::cerr << std::setprecision(23);

//    double initial = 0.61575952241185627;
//    target = 0.6157595200093855;
//    stexpr a = nearest(initial, target);
//    std::cerr << a.val << ' ' << a.length << '\n';
//    return 0;

    while (std::cin >> digits[0]) {
        for (unsigned i = 1; i < digits.size(); ++i) std::cin >> digits[i];
        std::cin >> target;

/*        std::string e;
//        int sum = 0;
//        for (int i : digits) {
//            sum += i;
//            e.append(to_string(i)).push_back('+');
//        }
//        e.pop_back(); // remove the last '+'
//        e = "cos cos (" + e + ")";
//        double val = std::cos(std::cos((double)sum));
//
//        stexpr result = nearest(val, target); // cos(cos(x)) is in approx 0.5 - 1,
//        // so we can expect that sin(x) and tan(x) behaves reasonably nice
//        std::string fns;
//        for (int i = 0; i < result.length; ++i) fns.append(result.fn[i] ? "tan" : "sin").push_back(' ');
//
//        std::cout << (fns + e) << '\n';
//        continue;*/

        std::array<expr, NSOL> sols;
        expr a, b, c, d; // temporary for solutions

        /* ----------------------------------------
           solution 1 : nearest cos cos sum(digits) */

        a.clear();
        for (int i : digits) {
            a.val += i; // no floating-point error here
            a.expr.append(to_string(i)).push_back('+');
        }
        a.expr.pop_back(); // remove the last '+'
        a.expr = "(" + a.expr + ")";
        a.wrap1();

        sols[0] = nearest(a, target);

        /* -----------------------------------------
              solution 2 : a * tan(b) + c (also important) */

        // find b first, then a, then finally c
        a.clear(); b.clear(); c.clear(); // e = a, b = e1, c = e2

        a.expr = to_string(digits[0]);
        a.val = digits[0];
        a.wrap1();

        b.expr = "(" + to_string(digits[1]) + "+" + to_string(digits[2]) + ")";
        b.val = digits[1] + digits[2];
        b.wrap1();

        c.expr = to_string(digits[3]);
        c.val = digits[3];
        c.wrap1();

        d.expr = to_string(digits[4]);
        d.val = digits[4];
        d.wrap1();

        b = nearest(b, std::atan(target));

        double targetA = target / std::tan(b.val);
        int cnt = 0;
        while (targetA < 1 && targetA > 0.9) {
            ++cnt;
            targetA = targetA * targetA;
        }
        a = nearest(a, targetA);
        while (cnt --> 0) {
            a.val = std::sqrt(a.val);
            a.expr = "sqrt " + a.expr;
        }
        a.expr = "(" + a.expr + ")"; // handle number of the form 0.9999999999

        /// partition of any number to easy-to-calculate sum of 2 numbers
        {{{{{{{{{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}}}}}}}}}

        double targetC, targetD; // near 1, not in [0.9, 1), >= 0.1
        // that is, [0.1, 0.9), [1, inf)

        double target1 = target - (a.val * std::tan(b.val));

        double ac = std::abs(target1), sc = sgn(target1);
        if (ac < .1) targetC = 1 + ac, targetD = -1;
        else if (ac < 1) targetC = 1 + ac/2, targetD = ac/2 - 1;
        else if (ac < 1.8 || ac > 2) targetC = targetD = ac/2;
        else targetC = .8, targetD = ac - .8;

        targetC *= sc; targetD *= sc;

        c = nearest(c, std::abs(targetC)); if (targetC < 0) c.val = -c.val, c.expr = "(-" + c.expr + ")";
        d = nearest(d, std::abs(targetD)); if (targetD < 0) d.val = -d.val, d.expr = "(-" + d.expr + ")";

        sols[1].expr = a.expr + "*tan " + b.expr + "+" + c.expr + "+" + d.expr;
        sols[1].val = a.val * std::tan(b.val) + c.val + d.val;

        std::cerr
        << "\n---Method 2---"
        << "\na = " << a.val
        << "\ntarget a = " << targetA
        << "\nb = " << b.val
        << "\ntan b = " << std::tan(b.val)
        << "\nc = " << c.val
        << "\ntarget c = " << targetC
        << "\nd = " << d.val
        << "\ntarget d = " << targetD
        << "\n";

        /* -----------------------------------------
              solution 3 : (b + c) */

        target1 = target / 2;
        b.clear(); c.clear();

        for (int i = 0; i < N_DIGIT; ++i) {
            expr &ex = (i < 2 ? b : c);
            ex.val += digits[i];
            ex.expr.append(to_string(digits[i])).push_back('+');
        }
        b.expr.pop_back();
        b.expr = "(" + b.expr + ")";
        b.wrap1();

        c.expr.pop_back();
        c.expr = "(" + c.expr + ")";
        c.wrap1();

        b = nearest(b, target1);
        c = nearest(c, target - target1); // approx. target / 2

        sols[2].expr = "(" + b.expr + "+" + c.expr + ")";
        sols[2].val = b.val + c.val;

        /* -----------------------------------------
              solution 4 : a (*|/) (b - c)  (important) */

        a.clear(); b.clear(); c.clear(); // a = a, b = e1, c = e2

        a.expr = to_string(digits[0]);
        a.val = digits[0];
        a.wrap1();

        b.expr = "(" + to_string(digits[1]) + "+" + to_string(digits[2]) + ")";
        b.val = digits[1] + digits[2];
        b.wrap1();

        c.expr = "(" + to_string(digits[3]) + "+" + to_string(digits[4]) + ")";
        c.val = digits[3] + digits[4];
        c.wrap1();

        // (b-c) should be minimized
        bool multiply = target < a.val;
        double factor = multiply ? target / a.val : a.val / target;

        target1 = 1 + 2 * factor; // 1 + 2 * factor and 1 + factor

        std::cerr << "* Method 4 :\n";
        std::cerr << "b initial = " << b.val << ", target = " << target1 << ", ";
        b = nearest(b, target1);
        std::cerr << " get " << b.val << '\n';

        std::cerr << "c initial = " << c.val << ", target = " << b.val - factor << ", ";
        c = nearest(c, b.val - factor); // factor ~= e1.val - e2.val
        std::cerr << " get " << c.val << '\n';

        sols[3].expr = "(" + a.expr + (multiply ? "*(" : "/(") +
        ( b.expr + "-" + c.expr )
        + "))";
        factor = b.val - c.val;
        sols[3].val = multiply ? a.val * factor : a.val / factor;

        std::cerr << "a.val = " << a.val << '\n';

        /* ----------------------------------
                    Final result */

        int minindex = 0;
        assert(NSOL != 0);
        for (int i = 0; i < NSOL; ++i) {
            if (std::abs(target - sols[i].val) < std::abs(target - sols[minindex].val)) minindex = i;
            std::cerr << "Sol " << i << ", diff = " << std::abs(target - sols[i].val) << "\n";
        }
        std::cerr << "Choose " << minindex << "; target = " << target << '\n';
        totalscore += std::abs(target - sols[minindex].val);

        std::cout << sols[minindex].expr << '\n';
    }

    // #undef cerr // in case no-debug
    std::cerr << "total score = " << totalscore << '\n';
}

Input from standard input, output to standard output.

Yes, I think <1MB. Note that if the program violate something you can decrease N_ITER (currently is 1000)

@geokavel Now it is questionable if 1 / sin_100000000 (2) is allowed, or sin_1.374059274 (1).

1 / sin_100000000 (2) is allowed if you have the digits 1 and 2 at your disposal. I have no idea how sin_1.374059274 would work. What does it mean to repeat sin a non-integer number of times?

@geokavel But the former formula takes forever to evaluate, so it is not hard to calculate the score. The later can be defined https://en.wikipedia.org/wiki/Iterated_function#Fractional_iterates_and_flows.2C_and_negative_iterates   | How is the program on official test cases?

I see what you mean by a partial iteration, but I think it's too hard for me to implement it. Your program runs in good time - only about 25 seconds.

@geokavel [Rescore] What is the "single player score" as in "score 0.0032 on official test" in the other answer?

@geokavel And remember that the trignometric functions use radian.

It refers to his average score on the test cases.

@geokavel Rescore Because that is an math-library issue, you just need to add the fdlibm 5.3 library (which can be found for example here) and re-evaluate. You can also test if the file used the library by compiling the evaluator with the library and it should give the exact result as the Java evaluator. Besides, note that Java only guaranteed to produce the exact results if you use StrictMath instead of Math.

why should i rescore if Java already gives exact?

I changed all functions to StrictMath and still same scores. I also tried compiling  c++ evaluator with fdlibm 5.3, however it still gets different scores from Java. Does clang++ -std=c++11 -stdlib=libc++ -I ~/fdlibm53 -lm ~/fdlibm53/libfdm.a -o TestEval TestEval.cpp seem like correct command?

I don't know how to use Linux or Mac, but if compiled correctly the evaluator should produce exactly correct result as Java evaluator.

Must be doing something wrong, because c++ evaluator produces same results regardless of including libfdm.

Python 2, radians, score 0.0032 on official test
This is the second draft solution gives an average score of 0.0032 points.
As it uses a composition of a lot of sin I used the following compact notation for the output formula:

sin_1 x=sin(x)
sin_2 x=sin(sin(x))
...
sin_7 x=sin(sin(sin(sin(sin(sin(sin(x)))))))
...

import math
import bisect
s1=[[float(t) for t in e.split()] for e in s0.split('\n')]
maxi=int(1e7)
A=[]
B=[]
C=[]
D=[]
a=1
for i in range(maxi):
	A.append(a)
	C.append(1/a)
	b=math.sin(a)
	c=a-b
	B.append(1/c)
	D.append(c)
	a=b
B.sort()
C.sort()
A.sort()
D.sort()
d15={0:'sqrt_100 tan_4 cos_2 sin 0',1:'sqrt_100 tan_4 cos_2 sin 1',2:'sqrt_100 tan_2 cos_2 sin 2',3:'sqrt_100 tan_4 cos_2 sin 3',4:'sqrt_100 tan_4 cos_2 sin 4',5:'sqrt_100 tan_4 cos_2 sin 5',6:'sqrt_100 tan_4 cos_2 sin 6',7:'sqrt_100 tan_2 cos_2 sin 7',8:'sqrt_100 tan_2 cos_2 sin 8',9:'sqrt_100 tan_4 cos_2 sin 9'}
def d16(d):return '('+d15[d]+')'

def S0(l):
	cpt=0
	d=l[:-1]
	r=l[-1]
	a1,a2,a3,a4,a5=[int(t) for t in d]
	i1=bisect.bisect(B, r)-1
	w1=abs(r-B[i1])
	i2=bisect.bisect(C, w1)-1
	w2=abs(w1-C[i2])
	s='('+d16(a1)+'/(sin_'+str(i1)+' '+d16(a2)+'-'+'sin_'+str(i1+1)+' '+d16(a3)+')'+'+'+d16(a4)+'/sin_'+str(i2)+' '+d16(a5)+')'
	return (w2,s)

def S1(l):
	cpt=0
	d=l[:-1]
	r=l[-1]
	a1,a2,a3,a4,a5=[int(t) for t in d]
	i1=bisect.bisect(C, r)-1
	w1=abs(r-C[i1])
	i2=bisect.bisect(A, w1)-1
	w2=abs(w1-A[i2])
	s='('+d16(a1)+'/sin_'+str(i1)+' '+d16(a2)+'+sin_'+str(maxi-i2-1)+' ('+d16(a3)+'*'+d16(a4)+'*'+d16(a5)+')'
	return (w2,s)

def S2(l):
	cpt=0
	d=l[:-1]
	r=l[-1]
	a1,a2,a3,a4,a5=[int(t) for t in d]
	i1=bisect.bisect(A, r)-1
	w1=abs(r-A[i1])
	i2=bisect.bisect(D, w1)-1
	w2=abs(w1-D[i2])
	s='('+'(sin_'+str(maxi-i2-1)+' '+d16(a1)+'-'+'sin_'+str(maxi-i2)+' '+d16(a2)+')'+'+sin_'+str(maxi-i1-1)+' ('+d16(a3)+'*'+d16(a4)+'*'+d16(a5)+'))'
	return (w2,s)

def S3(l):
	cpt=0
	d=l[:-1]
	r=l[-1]
	a1,a2,a3,a4,a5=[int(t) for t in d]
	i1=bisect.bisect(A, r)-1
	w2=abs(r-A[i1])
	s='('+'sin_'+str(maxi-i1-1)+' ('+d16(a1)+'*'+d16(a2)+'*'+d16(a3)+'*'+d16(a4)+'*'+d16(a5)+'))'
	return (w2,s)

def S4(l):
	cpt=0
	d=l[:-1]
	r=l[-1]
	a1,a2,a3,a4,a5=[int(t) for t in d]
	i1=bisect.bisect(B, r)-1
	w2=abs(r-B[i1])
	s='('+d16(a1)+'/(sin_'+str(i1)+' '+d16(a2)+'-'+'sin_'+str(i1+1)+' '+d16(a3)+'*'+d16(a4)+'*'+d16(a5)+')'+')'
	return (w2,s)

def S5(l):
	cpt=0
	d=l[:-1]
	r=l[-1]
	a1,a2,a3,a4,a5=[int(t) for t in d]
	i1=bisect.bisect(C, r)-1
	w2=abs(r-C[i1])
	s='('+d16(a1)+'/sin_'+str(i1)+' '+d16(a2)+'*'+d16(a3)+'*'+d16(a4)+'*'+d16(a5)+')'
	return (w2,s)

def S6(l):
	cpt=0
	d=l[:-1]
	r=l[-1]
	a1,a2,a3,a4,a5=[int(t) for t in d]
	i1=bisect.bisect(D, r)-1
	w2=abs(r-D[i1])
	s='(sin_'+str(maxi-i1-1)+' '+d16(a1)+'-'+'sin_'+str(maxi-i1)+' '+d16(a2)+'*'+d16(a3)+'*'+d16(a4)+'*'+d16(a5)+')'
	return (w2,s)

def all4(s1):
	s=0
	for l in s1:
		f=min(S0(l),S1(l),S2(l),S3(l),S4(l),S5(l),S6(l))
		print f[1]
		s+=f[0]
	s/=len(s1)
	print 'average unofficial score:',s
all4(s1)

Try it online!

Your program gets an moy of 49.70 on the official tests. For some reason it does really bad on a test case in section 3 with the following digits: 6 7 8 0 1.

Your program outputs +(tan_4 cos_2 sin 6)/(sin_0((-(tan_4 cos_2 sin 7)-(tan_4 cos_2 sin 8)+(tan_4 cos_2 sin 0)+(tan_4 cos_2 sin 1)))) for that test case, which equals 0.145.

Sorry, I wrote your official test score wrong the first time. You actually do a little worse than average on the official tests.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Unfurl a string
Given a square string, produce all the output for the string at every stage of unfurling.
The string must unfurl in a clockwise direction one quarter turn at a time.
Examples
Input:
A

Output:
A

Note: I'll also accept the input duplicated for this particular test case only if this helps reduce your byte count.
Input:
DC
AB

Output:
DC
AB

  D
ABC

ABCD

Input:
GFE
HID
ABC

Output:
GFE
HID
ABC

   HG
   IF
ABCDE

     IH
ABCDEFG

       I
ABCDEFGH

ABCDEFGHI

Input:
JIHG
KPOF
LMNE
ABCD

Output:
JIHG
KPOF
LMNE
ABCD

    LKJ
    MPI
    NOH
ABCDEFG

       NML
       OPK
ABCDEFGHIJ

          ON
          PM
ABCDEFGHIJKL

            PO
ABCDEFGHIJKLMN

              P
ABCDEFGHIJKLMNO

ABCDEFGHIJKLMNOP

Rules
This is code-golf so the shortest code in bytes wins.

Any reasonable format can be used for I/O assuming it is consistent.
Spaces must be used to pad the top lines of the output.
Must be able to handle input of all printable characters (including space: \x20-\x7e):

 !"#$%&'()*+,-./0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

Leading/trailing whitespace is allowed.
You can assume the string will always be a square.
All standard loopholes are forbidden.

Inspiration: Write a square program that outputs the number of times it has been “unrolled”.

May we output ["A","A"] for "A", like my program does (instead of ["A"])? It seems reasonable to me since they're just the starting and the ending positions, and you only try to unfurl it once.

@Mr.Xcoder I agree, adding code to cater for that specific test case seems like a waste of bytes. I'll accept it for the single byte input and update the question accordingly!

+1 from me, very interesting challenge. This site needs more of these, since they raise the difficulty level and gets rid of the triviality of most solutions. This goes straight to my favourite challenges list. I am disappointed that this has few answers though, I'd really like too see other clever approaches

@Mr.Xcoder I'm glad you like it! I wish I could take credit for coming up with the idea alone, but it's all thanks to @HelkaHomba's challenge!

SOGL V0.12, 21 20 19 18 17 bytes
ø;[;ο⁴№č▓┼№TJι;jI

Try it Here! (→ added because this expects input on the stack)
Explanation:
ø;[;ο⁴№č▓┼№TJι;jI
ø;               push an empty string below the input           stack with the input GFE,HID,ABC
  [              while [ToS (the array) isn't empty] do       ["", [["G","F","E"],["H","I","D"],["A","B","C"]]]
                                                                stack at the second time looping
   ;               duplicate 2nd from top                     [[[H,G], [I,F], [D,E]], "ABC"]
    ο              wrap it in an array                        [[[H,G], [I,F], [D,E]], ["ABC"]]
     ⁴             duplicate 2nd from top                     [[[H,G], [I,F], [D,E]], ["ABC"], [[H,G], [I,F], [D,E]]]
      №            reverse vertically                         [[[H,G], [I,F], [D,E]], ["ABC"], [[D,E], [I,F], [H,G]]]
       č▓          join the inner arrays (┼ fails otherwise)  [[[H,G], [I,F], [D,E]], ["ABC"], ["DE", "IF", "HG"]]
         ┼         add the 2 parts together                   [[[H,G], [I,F], [D,E]], ["ABCDE", "   IF", "   HG"]]
          №        reverse vertically again                   [[[H,G], [I,F], [D,E]], ["   HG", "   IF", "ABCDE"]]
           T       print that without popping                 [[[H,G], [I,F], [D,E]], ["   HG", "   IF", "ABCDE"]]
            J      take the last line off                     [[[H,G], [I,F], [D,E]], ["   HG", "   IF"], "ABCDE"]
             ι     remove the rest of the array               [[[H,G], [I,F], [D,E]], "ABCDE"]
              ;j   remove the last line of the original array ["ABCDE", [[H,G], [I,F]]]
                I  rotate it clockwise                        ["ABCDE", [[I,H], [F,G]]]

Python 2, 209 207 205 203 202 201 200 196 bytes
-4 bytes thanks to @Quelklef!
s=input();l=len;k=''.join;exec"print s;s=[x for x in[' '*l(s[0])+k(x[:-1]for x in s[-2::-1])[t::l(s[0])-1]for t in range(l(s[0]))][:-1]+[s[-1]+k(x[-1]for x in s)[-2::-1]]if x.strip()];"*(2*l(s)-1)

Try it online!
Python 2, 219 217 215 213 212 211 207 bytes
s=input();l=len;k=''.join;exec"print'\\n'.join(s);s=[x for x in[' '*l(s[0])+k(x[:-1]for x in s[-2::-1])[t::l(s[0])-1]for t in range(l(s[0]))][:-1]+[s[-1]+k(x[-1]for x in s)[-2::-1]]if x.strip()];"*(2*l(s)-1)

Try it online!
The first one outputs as a list of Strings, the second one outputs as ASCII-art.

I think [::-1][1:] can be [-2::-1], like in Lynn's answer.

@Quelklef Thanks a lot!

Charcoal, 42 35 bytes
ＡＥθＳθＷ⊟θ«⪫θ¶ＡＥι⮌⪫Ｅθ§μλωθ⊞υι↙←⮌⪫υωＤ⎚

Try it online! Link is to verbose version of code. Edit: Saved 7 bytes mostly by switching from character arrays to strings. Explanation:
ＡＥθＳθ

Read the input square as an array of strings into the variable q.
Ｗ⊟θ«

While the last string in the array is not empty, remove it.
⪫θ¶

Print the rest of the array.
ＡＥι⮌⪫Ｅθ§μλωθ

Rotate the rest of the array by looping through each character of the last string and joining the lth character of every remaining string in the reversed array.
⊞υι↙←⮌⪫υω

Append the previously removed last string to u, which holds the unfurled value, and print it.
Ｄ⎚

Output the result and then clear the canvas ready for the next iteration.
Note that this version outputs the final unfurl on a separate line, if this is undesirable then for 38 bytes:
ＡＥθＳθＷ⊟θ«⊞υι←Ｅ⁺⟦⪫υω⟧⮌θ⮌κＡＥι⮌⪫Ｅθ§μλωθＤ⎚

Try it online! Link is to verbose version of code. Explanation: ←Ｅ⁺⟦⪫υω⟧⮌θ⮌κ reverses the current array, prepends the unfurled line, then reverses the characters in each line, then prints everything upside-down, thus producing the desired result.

I tried doing it a more Charcoal-y way but I couldn't work out where the Rotate and Trim commands leave the cursor...

Haskell, 127 120 bytes
e=[]:e
i#[x]=[]
i#s|t<-foldl(flip$zipWith(:))e$init s,j<-i++last s=(map((j>>" ")++)(init t)++[j++last t]):j#t
f s=s:""#s

Try it online!
Input is a list of lines, e.g. ["DC","AB"] for the second test case, output is a list of lists of lines: [["DC","AB"],["  D","ABC"],["ABCD"]]. Use mapM (putStrLn . unlines) to pretty-print the result.
Edit: Saved 7 bytes by noticing that the shorter transpose I found some while a go comes in handy because it can be modified to reverse each transposed directly.

05AB1E, 18 bytes
[Dí.Bí»,¤UR¦ζŽ`Xì)

Try it online!
Explanation
[            Ž       # while stack is not empty, do:
 D                   # duplicate current list
  í                  # reverse each element
   .B                # pad with spaces to equal length
     í               # reverse each element again
      »,             # join with newlines and print
        ¤U           # store the last element in X
          R¦         # reverse the list and remove the first element
            ζ        # zip with spaces as filler
              `      # split elements separately to stack
               Xì    # prepend X to the last element
                 )   # join the stack to a list

J, 62 bytes
|."1@([:(#~[:-.[:*/"1' '=])|.@{:(}:@],{:@],[)|:@}:)^:(1<#)^:a:

Try it online!
I'm sure this can be golfed a lot. This prints extra whitespace, but only because of the way that J formats the arrays contained within the outputted array to have the same shape.
I think once I go in and comment out exactly what I'm doing, I might get a better idea of how to golf this (having done that now, I don't really know...). For purposes of golfing, it's worth noting that

I have to special case 1 row inputs (the while part of the loop)
I have to eliminate all lines consisting solely of whitespace (surely there must either be a builtin for this or a better way to do it), which is the filter near the end
There are a lot of caps, identity functions, and atops

Explanation
In ungolfing this, I'll be splitting the main function in three.
unfurl_reversed   =. |.@{: (}:@] , {:@] , [) |:@}:
whitespace_filter =. #~ [: -. [: */"1 ' ' = ]
unfurl            =. |."1@(whitespace_filter @: unfurl_reversed) ^: (1 < #) ^: a:

test_case         =. 3 3 $ 'GFEHIDABC'

We'll be working with the second test case.
unfurl_reversed
|.@{: (}:@] , {:@] , [) |:@}:

This gives one the string unfurled once, but in reverse. All of this is being done in reverse and in a specific order so that the way J automatically pads strings with spaces to match the shape of the array they're in will give the right spacing.
|:@}: is the transpose of the curtail of the input
   |:@}: test_case
GH
FI
ED

|.@{: is the reverse of the tail of the input
   |.@{: test_case
CBA

I think you can see what we want to do: we want to append the reverse of the tail to the last part of the transpose of the curtail (that's a mouthful, but basically attach CBA to the end of ED). This will give us one step of unfurling, reversed.
(}:@],{:@],[) does just that.
It appends CBA to ED, then joins that with the rest of the array. Our output therefore is
   unfurl_reversed test_case
GH
FI
EDCBA

whitespace_filter
#~ [: -. [: */"1 ' ' = ]
                 ' ' = ]  Equate each element to space
            */"1          Product of each row (all true?)
      -.                  Negate
#~                        Filter rows that are true

Basically, this tests to see if any row is completely spaces, and removes it if it is. It doesn't do anything for the first iteration of the test case.
This is necessary (at least until I find an alternative) since otherwise we'll eventually be unfurling whitespace into our output string.
unfurl
|."1@(whitespace_filter @: unfurl_reversed) ^: (1 < #) ^: a:

Unfurl basically puts the other functions together and special cases single character inputs.
When the power of verb (^:) is given the empty box (a:), it applies a function on an input until it converges and collects the results in an array.
(1 < #) checks that the rows are always greater than 1 (to special case 1 row inputs).
|."1 reverses each row, so it inverts the results of whitespace_filter @: unfurl.

Perl 5, 155 bytes
$"=$,;@a=map[/./g],<>;while(@a){say' 'x(length$s)."@$_"for@a[0..@a-2];say$s.="@{pop@a}";say@b=();for$i(0..$#a){$q=0;$b[$q++][$#a-$i]=$_ for@{$a[$i]}}@a=@b}

Try it online!
Saved a few bytes without really modifying the logic.  The flow below is still basically correct.
# Perl 5, 163 bytes
$"=$,;@a=map[/./g],<>;while(@a){say' 'x(length$s)."@{$a[$_]}"for 0..@a-2;say$s.="@{pop@a}";say@b=();for$i(0..$#a){$b[$_][$#a-$i]=$a[$i][$_]for 0..$#{$a[$i]}}@a=@b}

Try it online!
How?
$"=$,; #set the array output separator to null
@a=map[/./g],<>;   # take the input as a 2-D array @a
while(@a){         # repeat while there are still things to unfurl
  say' 'x(length$s)."@{$a[$_]}"for 0..@a-2; # output all but last
                                            # line of the remaining
                                            # square
  say$s.="@{pop@a}";  # remove bottom row, add it to the unfurled string $s
                      # and output it
  say@b=();           # clear temporary array; output empty array, causing
                      # a newline to output

                      # rotate remaining shape 90 degrees:
  for$i(0..$#a){$b[$_][$#a-$i]=$a[$i][$_]for 0..$#{$a[$i]}}
  @a=@b               # replace input with rotated array
}

Nice method, but I'm after the output at each stage of unfurling, could you update to print all steps? Sorry!

OK, I rewrote it.

Perfect, thanks! Sorry for causing extra bytes though...

Python 2, 143 132 bytes
a=input()
while 1:print'\n'.join(a);b=map(''.join,zip(*map(str.strip,a[-2::-1])));a[-1]+=b.pop();a[:-1]=[len(a[0])*' '+x for x in b]

Try it online!
In each iteration, b is the “head” of the string (first n−1 rows), rotated 90 degrees: if a is ["       NML", "       OPK", "ABCDEFGHIJ"] then b is ["ON", "PM", "KL"].
To unfurl a string once, we append the final line of b to a[-1] (giving "ABCDEFGHIJKL") and then recompute a[:-1] by adding spaces to the rest of the strings in b.
We terminate by attempting to pop from b when it’s empty.
Python 2, 132 bytes
a=input()
while 1:s=str.strip;print'\n'.join(a);a[:-1]=[len(a[0])*' '+''.join(x)for x in zip(*map(s,a[-2::-1]))];a[-1]+=s(a.pop(-2))

Try it online!
Same idea, written differently. We terminate by attempting to a.pop(-2) when a has only one element.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Undo a Range of Numbers
It is fairly simple to, given a number n, create a range from 0 to n-1. In fact, many languages provide this operation as a builtin.
The following CJam program reads an integer, and then prints out such a range (Try it online!):
ri,

Notice that it prints out numbers without a separator.
The Challenge
Your task is to reverse this process. You should write a program that, given a string representing a range, returns the number used to produce that range.
Specifications

The numbers are given without any separator.
You may assume the string forms a valid range.
You may use 0- or 1-based indexing for your range.
You may assume that a correct output will never exceed 32,767 (so a valid input will never have a length greater than 152,725).
You may assume that a correct output will always be positive (so you do not have to handle 0 or negative).

This is code-golf, so the shortest competing answer (measured in bytes) wins.
Test Cases
0-indexed:
0123 -> 4
0 -> 1
0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 -> 101

1-indexed:
1234 -> 4
1 -> 1
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 -> 100

Are there any descending ranges? Does it need to work for negative numbers?

@Daniel No. Forgot to mention that; added.

Do our programs really need to handle the empty string? I think it would be reasonable to allow us to ignore that. Some answers do not benefit from that rule at all.

Can the output be a string representation of the number i.e. taken as a substring from the original string?

@user2390246 Yes, that's fine.

@Mr.Xcoder That's fair, considering that I expect many languages' range builtins won't handle it.

"You may assume that a correct output will always be positive (so you do not have to handle 0 or negative)." Yet, you put 0 in the test cases!

@Zacharý I didn't delete those when I added that rule. Edited.

Related.

Prolog (SWI), 91 80 bytes
0-indexed.
X*L:-atom_length(X,L),
     between(0,L,Y),
     numlist(0,Y,B),
     atomic_list_concat(B,X)
     ;L=0.

Newlines added for readability.
Try it online!

Husk, 5 bytes
LCmLN

Try it online!
Only letters!
Takes input as a string, result is 1-indexed.
Explanation
LCmLN
  mLN    get the list of lengths of all positive naturals
 C       cut the input into slices of those lengths
L        get the length of the resulting list

05AB1E, 7 6 bytes
1-indexed.
āηJsk>

Try it online!
or as a Test Suite
Explanation
ā        # push range [1 ... len(input)]
 η       # compute prefixes of the range
  J      # join each prefix to a string
   sk    # get index of the input in the list of prefixes
     >   # increment

Am I doing something wrong? This seems to return 0 no matter the input: https://tio.run/##MzBNTDJM/f8/3efcdi/PbLv//5UMjYxNTM3MLSwNDZQA

@Shaggy: You have to do it like this or this as single quotes count as part of the input.

Ah, so string inputs in 05AB1E need to be triple quoted?

@Shaggy: If you want the empty string or newlines in the input yes. Otherwise you don't need to quote it at all.

[NÝJQ#]N was my idea, but this is better because it works for "".

Brachylog, 9 7 bytes
⟦kṫᵐc,Ẹ

Try it online!
0-indexed.
Explanation
Here we pass the input through the Output variable, and access the result through the Input variable.
⟦          The result is the input to a range…
 k         …with the last element removed…
  ṫᵐ       …which when all elements are casted to string…
    c      …and are then concatenated results in the input string
     ,Ẹ    (Append the empty string, this is necessary for it to work in the case where the
             input is the empty string)

Java 8, 66 59 bytes
s->{int r=0;for(String c="";!c.equals(s);c+=r++);return r;}

0-indexed
-7 bytes thanks to @PunPun1000.
I have the feeling this can be shortened by only checking the length of the input somehow, since we can assume the input is always valid. Still figuring this out. Unable to figure this out, and it will probably cost too many bytes in Java to be useful anyway (same applies to returning a substring of the end of a 1-indexed input).
Explanation:
Try it here.
s->{                 // Method with String parameter and integer return-type
  int r=0;           //  Result-integer
  for(String c="";   //  Check-String
      !c.equals(s);  //  Loop as long as the sum-String doesn't equal the input-String
    c+=r++           //   Append the number to the the Check-String,
                     //   and increase the Result-integer by 1
  );                 //  End of loop
  return r;          //  Return the result-integer
}                    // End of method

59 bytes: TIO

There's probably some absurd shortcut like counting the number of ones or using the logarithm of the length to get the length of the needed substring... I only seem to have bad ideas for this.

Ly, 29 bytes
iys&p>0<11[ppl>s1+<lfspSylL]>

Try it online!
Can't believe this worked as well as it did...

Japt, 8 bytes
Starting to get to grips with function methods in Japt.
0-indexed. Can take input as a string, an integer or an array containing 0 or 1 elements.
_o ¬¥U}a

Test it

Explanation
Implicit input of string U.
_     }a

Get the first integer >=0 that returns true when passed through a function that ...
o

Generates an array of integers from 0 to 1 less than the current integer ...
¬

Joins it to a string ...
¥U

Checks that string for equality with U.
Implicit output of resulting integer.

Alternative, 8 bytes
ÊÇo ¬ÃbU

Test it

Charcoal, 13 bytes
Ｉ⌕Ｅ⁺ψθ⪫ＥκＩλωθ

Try it online! Link is to verbose version of code. Explanation:
          λ     Inner map variable (μ inner map index also works)
         Ｉ      Cast to string
        κ       Outer map index
       Ｅ        Map over implicit range
      ⪫    ω    Join result
     θ          Input string
   ⁺ψ           Plus an extra character
  Ｅ             Map over each character
 ⌕          θ   Find the index of the original string
Ｉ               Cast from integer to string
                Implicit print

Retina, 30 bytes
+1`(\d+?)(?!\D)(?<!\1.+)
$0;
;

Recursively adds a semicolon after each number then counts the number of semicolons
Try it online!

Haskell, 40 37 bytes
f s=[n|n<-[0..],(show=<<[0..n])>s]!!0

Function that reverses zero-based ranges.
Thanks to Laikoni for saving 3 bytes!
Try it online.

37 bytes with a list comprehension: f s=[n|n<-[0..],(show=<<[0..n])>s]!!0.

And just to mention it, you can save a byte by using the second pattern guard: |m<-n+1=s!m.

Perl 5, 19 bytes
18 bytes code + 1 for -p.
$i++while s/$i\B//

Uses 1-based indexing. -7 bytes thanks to @nwellnhof's much better approach!
Try it online!
Explanation
$\ is a special variable that is printed automatically after each statement, so by using that to store our number we don't need to update $_ (which is automatically printed as part of the functionality of the -p flag) to contain the desired output. Then, whilst the input starts with $\, remove it and redo the program, which again increments $\ and replaces it. When it no longer finds the number at the beginning of the string, we're done! Finally, decrement $\ so we have the last number in the range.

What about $i++while s/$i\B// (18 + 1 bytes)?

@nwellnhof That's much better! I think I started down a more complex route as I made the answer 0-indexed first of all... Thanks!

JavaScript (ES6), 32 31 bytes
Saved 1 byte thanks to Challenger5
f=(s,r=n='')=>r<s?f(s,r+n++):+n

Test cases

f=(s,r=n='')=>r<s?f(s,r+n++):+n

console.log(f('0123'))
console.log(f('0'))
console.log(f(''))
console.log(f('0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100'))

Again, can you compare the strings lexicographically?

I was going to suggest currying but it looks like that's no longer a consensus :(

@Shaggy Umm, it is actually...

@EriktheOutgolfer Standard currying is fine, but Shaggy was referring to this special form of currying which requires calls such as f(payload_param)() or even f(payload_param)(some_constant). (Incidentally, I'm not sure that would work in this particular case because I need both r and n to be initialized.)

Mathematica, 46 bytes
Array[""<>ToString/@Range@#&,2^15]~Position~#&

1-indexed
input

["12345678910"]

R, 47 bytes
n=nchar(scan(,""));which(cumsum(nchar(1:n))==n)

Try it online!
1-indexed

Use "if" instead of ifelse

Good point! But OP has now removed the requirement to deal with the 0 case, so I can get rid of that bit entirely...

You can take input as a number, as nchar works as you might expect on numbers. However, you need to handle printing your output, since this wouldn't when run as a full program.

n=nchar(scan());cat(which(cumsum(nchar(1:n))==n))

Ruby, 51 50 46 bytes
->n{(0..4e4).map{|x|(1..x).to_a.join}.index n}

(This is my first Ruby program ever so it must be easy to golf it further)
-4 bytes thanks to @Nnnes

You don't need the last set of parenthesis: .index(gets) => .index gets. You can use 4e4 instead of 8**5, though this will make it run even slower. It's generally OK, and often saves a few bytes, to use anonymous lambdas for Ruby answers: Try it online! (I changed the limit to 100 so that it doesn't time out.)

Python 2, 43 bytes
f=lambda s,i=1,r='':r<s and-~f(s,i+1,r+`i`)

Try it online!

Python 2, 43 bytes
f=lambda s,i=1:s>''and-~f(s[len(`i`):],i+1)

Try it online!

Python, 46 bytes
lambda s:s[-sum(i*'0'in s for i in range(5)):]

Try it online!
A different strategy. Takes a number of characters from the end equal to the length of the largest run of 0's in s.

Python, 46 bytes
f=lambda s,c=0:c*'0'in s and f(s,c+1)or s[-c:]

Try it online!
Recursive version of the above.

Does your "different strategy" (very clever,  btw) work for 0-based ranges as required in the statement of the challenge? Should you change the inner bit to ... i*'0'in s[1:] for ... or something like that?

@LucaCiti It works for 1-based ranges, and the challenge lets us choose.

Sure, you are right.  I only looked at the initial description and missed the part where it allows for 1-based ranges.

APL (Dyalog), 17 11 bytes
-6 bytes thanks to ngn.
{,\⍕¨⍳≢⍵}⍳⊂

Try it online!
⍳⊂ find the ɩndex of the entire argument in
{…} the result of this anonymous function:
 ≢ length of the argument
 ⍳ ɩntegers until that
 ⍕¨ format (stringify) each
 ,\ cumulative concatenation of those

Oh, I forgot I could just go off of the length, nice job.

{,\⍕¨⍳≢⍵}⍳⊂ (11 chars)

@ngn Silly me. Of course!

Python 2, 46 bytes
0-indexed
l=lambda x,z="",y=0:z<x and l(x,z+`y`,y+1)or y

Try it online!

Pyth, 11 10 bytes
1-indexed.
fqQ|jkSTk0

Try it here
If the empty string could be ignored, this can be shortened to 6 bytes:
fqQjkS

-1 byte thanks to @Mnemonic

?QfqQjkUT)1 can do it in 11 as well, but I feel like some reordering can golf off a byte. Any ideas?

You can save a byte by using jk instead of s`m.

Aceto, 27 25 bytes
1-based index.
;L[¥
`=]z
MLdI<
r!`;   p

We read the input and Memorize it (and directly Load it again), then we negate it (!; leading to a truthy value only for an empty string). If this value is truthy (`), we jump to the end (;), where we print the implicit zero.
Otherwise, we increment the current stack value (initially a zero), duplicate it, and put one copy on the stack to the right, while also moving there (Id]). We then construct a decreasing range (z), join the stack as a string (¥), and move the value (and us) on the original stack again ([). We Load the value we memorized earlier (the input) and compare it with this string. If equal, we jump to the end again, where we print the current "counter" value (=`;).
Otherwise, lots of empty space is traversed until the Hilbert curve eventually hits the < which puts the IP on top of I again, incrementing the counter and testing again.

CJam, 13 bytes
q:Q,),{,sQ=}#

So many commas...
Try it online!
Explanation
q:Q            Read the input and store it in Q
   ,           Get its length
    ),         Get the range 0..n
      {,sQ=}#  Find the index of the first number in the range to satisfy this block:
       ,        Get the range 0..(number)-1
        s       Stringify it
         Q=     Check if it equals the input

CJam, 16 bytes
r0({)_,s2$=!}g\;

Try it online!
Alternative 16 bytes
r:V;0({)_,sV=!}g

Try it online!

Perl 6,  30 28  27 bytes
{first :k,*eq$_,[\~] '',0...*}

Test it
{[\~]('',0...*).first($_):k}

Test it
{first :k,$_,[\~] '',0...*}

Test it
Expanded:
{  # bare block lambda with implicit parameter ｢$_｣

  first       # find the first one
  :k,         # return the index into the Seq instead of what matched
  $_          # that matches the input

  # from the following

  [\~]        # triangle reduce using &infix:«~» (string concatenation)

              # a Seq
    '',       #   that starts with an empty Str
    0         #   then a 0
    ...       #   generate values
    *         #   indefinitely
}

'',0...* produces an infinite sequence of values '',0,1,2,3 …
[\~] '',0...* produces an infinite sequence of all of the possible inputs
""
"0"
"01"
"012"
"0123"
...

Note that this code will never stop if you give it an invalid input.

CJam, 14 12 11 bytes
q,_){,s,}%#

Try it Online
q,   e# Get length of input string
_)   e# Duplicate length, increment by 1
{    e# Generate array by mapping [0,1,2,...,length] using the following function:
,    e# Generate range [0,x] (x is the int we're mapping)
s    e# Convert range to string (e.g [0,1,2,3] => "0123"
,    e# Get the length of that string
}%   e# Map the int to the length of it's range string
#    e# Return the index of the length of the input string in the generated array

Dyvil, 42 38 bytes
s=>"".{var r=0;while($0!=s)$0++=r++;r}

Same algorithm as this Java answer, except it (ab)uses some of Dyvil's syntactic specialties.
Explanation:
s=>          // starts a lambda expression with one parameter
"".{         // begins a brace access expression, the value before the '.'
             // is available within the braces as a variable named '$0'
var r=0;     // variable with inferred type int
while($0!=s) // while the accumulator $0 does not (structurally) equal s
$0++=r++     // concatenate $0 and the String representation of r,
             // then store the result in $0 and increment r by 1
;            // end of while
r}           // return r as the result of the lambda

Saved 4 bytes by using a brace access expression instead of a variable for the accumulator

Cool language!!

Thunno 2, 4 bytes
ƘRJ=

Try it online!
Thunno 2, 6 bytes
żƒ€JȮ⁺

Try it online!
Explanation
ƘRJ=  # Implicit input
Ƙ     # First integer where:
 RJ   #  Join the range
   =  #  Equals the input?
      # Implicit output

żƒ€JȮ⁺  # Implicit input
ż       # Push [1..length]
 ƒ      # Prefixes of this list
  €J    # Join each into a string
    Ȯ⁺  # 1-based index of input
        # Implicit output

PowerShell, 47 bytes
do{$b=1..$a-join"";$a+=1}while($b-ne$args);$a-1

Try it online!

Nice answer! You need to include the $args|%{...} sections of the code in the byte count and answer as they are part of the code. example

Also, you can pass a single parameter to the function to save some bytes example

Arturo, 31 bytes
$->s[0while[s<>join@1..<=]->1+]

Try it!

SOGL V0.12, 11 10 9 bytes
1-indexed.
I∫HΔ∑=?f←

Try it Here!
Explanation:
I∫         repeat input+1 times
  HΔ         create a range from 1 to the 0-indexed iteration, inclusive
    ∑        join it
     =?      if it's equal to the input
       f←      exit, pushing the 0-indexed counter

..or 7 bytes without the empty case
∫Δ∑=?F←

Try it Here!

C#, 72 bytes

Data

Input String i The int array to be deciphered
Output Int32 The number used to make the array

Golfed
(string i)=>{int c,p=c=0;for(;p<i.Length;c++)p+=(c+"").Length;return c;}

Ungolfed
( string i ) => {
    int
        c,
        p = c = 0;

    for( ; p < i.Length; c++ )
        p += ( c + "" ).Length;

    return c;
}

Ungolfed readable
// Takes the string with the int array
( string i ) => {
    int
        c,         // Counter, it will count how many ints the array has.
        p = c = 0; // Padding, it will help jumping from int to int on the string.

    // Start counting. If 'i' is empty, the 'c' will be 0.
    for( ; p < i.Length; c++ )

        // Increase the number of digits with the length of 'c'.
        p += ( c + "" ).Length;

    // Return the counter.
    return c;
}

Full code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestBench {
    public static class Program {
        private static Func<String, Int32> f = ( string i ) => {
            int
                c,
                p = c = 0;

            for( ; p < i.Length; c++ )
                p += ( c + "" ).Length;

            return c;
        };

        static void Main( string[] args ) {
            List<String>
                testCases = new List<String>() {
                    "0123",
                    "0",
                    "",
                    "0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100",
                };

            foreach(String testCase in testCases) {
                Console.WriteLine($" Input: {testCase}\nOutput: {f(testCase)}\n");
            }

            Console.ReadLine();
        }
    }
}

Releases

v1.0 - 72 bytes - Initial solution.

Notes

None

i=>{int c,p=c=0;for(;p<i.Length;)p+=(c+++"").Length;return c;} 62 bytes

Stacked, 23 bytes
{!0$#+[::>''#`n=]until}

Try it online!
Basically, increments  0 until the range from 0 to the number looks like the input, checking for equality first.

Jelly, 8 bytes
JVṾẎ$$Ƥi

Try it online!

APL, 28 bytes
{⍺←0⋄(' '~⍨⍕⍳⍺)≡∊⍵:⍺⋄⍵∇⍨⍺+1}

Try it online!
The index origin must be 1, thus this is 1-based.
This will not work on some of the test cases due to memory limitations.
It works by going through each number and checking if the range as a string with spaces removed matches the argument, if not, it calls itself with its left argument (default of 0) incremented by 1.

Out-golfed!

I expected that.

Python 2, 49 48 46 bytes
-1 thanks to Challenger5
-2 thanks to Mr. Xcoder
f=lambda s,i=0,t='':t<s and f(s,i+1,t+`i`)or i

Try it online!

Can you compare the strings lexicographically to save a byte?

46 bytes using recursion, but it's Halvard's solution already

I think you mean, "-2 thanks to Mr. Xcoder".

MATL, 14 bytes
`@q:VXzGX=~}@q

1-indexed.
Try it online!
Explanation
`       % Do...while
  @     %   Push iteration index (1-based), k
  q     %   Subtract 1: gives k-1
  :     %   Range: [1 2 ... k-1]. Will be empty for k=1
  V     %   Convert to string
  Xz    %   Remove spaces
  G     %   Push input
  X=    %   Are the two strings equal?
  ~     %   Negate. This is the loop condition. If true: next iteration
}       % Finally (execute at the end of the loop)
  @     %   Push k
  q     %   Subtract 1: gives k-1. This is the solution
        % End (implicit). Display (implicit)

Wait, Charcoal beat MATL?

PHP, 35 bytes
for(;$s!=$argv[1];$s.=++$i);echo$i;

Try it online!
1-indexed.
Continually increment i and add to a string until it matches the input, then return i.

Proton, 50 bytes
n=input(s="")
i=0
for(;s!=n;s+=str(i++))1
print(i)

Sadly Proton doesn't do default parameters very well, so no recursion...
Try it online!

Common Lisp, 84 bytes
(lambda(x)(do((i 0(1+ i))(s""(concatenate'string s(format()"~a"i))))((equal x s)i)))

Try it online!

Jelly, 7 bytes
1RV⁼ɗ1#

Try it online!
1-indexed, and expects input as one big int (or equivalently, requires no additional quotes or such as a full program).
1    1#    Find the first positive integer n for which
 R         [1 .. n]
  V        smashed together into a flat string then evaluated as an integer
   ⁼ɗ      equals the input.

This one... runs into some issues pretty fast...
Jelly, 4 bytes
RV)i

Try it online!
Jelly lists are Python lists, and Python lists aren't lazy. So even for relatively small outputs, this ends up attempting to construct lists that CPython literally cannot construct regardless of any actual memory issues, and it slows down very dramatically before that.

PowerShell Core, 34 bytes
for(;"$args"-ne-join(1..++$a)){}$a

Try it online!
1-indexed, takes the input as a string

Curry (KiCS2) + :set +first, 26 bytes
f(g n)=n
g n=[1..n]>>=show

Attempt This Online!
1-indexed.

Vyxal, 31 bitsv2, 3.875 bytes
ʀɾṅḟ

Try it Online!
1 indexed. Takes input as a number
Explained
ʀɾṅḟ
ʀɾ    # The range [1, n] for each number in the range [0, input]
  ṅ   # Join each range into a single string
   ḟ  # And find the index of the input in that.

Created with the help of Luminespire.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
The Solar Eclipse Through a Pinhole Camera
This challenge is a simple ASCII-art challenge inspired by the solar eclipse that happened on August 21, 2017. Given an input 0 <= n <= 4, output the corresponding stage of the eclipse described below:
n=0:
   *****
 **     **
*         *
*         *
**       **
  *******

n=1:
   *****
 **  *****
*   *******
*   *******
**   ******
  *******

n=2:
   *****
 *********
***********
***********
***********
  *******

n=3:
   *****
 *****  **
*******   *
*******   *
******   **
  *******

n=4:
   *****
 **     **
*         *
*         *
**       **
  *******

Rules

You can 0 or 1 index, state what you chose.
The chars used are space and *, you may use any printable char for * (other than space).
Trailing spaces are optional (you may or may not have them).
This is code-golf, lowest byte-count is the winner.

@Mr.Xcoder I'm against tagging challenges getting input as [tag:kolmogorov-complexity], although that's up to OP's discretion.

Bummer that it's not symmetric top-to-bottom.

Also, the eclipse has already started...

@AdmBorkBork Yeah I could've saved some bytes...

@AdmBorkBork it looks really weird like that though :(.

Related

"You may use any character for *" ... including space? ;)

Python 2, 161 149 142 135 bytes
lambda n,u=u' *':u'''   *****
 ****
**
**
****
  *******'''.translate({1:u[0<n<3],2:u[0<n<4],3:u[1<n<4]})

Try it online!
-7 thanks to Mr. Xcoder.

Nice abuse of unprintables.

Didn't fully appreciate this answer until I copy-pasted into Emacs. Brilliant!

@SilvioMayolo Umm, what did you do with Emacs?

I was just looking at the answer on this page and didn't understand how it worked. Emacs shows all the hidden characters as ^A, ^B, ^C, etc.

@SilvioMayolo Oh, that's because unprintables have a representation that looks somewhat like Unicode chars.

Charcoal, 82 81 55 43 bytes
-38 bytes thanks to Neil!
Ｎν”{“⟲ＦEd⧴_³⟲”‖Ｏ¿﹪ν⁴«Ｆ﹪ν²Ｇ↗³↑²↖²↙³*↑¤*¿⁼ν¹‖

Try it online! Link is to verbose version.
I did for the heck of it. :P I'll probably get out-golfed by 40 bytes. 26 38 bytes... Close enough?

I made some simplifications to your basic algorithm: Try it online!

I got out-golfed in my logic instead of my inability to use Charcoal. >_> Thanks!

Looks like printing the outer "circle" works out shortest. I was also creative with the polygon for the odd inputs: Try it online!

Dammit, I thought I was being clever with PolygonHollow. :P 2) Ohh, nice. Thanks!

Cinnamon Gum, 70 bytes
Hexdump:
0000000: 6c33 5053 5050 d002 012e 20a5 0002 4026  l3PSPP.... ...@&
0000010: 9001 0568 6c20 07a6 0648 4080 b521 8a19  ...hl ...H@..!..
0000020: 30a6 1644 1093 0de3 a098 6184 6206 422d  0..D......a.b.B-
0000030: 6136 c20c 6374 3380 3cb8 5aa0 1436 36ba  a6..ct3.<.Z..66.
0000040: 5f4c 280f 0f00                           _L(...

Try it online!
I have been waiting so long to find out how to use this language. :P
So, Cinnamon Gum is Bubblegum, but it's more of a "real" language than Bubblegum.
The first byte (l) sets the mode to dictionary mode. The rest of the bytes is the following string compressed.
0&   *****
 **     **
*         *
*         *
**       **
  *******;1&   *****
 **  *****
*   *******
*   *******
**   ******
  *******;2&   *****
 *********
***********
***********
***********
  *******;3&   *****
 *****  **
*******   *
*******   *
******   **
  *******;4&   *****
 **     **
*         *
*         *
**       **
  *******

This essentially makes a lookup table with each text assigned to a number. The program then takes input and outputs the respective text.

Can argument%4 or argument&3 save bytes?

JavaScript (ES6), 103 102 bytes

f=
n=>`   *****
 **66733**${s=`
*666777333*`}${s}
**6667333**
  *******`.replace(/\d/g,c=>" *"[c*2>>n&1])
<input type=number min=0 max=4 oninput=o.textContent=f(this.value)><pre id=o>

Edit: Saved 1 byte thanks to @darrylyeo.

-2 bytes by storing *666777333*\n in a variable.

@darrylyeo I must be doing something wrong because I can only seem to save 1 byte...

My bad, it does indeed save just 1 byte.

VI, 108 bytes
D:let@a=@"%2?@":@"%4?"X":"\\d"<CR>
3i <Esc>5a*<Esc>Yphr*$a*<Esc>O**1110333**<Esc>YPi <Esc>3lx3lx"0px4lyl2p$xYp
:%s/<C-r>a/ /g<CR>
:%s/\d/*/g<CR>

<CR> is the Enter stroke, <C-?> corresponds to Control + ?, and <Esc> to Escape obviously. Each of these count for 1 byte (see meta). The line breaks in the solution is for readability. Only <CR> represents real Enter strokes.
Input
The input file should contain only 1 character, representing n.
Launch
VI should be started like :
vi -u NONE input

Explanations
There are 3 parts in the solution. I will describe the 2nd part first (2nd line), since it is the easiest to explain.
Drawing the sun
The command to draw the sun is :
3i <Esc>5a*<Esc>Yphr*$a*<Esc>O**1110333**<Esc>YPi <Esc>3lx3lx"0px4lyl2p$xYp

The sun must be drawn with , *, 0, 1 and 3, like this :
   *****
 **11033**
*111000333*
*111000333*
**1110333**
  *******

A symmetry would have helped to reduce the bytes size of this part, but it's not that important. I will not explain the full line, but the pattern ***** is used to easily generate the last line, and the pattern **1110333** has been taken as a reference to generate the 3 other lines containing 0, 1 and 3.
It is important to use 0, 1 and 3 for sun parts that can be filled (see next explanations). Drawing this sun takes 55 bytes, and can probably be golfed with some tricks.
Filling the sun according to n
To correctly fill the sun, the instructions to follow are :

if n = 0, then 0, 1 and 3 (all digits) should be replaced with
if n = 1, then 1 should be replaced with , the other digits with *
if n = 2, then 0, 1 and 3 (all digits) should be replaced with *
if n = 3, then 3 should be replaced with , the other digits with *
if n = 4, then 0, 1 and 3 (all digits) should be replaced with  (like n = 0)

From that, we can infer that the substitutions required are :

replace some digits by  (first substitution)
replace all other digits by * (second substitution)

Note that "some digits" can mean "no digits" (n = 2 for example). And "all other digits" can also represent "no digits", if all digits have already been replaced by the first substitution (n = 0 for example).
The second substitution can be easily written in 11 bytes :
:%s/\d/*/g<CR>

The first substitution depends on n, so first we have to calculate what digits are going to be replaced. If replaced characters are stored in register a, the substitution command is written in also 11 bytes :
:%s/<C-r>a/ /g<CR>

<C-r>a is replaced by the content of register a when the command is typed.
To calculate the value of a, following the previous instructions, the algorithm is (in pseudo-code) :
n := read()
if (n % 2 != 0)
then
    a := n
else
    if(n % 4 != 0)
    then
        a := "X"
    else
        a := "\d"

"X" string is used because when n = 2, no digits are replaced by spaces. Any string that is not the sun could be used here, as long as the first substitution does nothing.
This could be written in 31 bytes :
D                                   # yank and delete the first character of the file (n) to register "" (yank by default) : n = @"
 :let@a=                            # define register "a content
        @"%2                        # if (n % 2 != 0)
            ?                       # then
             @"                     #   n
               :                    # else
                @"%4                #   if (n % 4 != 0)
                    ?               #   then
                     "X"            #       "X"
                        :           #   else
                         "\\d"      #       "\\d"
                              <CR>  # calculate "a

Solution
Put all these parts in the right order, and you have the solution :
D:let@a=@"%2?@":@"%4?"X":"\\d"<CR>                                              # calculate the digits to replace with spaces
3i <Esc>5a*<Esc>Yphr*$a*<Esc>O**1110333**<Esc>YPi <Esc>3lx3lx"0px4lyl2p$xYp     # draw the sun with spaces, stars, 0, 1 and 3
:%s/<C-r>a/ /g<CR>                                                              # replace the pattern stored in register "a with spaces
:%s/\d/*/g<CR>                                                                  # replace the remaining digits with stars

SOGL V0.12, 40 39 bytes
"⁽Ρūa╔Ƨ ‘╥▓.4%?52"¹ο1¹‘╬¡╬5.H?:±}.2=?╬8

Try it Here!

If that helps any, Trailing spaces are optional (you may or may not have them). - Don't know SOGL, but might save bytes

@Mr.Xcoder It'd do the opposite, as SOGL adds trailing spaces when dealing with ASCII art anywhere :p

PHP, 114+1 bytes
+1 byte for -R. Thanks @Neil for the shifting hint.
for(;$c="   *****
 **66733**
*666777333*
*666777333*
**6667333**
  *******"[$i++];)echo+$c?" *"[$c*2>>$argn&1]:$c;

uses underscore for *, 0-indexed. Run as pipe with -nR or try it online.
Requires PHP 5.5 or later:
older PHP does not understand literal string indexing (parse error);
PHP 7.1 complains about non-numeric values (replace +$c with $c>0 to fix).

I think " _"[$c*2>>$argn&1] avoids negative shift parameters if you need it.

Java 8, 225 213 211 200 bytes
n->{String y="   ",z="***",a=n<2|n>3?y:z,b=n<1|n>2?y:z,c=n%4<1?" ":"*",d=a+(n%4<1?y:z)+b;return y+z+"**\n **"+(n<2|n>3?"  ":"**")+c+(n<1|n>2?"  ":"**")+"**\n*"+d+"*\n*"+d+"*\n**"+a+c+b+"**\n  *"+z+z;}

-11 bytes thanks to @ceilingcat.
Try it here.

Python 2, 181 bytes
lambda n,s=' ',a='*':"""   *****
 **%s**
*%s*
*%s*
**%s**
  *******"""%[(s*5,s*9,s*9,s*7),(s*2+a*3,s*3+a*6,s*3+a*6,s*3+a*4),(a*5,a*9,a*9,a*7),(a*3+s*2,a*6+s*3,a*6+s*3,a*4+s*3)][n%4]

Try it online!
Very naive approach, workin' on golfin' nvm.

Python 2, 170 169 bytes

-1 byte thanks to @TheIOSCoder: use of exec

def f(x,k=0):exec'print"".join(ord(i)*" *"[j%2]for j,i in enumerate(["		","	","	!",""][x%4]))[11*k:][:11];k+=1;'*6

Try it online!

169 bytes

05AB1E, 46 bytes
„* •zÇRéóĀ—ÚÂÐoʒ<]ÜA›¶Ò¿H¶ ∞m•b3äûIèSèJ6äIií}»

Try it online!

Vyxal j, 48 bytes
‛* »>ṪÞ£Ǔḟṅ↲Ṅ²3@qx⋎
ṡµ⌈İ∆µ^X1»bṅ3/∞?if⌊İṅ6/?1=[R

Try it Online!
How?
‛* »>ṪÞ£Ǔḟṅ↲Ṅ²3@qx⋎
ṡµ⌈İ∆µ^X1»bṅ3/∞?if⌊İṅ6/?1=[R
‛*                    # Push string "* "
   »>ṪÞ£Ǔḟṅ↲Ṅ²3@qx⋎\nṡµ⌈İ∆µ^X1»
                      # Push compressed integer 90018261496673587326026870693610373816328976440801592144686583
b                     # Convert it to binary
 ṅ                    # Join by nothing
  3/                  # Split it into 3 equal parts
    ∞                 # Palindromise this list
     ?                # Push the input
      i               # Index it into the list
       f              # Convert to list of characters
        ⌊             # Convert each to an integer
         İ            # Index each into the other string ("* ")
          ṅ           # Join by nothing
           6/         # Split into six equal parts
             ?1=[     # If the input is equal to one:
                 R    # Reverse each


text:
Skip like a frog!
Given an array of non-negative integers, your task is to only keep certain elements of it, as described below.

Let's say the array is [1, 3, 2, 4, 11, 5, 2, 0, 13, 10, 1].

First get the first element of the array, n. Keep the first n elements and discard the next one (discard the n+1th). The new array is [1, 2, 4, 11, 5, 2, 0, 13, 10, 1].

Then, you grab the element following the one removed and do the exact same thing. Reapplying the process, we get [1, 2, 11, 5, 2, 0, 13, 10, 1]

You repeat the process until you arrive outside the array's bounds / there are no elements left in the array. We stop because 11 is higher than the length of the array.

Now you should output the result.

Input / output may be taken / provided in any standard form. The array will never be empty, and will only contain non-negative integers. All standard loopholes are forbidden.
This is code-golf so the shortest code in bytes wins!

Test Cases

Input --> Output

[1, 2, 3, 4, 5] --> [1, 3, 4]

[6, 1, 0, 5, 6] --> [6, 1, 0, 5, 6]

[1, 3, 2, 4, 11, 5, 2, 0, 13, 10, 1] --> [1, 2, 11, 5, 2, 0, 13, 10, 1]

[2, 2, 2, 2, 2, 2] --> [2, 2]

[1, 2, 3, 1, 2, 3, 1, 2, 3] -> [1, 2]

[3, 1, 2, 4, 0] --> []*

* The last test case involves 0, so I decided to post the process such that it is clearer:
[3, 1, 2, 4, 0] --> [3, 1, 2, 0] --> [1, 2, 0] --> [1, 0] --> [0] --> [] )

(Inspired by this challenge by Erik the Outgolfer)

I have written all the test cases completely by hand, please notify me if you think there is a mistake!

Why is 2 removed in the first step instead of 3?

@LeakyNun My mistake. Correcting. Ping me if I made any other mistakes

suggested test case : [1, 2, 3, 1, 2, 3, 1, 2, 3]

@Rod Added. Thanks for the suggestion.

So to clarify, when you move to your new "n", you always start from the beginning of the array to keep n elements? Not (as I thought at first glance) keep n elements where the first element is the n you are evaluating?

@BrianJ Yes, you always remove the element from the beginning.

Are you downgoats sock?

@Christopher2EZ4RTZ No, that's Evil Sheep. :P (Or TF2Goat)

Pyth, 18 bytes
#IgZlQB .(Q=Z@QZ)Q

Try it here.

Nope.

@LeakyNun And I thought I tested it enough! darn

At least check the given testcases.

@LeakyNun sometimes I think code is giving me different results than what it actually does though...fixing...fixed (oh and btw I'm a bit lazy to remove the formatting off the test cases tbf)

JavaScript (ES6), 45 bytes
f=(a,k=0,x=a[k])=>1/x?f(a.splice(x,1)&&a,x):a

Test cases

f=(a,k=0,x=a[k])=>1/x?f(a.splice(x,1)&&a,x):a

console.log(JSON.stringify(f([1, 2, 3, 4, 5]))) // --> [1, 3, 4]
console.log(JSON.stringify(f([6, 1, 0, 5, 6]))) // --> [6, 1, 0, 5, 6]
console.log(JSON.stringify(f([1, 3, 2, 4, 11, 5, 2, 0, 13, 10, 1]))) // --> [1, 2, 11, 5, 2, 0, 13, 10, 1]
console.log(JSON.stringify(f([2, 2, 2, 2, 2, 2]))) // --> [2, 2]
console.log(JSON.stringify(f([1, 2, 3, 1, 2, 3, 1, 2, 3]))) // -> [1, 2]
console.log(JSON.stringify(f([3, 1, 2, 4, 0]))) // --> []

Haskell, 50 bytes
g.pure.(0:) is an anonymous function taking and returning a list of Ints, use as (g.pure.(0:))[1,2,3,4,5].
g.pure.(0:)
g(a,_:b:c)=g$splitAt b$a++b:c
g(a,_)=a

Try it online!
How it works

The function g takes a tuple argument representing a split list. a is the list of initial elements kept at the previous step, _ is the element to be discarded, b is the next element to be used as a length, and c is the remaining elements.

If there are enough elements in the second part of the tuple to select a b, then a new split is performed and g recurses. Otherwise, it halts with a as the result.

The anonymous function g.pure.(0:) starts it all by calling g with the tuple ([],0:l), where l is the input and 0 gets immediately discarded by g.

pure here uses the Applicative instance for (binary) tuples, and with the result type ([Int],[Int]) conveniently puts its argument as the second element in a tuple with [] as first element.

Python 3, 59 bytes
f=lambda a,i=0:f(a[:a[i]]+a[a[i]+1:],a[i])if i<len(a)else a

Try it online!

Impressive! I had a 65-byte non-recursive approach (in Python 2).

Haskell, 51 bytes
f s=s%s
s%(n:_)|(x,_:z)<-splitAt n s=(x++z)%z
s%_=s

Try it online! Example usage: f [1,2,3,4,5].

APL (Dyalog Classic), 32 bytes
1∘{n∇⍣(n≤≢w)⊢w←⍵/⍨(n←1+⍺⊃⍵)≠⍳≢⍵}

Explanation
1∘{                             } bind 1 as starting left argument (⍺)
                             ⍳≢⍵  generate indexes for right argument (⍵)
                   (n←1+⍺⊃⍵)      n is 1+item at position ⍺
              w←⍵/⍨         ≠     w is ⍵ with item at n removed
   n∇⍣(n≤≢w)⊢                     recurse with n as left and w as right arg if n <= length of w

Try it online!

Java 8, 68 bytes
This lambda accepts a mutable List<Integer> (supports remove(int), e.g. ArrayList). Output is mutated input. Assign to Consumer<List<Integer>>.
l->{for(int i=0,f=0;i<l.size();f^=1)i=f>0?l.remove(i)*0+i:l.get(i);}

Try It Online
The control flow for this problem is very annoying. Each iteration we have to remove an element and get the element at the next position, and both of these operations require a range check (and either may trigger program completion). One strategy is to carry out both operations in a single loop iteration, with the index update guarded by its own range check. Another strategy, which turned out to be shorter, is to alternate between the operations each loop iteration, which is what this solution does.

Perl 5, 38 + 1 (-a) = 39 bytes
splice@F,$p=$F[$p],1while$p<@F;say"@F"

Try it online!

Haskell, 99 bytes (88 without indentation)
f x y
 |y>=l=f x$l-1
 |e>=l=x
 |True=f (take e x ++ drop (1+e) x) e
 where e=x!!y
       l=length x

I could probably save 1 byte using "1=1" instead of "True", also maybe the two spaces near "++" could be removed

VI, 31 25 bytes
O@0kdd<C-v><C-a>Y<C-v><C-x>gg@a<Esc>"add<C-a>Y<C-x>@a

<C-?> corresponds to Control + ?, and <Esc> to Escape obviously. Each of these count for 1 byte (see meta).
Input
The input file should contain 1 integer per line + 1 blank line at the end, example :
1
2
3
4
5

We can see each line of the input file as an array element, such as 1 :: 2 :: 3 :: 4 :: 5 :: [], like in some languages (caml for example).
Launch
You can start vi with the following command, and type the solution stroke by stroke :
vi -u NONE input

You can also use this one-liner :
vi -u NONE -c ':exec "norm O@0kdd\<C-v>\<C-a>Y\<C-v>\<C-x>gg@a\<Esc>\"add\<C-a>Y\<C-x>@a"' -c ":w output" -c ':q' input

This should produce a file output with the correct result from an input file input.
Explanations
To introduce the solution, I will first present a 19-bytes solution working only for arrays without 0. This solution uses a recursive macro, used with little modification in the final solution :
Yqa@0ddYgg@aquggY@a

Explanation of a partial solution
Y                       # yank first line (first integer + line break) to "0 register
 qa                     # start recording a macro ("a register)
   @0                   # jump n lines, where n is the content of the "0 register
     dd                 # delete the current line (n+1th line)
       Y                # yank current line (integer after the previously deleted line)
        gg              # go back to the first line
          @a            # recurse on macro "a"
            q           # finish recording the macro
             u          # cancel modifications done by the execution of the macro
              gg        # go back to the first line
                Y@a     # apply the recorded macro with first parameter equal to the first integer

The trick here is to use the "0 register to store the current integer (and the line break, very important). Therefore, the command @0 allows to jump n lines (call n the value of "0). If the jump exceeds the number of lines in the file, the macro will fail, so the program will stop (outside of the array bounds, as required).
But this solution does not work if the input contains 0. Indeed, if "0 register value equals 0, then @0 will jump one line (due to the line break), not 0 as we liked. So the next command (dd) won't delete the 0th integer, but the 1st (not correct).
A valid solution to handle the 0 is to always increment the integer before yanking it, and decrement it just after. Thus, the @0 command will jump n+1 lines (n is the current integer that have been incremented). A k command is then necessary to go to line n (previous line). Using this trick, a blank line is needed at the end of the input file, to avoid jumping outside of the array (thus, terminating the program), since we now always jump n+1 lines, before jumping to the previous line.
Explanation of the final solution
O                                                       # insert a new line at the beginning of the file, enter insert mode to write the macro content
 @0                                                     # jump n lines
   k                                                    # go to the previous line
    dd                                                  # delete this line
      <C-v><C-a>                                        # type Control+A (C-v is needed because we are in insert mode) to increment the current integer
                Y                                       # yank the incremented integer
                 <C-v><C-x>                             # decrement the current integer
                           gg                           # go to the first line
                             @a                         # recurse on macro "a"
                               <Esc>                    # exit insert mode : at this step, the first line of the file contains the macro content @0kdd^AY^Xgg@a
                                    "add                # copy @0kdd^AY^Xgg@a line to the register "a and delete the line
                                        <C-a>           # increment the first integer
                                             Y          # yank it (into "0)
                                              <C-x>     # decrement the first integer
                                                   @a   # apply macro in a" (initial @0 will jump n+1 lines, since we incremented the first integer before calling the macro)

Writing the macro content inside the file before registering it allows to save a few bytes :

avoids to write qa...q and undo all changes after registering
avoids :let @a="...")

Edits
#1

write the macro content on the first line (instead of last line)
change input (1 blank line at the end)
add one-liner to test in command-line

Pyth, 32 bytes
VlQIgNlQBK@QNI!K=QYBIgKlQB.(QK;Q

Try it online

Pyth can be much more elegant than that :) #VlQ.(Q@QN;Q does the job in 12 bytes, and I'm pretty sure it can be golfed even more

By keeping the old-school Pythonic approach you can do W<Zl=Q+<Q@QZ>Qh@QZ=Z@QZ)Q (25). pizzakingme's approach is much better though.

My solution still fails for cases that reduce to [0], it needs to be fixed up a bit  before posting

Sorry, I'm still learning Pyth

@KaranElangovan nothing to apologize for, they're just trying to help you.

Fixed for the final test case, it comes out to 15 bytes: #VlQ .(Q@QN)%;Q. Feedback from Pyth golfers would be welcome, I'm still learning too!

Oooh, the 15 byte one is broken too, because @ wraps around the array.

This approach is invalid. Not only it doesn't print the result only, bur it also fails the test cases (the second last one at least). Can you please delete this answer / fix it?

C# (.NET Core), 74 bytes
n=>{for(int i=n[0];i<n.Count;){n.RemoveAt(i);i=i<n.Count?n[i]:n.Count+1;}}

Try it online!
This takes in a list of ints and modifies it. I have seen some Java answers that skirt around imports by using the fully qualified name in the Lambda argument definition. If this is not allowed, I can remove this answer.

If you're referring to the omission of parameter types in lambda definitions, that's allowed.

@Jakob I understand that. I just feel a little dirty for the System.Collections.Generic.List<int> instead of using System.Collections.Generic and adding that to the byte count. But I guess it isn't any different than using an array.

Oh, I see. Well you could use using if you want; as long as the lambda itself doesn't rely on the statement you wouldn't have to include it in the byte count. Personally I always use fully-qualified names in test code just so that it's clear and easily verifiable what imports the lambda uses.

R, 64 53 bytes
f=function(a,i=1,d=a[i]+1)"if"(is.na(d),a,f(a[-d],d))

Recursive function. Has one mandatory input, a, the list to skip over. i is the index of the number of things to jump over (defaults to 1), and d is the index of the next item after the required value has been removed, which is also the index of the item to be removed. Returns numeric(0), an empty vector, for empty output.
Try it online!
Ungolfed:
f <- function(a, i = 1, d = a[i] + 1) {
  if(is.na(d)) {   # d is NA if and only if a[i] is out of bounds
    a
  } else {
    f( a[-d], d, a[d] + 1 )   # a[-d] is a with the item at index d removed
  }
}


text:
Generate programs that print n times their length
Given a nonnegative integer n, your solution must output a program in your chosen language whose output has n times as many bytes as the outputted program.
Rules

You must specify the language and encoding of the programs your solution outputs, and you may not choose different languages or encodings for different inputs to your solution. The language of your output program may or may not be the same as the language of your solution.
Your submission only needs to handle integers in your language's range, but please do not abuse this rule.

This is code-golf so the shortest submission in bytes wins.
Example
Suppose n is 4. My solution then outputs f_8, a program which, in my (imaginary) language outputs j3 1s+/2]!mz. The program output has length 3 and its output has length 3 * 4 = 12, so the solution is correct for input 4.
Suppose instead that n is 1 and my program outputs ffffpfpffp (10 bytes). The program ffffpfpffp in my chosen language would have to produce an output of 10 * 1 = 10 bytes.

At the moment, this is pretty underspecified. Could you provide some examples?

I think I know what we're supposed to do, but every time I read the spec, I become less certain. output some text that has n times as many bytes as the outputted program seems to imply that we have to output a text and a program. The character set and the language must be consistent for all integers. Which "character set" is this referring to?

Nevermind, I actually did misunderstand, and so did all but one of the answers.

@Dennis It doesn't help that the title seems to contradict the body. Perhaps Output a program that outputs n times its length would be a better title, if I understand the challenge correctly (I'm not sure I do)

"A program in your chosen language whose output has n times as many bytes as the outputted program". On what input? I would guess given no input, but that should be explicit.

Can I use HQ9+ as the output language? (I think consensus allows that now) if so then a 3-byte solution would be trivial.

What happens if the two languages use different code pages?

Can we take n as a string?

JavaScript (ES6), 38 bytes
n=>`(x="${n}")=>(x+1/7+1e9).repeat(x)`

Demo

let f =

n=>`(x="${n}")=>(x+1/7+1e9).repeat(x)`

function update() {
  let n = I.value,
      func = f(n),
      res = eval(func)();
  O.innerText =
    'n = ' + n + '\n\n' +
    'Function (' + func.length + ' bytes):\n' + func + '\n\n' +
    'Function output (' + res.length + ' bytes):\n' + res;
}
update()
<input type=range id=I min=0 max=100 oninput="update()">

Jelly, 10 bytes
;“DL+8×x@⁶

Try it online!
For input 12, it outputs 12DL+8×x@⁶, which outputs 120 spaces. Try it online!

brainfuck, 348 bytes
--[>+<++++++]>>--[>+<++++++]>++[-<+>]----[>+<----]>---[-<+>]----[>+<----]>-[-<+>]-[>+<---]>++++++[-<+>]-[>+<---]>++++++++[-<+>]--[>+<++++++]>+++[-<+>]<[<],[->.<]>>>>>.<<<.>>.<<<.>>>.<<<.>>>.<<<.>>...>>>.<<....<<.>>>.<<..<<.>>>..<<.......>>>>.<<<..<<.>.....>>>.<<.>>.>>.<<<<<.>>>>.<<.<<.>>.>.<<<.>>.<<<.>>...<<.>>>..>>.<<.>.<<<.>.<<.>>>.>>.<<<..>>>.

Try it online! Or see the Ungolfed version (i.e. what I had to work with)

Disclaimer
I spent more time making this than I thought was humanly possible. I'd like to thank my girlfriend for allowing me to ditch her to work on this; as well as my savior.
How does it even work?
No clue.
How does it work?
All outputs have a trailing snippet of code that are all the same:
[->+>+>+<<<]>>>>-[<<+>>-------]<<+-----[<[.-]>->[->+<<<+>>]>[-<+>]<<]

Let's split it into three parts called a,b,c
a : [->+>+>+<<<]>>>>               THE DUPLICATOR
b : -[<<+>>-------]<<+-----        THE ADJUSTER
c : [<[.-]>->[->+<<<+>>]>[-<+>]<<] THE PRINTER

The input i is simply tacked on to the front in unary:
iabc

(e.g; if the input was 10, then i = '++++++++++')
The Duplicator
 - Splits the input into two identical numbers m, n, equivalent to the input
The Adjuster
 - Adjusts n such that it equals the length of the program
The Printer
 - Prints m*n ASCII characters

Note that the input in the example is a newline, which as an ASCII value of 10, therefore the input is 10. If you want to test other small numbers, replace the , with however many +'s you desire.

Cheddar, 10 9 bytes
(*)&" "*9

An awkward Proton polyglot >_<

+1 for Proton polyglot with Cheddar to show the inspiration :D

Haskell, 55 bytes
f n=(++)<*>show$"main=putStr$[1.."++show n++"*2]>>'#':"

Try it online! Example usage: f 1 yields the following 54 bytes program:
main=putStr$[1..1*2]>>'#':"main=putStr$[1..1*2]>>'#':"

Try it online!
 which produces the following 54 byte output:
#main=putStr$[1..1*2]>>'#':#main=putStr$[1..1*2]>>'#':

Python 3 -> HQ9+, 11 bytes
'Q'.__mul__

It had to be done
Try it online!

Where can I test HQ?

Well, Q just prints its own source code. You can test that here: http://hq9plus.alwaysdata.net. This was never supposed to be a serious entry

This doesn't work. If I input 1, then you output Q, which in turn outputs Q. Q has length 1, but your code has length 11.

@NoOneIsHere 'whose output has n times as many bytes as the outputted program.' (not the submitted program)

@michi7x7 Ok, but the interpreter you linked outputs (for QQ) QQ\nQQ, which is 5 bytes, not 4.

@NoOneIsHere this does not: https://almnet.de/esolang/hq9plus.php (The language specification only states "Prints the entire text of the source code file")

Java 8, 175 174 bytes
interface M{static void main(String[]a){System.out.printf("interface M{static void main(String[]a){int i=(88+%s)*%s;for(;i-->0;System.out.print(0));}}",a[0].length(),a[0]);}}

Examples:
n=1 outputs:
interface M{static void main(String[]a){int i=(88+1)*1;for(;i-->0;System.out.print(0));}}

(length=89) which outputs 89 zeroes:
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

n=10 outputs:
interface M{static void main(String[]a){int i=(88+2)*10;for(;i-->0;System.out.print(0));}}

(length=90) which outputs 900 zeroes:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

n=100 outputs:
interface M{static void main(String[]a){int i=(88+3)*100;for(;i-->0;System.out.print(0));}}

(length=91) which outputs 9100 zeroes:
[encoded data, 9100 characters]

Explanation:
interface M{                                // Class:
  static void main(String[]a){              //  Mandatory main method
    System.out.printf("interface M{static void main(String[]a){
                                            //   Print a new program with:
      int i=(88+%s)*%s;                     //    Integer containing (88*A)+B
      for(;i-->0;System.out.print(0));}}",  //    And print that many zeroes
        a[0].length(),                      //     Where A is the length of the number
                                            //     (0-9 = 1; 10-99 = 2; 100-999 = 3; etc.)
        a[0]);}}                            //     and B is the number itself

RProgN 2, 7 5 bytes
«•.*

With a trailing space
Explained
«•.*
«    # Yield a function from the remaining string.
 •.  # Append a space and stringify, which builds the original program (Because stringifying a function removes noops, which spaces are)
   * # Repeat the implicit input times.

Try it online!

CJam, 8 13 bytes
q_,S\" 8+*S*"

Try it Online
The generated program outputs spaces so it's kind of hard to tell.

I think this is the only answer that interprets the part about outputting a program that outputs a text correctly, but the ratio is off if the input has more than one digit.

Oh yeah, duh.,,

Ly, 29 bytes
"\"9>("&onu")[<&s&ol>1-]<;"&o

Try it online! (does not work currently due to a pre-processing bug) All good!

Python → TECO, 20 bytes
The answer is in Python while the generated code is in TECO. The Python is a function returning VV12345\VV repeated n times. See here for an explanation of the TECO.
'VV12345\VV'.__mul__

PHP, 47+1 bytes
<?="<?=str_pad(_,",strlen($argn)+18,"*$argn);";

prints one underscore followed by spaces.
Run as pipe with -F; run outputted program with -f or -F.
This would fail for input with more than 64 digits,
which is far higher than PHP_INT_MAX (at this time).
However, it fails for input larger than PHP_INT_MAX-18 ... does it still qualify?

@HyperNeutrino: This will fail for input larger than PHP_INT_MAX-18. Does that disqualify?

Nah, I'll say that's fine :)

PHP → Python 2, 40+1 bytes
print "A"*<?=13+strlen($argn),"*",$argn;

prints a Python program that prints repeated As. Run as pipe with -F.

Batch → Charcoal, 22 bytes
I'm not sure which encoding I should be using, since these are bytes. Here are the bytes interpreted as Windows-1252:
@set/p=Á%1ñªÉñ«Ìñ¹<nul

The same bytes as PC-850:
@set/p=┴%1±¬╔±½╠±╣<nul

The same bytes in Charcoal's code page:
@set/p=Ａ%1θ×Ｉθ⁺Ｌθ⁹<nul

The resulting Charcoal program is Plus(Length(Cast(n)), 9) bytes long:
Ａ       Assign
 %1      (String representation of n)
   θ      To variable q
        Implicitly print a number of `-`s equal to:
×        Product of:
 Ｉθ       Cast of q to integer
 ⁺        Sum of:
  Ｌθ       Length of q
  ⁹        Integer constant 9

JavaScript (ES8), 43 41 39 bytes
n=>`f=_=>"".padEnd(${n}*(88+f).length)`

Test it
The output of the generated function is a string of spaces which are replaced with *s in this Snippet.

g=
n=>`f=_=>"".padEnd(${n}*(88+f).length)`

o.innerText=(h=n=>`Function: ${x=g(n)}\nLength:   ${x.length}\nOutput:   "${x=eval(x)().replace(/./g,"*")}"\nLength:   `+x.length)(i.value=10);oninput=_=>o.innerText=h(+i.value)
<input id=i type=number>

Recursiva, 16 15 bytes
++"*"V*15a'"*"'

Try it online!
This for input of n=2 prints:
*30"*"

which outputs 30 *.
Try it online!

R, 46 bytes
function(n)sprintf("cat(rep('a',%d*23),'')",n)

Try it online!
Anonymous function that returns the string
cat(rep('a',n*23),'')

Which prints a (that's a followed by a space) 23 times n times. I needed the '' because otherwise cat wouldn't print the last space character.

C, 94 bytes
main(int c,char**a){if(c>1){c=atoi(a[1]);if(c>0&&c<0xFFFFFF){c*=94;while(c--)printf("r");}}}

this would be 94 bytes include the last \n that stadard C says it should be written.
return as 'r' characters as the (lenght of the program) * (argument of the program)
if the program argument not exist or it is <=0 or it is >0xFFFFF print nothing
example
C:\>nameProg.exe 1
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

MATLAB (63 bytes)
a=@(n)['repmat(''a'',1,',num2str(n*(15+numel(num2str(n)))),')']

For example:
>> a(5)

ans =

repmat('a',1,80)

and:
>> repmat('a',1,80)

ans =

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa