text:
Create the shortest BitShift
Introduction
BitShift is an esolang, created by me, to output strings. Sounds boring, is boring. However, the only instructions available to BitShift are 0 and 1. Therefore it can be challenging to golf in it. To make matters even more interesting, the language only supports 4 bitshifting instructions, a clear, a print and an input instruction.
How it works
BitShift is written by alternating 0 and 1 characters. Once the interpreter finds 2 of the same characters in a row, it will perform an instruction based on the amount of non-alternating characters preceding it.
010010110001010 will perform the operations 3 4 2 1 5
010 0101 10 0 01010 here, the non-alternating characters are seperated by a spacebar for readability.
The interpreter can be found here
Operations
All operations are performed on one single value. BitShift does not know of a stack.
BitShift programs initially start with a value of 0. This value can range from 0-255 and overflows at -1 and 256
1   Shift the value 1 bit to the left (0000 0001 > 0000 0010)
2   Shift the value 1 bit to the right (0000 0010 > 0000 0001)
3   XOR the value with 1 (0000 0000 > 0000 0001)
4   XOR the value with 128 (0000 0000 > 1000 0000)
5   Set the value to 0
6   Convert the value to a character and print it
7   Read a character from user input and set the value to it

Challenge
Your task is to create a program which can convert an input string to the shortest possible BitShift program which will output that string when run.
Rules

You are not allowed to use the 7 operation
Your program takes only one input argument, which is the string to convert
Your program will output the translated BitShift program to STDOUT
You can use any kind of built-in function in your preffered language
You can use any kind of language, as long as it's created before this date

Scoring
This is a metagolf.
The person who can create the shortest BitShift program will win this challenge. In case of a tie, the lowest byte count will win.
The input string (ISO 8859-1) you should base your answer on is:
This is a string, meant to test the effectiveness of your program. Here are some special characters to make matters interesting: Æ Ø ß. How meta! :D
The special characters used are Æ Ø ß
Please post the output of your program in your answer, so that it can be tested for validation.

The following is an example solution. Obviously, this is a terrible solution.
Javascript, 594 bytes, 4275 characters
var flag = true;
var input = prompt();
var output = ""
for (n in input) {
    var c = input.charCodeAt(n).toString(2);
    while (c.length < 8) {
        c = "0" + c;
    }
    for (var i = 0; i < 8; i++) {
        if (c[i] == "1") {
            output += flag ? "010" : "101";
        }
        if (i < 7) output += flag ? "0" : "1";
    }
    for (var z = 0; z < 6; z++) {
        output += flag ? "0" : "1";
        flag = !flag;
    }
    flag = !flag;
    for (var z = 0; z < 5; z++) {
        output += flag ? "0": "1";
        flag = !flag;
    }
    flag = !flag;
}
console.log(output);

Pretty clear, but one problem: 1. This challenge is wide open to "volkswagening". As written, I understand the program is required to work with any input. Is it acceptable to hardcode for the specific input string in the Scoring section? If not, you should provide more examples, but that may complicate the scoring.

What UTF encoding is required for those non-ascii symbols? it would also be helpful if you included the codepoints in your post.

Re steve's first point, I recently posed a similar challenge. Feel free to take some inspiration from the scoring section there.

It is allowed to hardcode the input string, but that will most likely just increase the byte count of your program. Because it indeed needs to work for any input. All input characters should be one byte long (0-255), i'm not a hero with encodings but i believe that's utf-8?

@steveverrill What is volkswagening? Google turns up empty.

@MarioCarneiro volkswagening is a term I have coined to describe programming to optimize performance in one specific test case, without any regard for normal use. Which is exactly what Volkswagen did with their engine management software. If you've missed all the news, here it is: https://en.wikipedia.org/wiki/Volkswagen_emissions_scandal

@MarioCarneiro it seems I am not the only one who has though of this. The third hit I get on google is Samsung-is-accused-of-volkswagening-its-tvs-to-oversell-their-energy-efficiency.

Non-ASCII characters such as the ones in your string are not one byte in UTF-8.

Maybe I'm just reading it wrong, but this part of the description sounds unclear to me: "based on the amount of non-alternating characters preceding it". The rest of the explanation makes it sound like non-alternating characters separate the tokens, and then the count of alternating characters determines which instruction is encoded by the token.

It's worth noting that all 3 of the non-ASCII characters in the example text are present in ISO-8859-1. I propose that this be used as the encoding for the output.

Is the bitshift cyclic (e.g. 00000011>10000001), or if not, will the border bits be filled with ones or zeros?

@flawr It's not cyclic. Borders are filled with zeroes.

@Mego (and others) I believed these were regular ASCII characters. Found them on this page.

@RetoKoradi You are right, English isn't my mother tongue

@Bas ASCII technically covers only 128 letters (it's actually a 7-bit encoding). Everything beyond the first 128 characters is called "extended ASCII". There are many different encodings for those, the simplest (when you're sticking to code points below 256) would be ISO 8859-1 (or Latin-1) which I think you've used here.

@MartinBüttner You are right, this is Latin-1. Thanks for the explanation!

Mathematica, 343 bytes, 2573 characters
B=BitXor;t[a_]:={Mod[2a,256],⌊a/2⌋,a~B~1,a~B~128,0};w[a_,b_]:=Position[t@a,b][[1,1]];f=FindShortestPath[Graph[0~Range~255,e=Join@@Table[a#&/@({}⋃t@a),{a,m=c=0,255}],EdgeWeight(w@@#&/@e)],All,All];o="";u[a_,b_]:=(Do[o=o<>ToString[m=1-m],{If[a==b,6,a~w~f[a,b][[2]]]}];m=1-m);While[c~u~y;c!=y,c=f[c,y][[2]]]~Do~{y,ToCharacterCode@i};o

This is my first code competition. This program should generate the shortest possible program for any string. It effectively calculates a lookup table given the current state of the accumulator and the goal byte to find the shortest sequence of the five operations to get from any one to another, carrying the accumulator over characters and taking advantage of the size difference between instructions. Uses Mathematica 8's Graph infrastructure for calculating shortest paths (alternatives being to roll one's own or just embed the 256 x 256 table of instructions).
Ungolfed version (the first i = "..." line is also present, but not counted in the golfed version since it is the input):
i = "This is a string, meant to test the effectiveness of your program. Here are some special characters to make matters interesting: Æ Ø ß. How meta! :D";
B = BitXor;
t[a_] := {Mod[2 a, 256], Quotient[a, 2], B[a, 1], B[a, 128], 0}
w[a_, b_] := Position[t[a], b][[1, 1]]
g = Graph[Range[0, 255],
  e = Join @@ Table[DirectedEdge[a, #] & /@ Union@t@a, {a, 0, 255}],
  EdgeWeight -> (w @@ # & /@ e)];
f = FindShortestPath[g, All, All]; c = m = 0; o = "";
u[a_, b_] := (Do[
   o = o <> ToString[m = 1 - m], {If[a == b, 6, w[a, f[a, b][[2]]]]}];
   m = 1 - m);
Do[While[u[c, y]; c != y, c = f[c, y][[2]]], {y, ToCharacterCode[i]}];
o

Output:
10111101111011110101000010110010101101101010000010110010110010010101101111110101001011001011001001010111110100110100110110101001000000101011101001101101010000000101011011101110111110111011010100110010000101011001101110111010100100001000001001010110011011101110101000010001000011011010100110100110010101111111001101010010001000010001000010010101101110111101101010011001000010010101100110010001000100010101110111101010000001101010010110010110010110010101100100010000110110101000000000110010101101001101001101001101010001000001011001001010110100110110101001100100001010111111001010110100110100110100110101000011010100100000101100100101011011111010100110100110100110110101001101110101001010110010001001010111011111101110110101000100001000010101111001001010110100110010001010111101111011010100010001000010110010101111011111001001010110100110110101001010110111111010100100010000100010001000100101011111011101111001010110010000001010110111011101110111110110101001101001101001101010010001000010010101100110111011101010000001010111010011010011010100110111010100110100110100110110101000001000100001101101010000010001010110111111101101010011010011010011011010100110111110011010100000000110010101100101100101011010011011010100101100101011110010010101101111101010001011001001010110100110010001010111100100101011011111010100100010001000001000100101011001011001011001001010110010001001010110111011110110101001000001010110111011101111101110110101001101110101001101111100100101011101111110111011010100001000001001010111011111110110101001101001101001101010000000110010101100100001011001001010111101111101010000010110010010101101001100100010101101111111011010100110111011010100010000100001010111011111010011011010100101100101011011010100100000010101101001101001101001101010011011101111001001010111111111001101010010001000010001000010010101101111101101010011001101111011101101010000010000100101011011111010100100010000100010000100101011011111011010100101100110010000101011010100010000010110010010101101001101010010010101101111110101001011001011001001010110011011101110101000100001010111011111010011011010100101100101011110010010101101001101101010011001000010101111001001010110011011101110101000010001000011011010100001000101011111110010101100100010001011010100110111111010100010110011010011010010101111110011010100100001000100010001000100101101010001100100101011111111001101010011010011010100110111011101111010011011010100101100101011111111100110101001000100001000100001001010110111011110110101001011001100100001010111111010011011010100001100101011011010100100010001000010001010111110111101010

Well done! I was just planning to do this, but you have already done it :)

D, 472 bytes, 4275 characters
import std.stdio;import std.conv;import std.file;import std.format;import core.stdc.stdio;void main(char[][]a){bool f=true;char[] o;int i;char[64000]b;size_t j;FILE* g=core.stdc.stdio.fopen("i", "r");j=fread(cast(void*)b, 1, 64000, g);foreach(dchar n;b[0..j]){string c=format("%b",n);while(c.length<8)c='0'~c;for(i=0;i<8;i++){if(c[i]=='1')o~=f?"010":"101";if(i<7)o~=f?'0':'1';}for(i=0;i<6;i++){o~=f?'0':'1';f=!f;}f=!f;for(i=0;i<5;i++){o~=f?'0':'1';f=!f;}f=!f;}writeln(o);}

Loads input from a file called i in the same directory as the program. Tons of bytes waisted on the UTF input.
Output:
[encoded data, 4275 characters]


text:
Back to the chemistry class
Introduction
One of the first things I learned in chemistry, was giving the formula for the combustion of alkanes. The most basic example was: 2CH4 + 4O2 -> 4H2O + 2CO2. Note that the equation could have been simplified by dividing every coefficient by 2, we would get CH4 + 2O2 -> 2H2O + CO2. To make things easier, we are going to ignore this to not complicate things.
You can see that with the combustion of any alkane, oxygen is used. After the reaction, only CO2 and H2O are made.
The task
The input will always be in the form C(n)H(2n+2), with n>0. These are some example inputs:
CH4
C2H6
C3H8
C4H10
C5H12
C6H14

Useful tip:
Every alkane has a standard pattern in the combustion reaction:
2C(n)H(2n+2) + (3n+1)O2 -> (2n+2)H2O + (2n)CO2

e.g.
C4H10 gives the following equation: 2C(4)H(2*4+2) + (3*4+1)O2 -> (2*4+2)H2O + (2*4)CO2. After calculating everything, we get this final equation 2C4H10 + 13O2 -> 10H2O + 8CO2
Testcases
CH4
2CH4 + 4O2 -> 4H2O + 2CO2

C3H8
2C3H8 + 10O2 -> 8H2O + 6CO2

C4H10
2C4H10 + 13O2 -> 10H2O + 8CO2

C12H26
2C12H26 + 37O2 -> 26H2O + 24CO2

Rules

Note that I used spaces for the examples to increase readability, these are not necessary. 2CH4 + 4O2 -> 4H2O + 2CO2 and 2CH4+4O2->4H2O+2CO2 are both valid outputs. However, if you consistently use spaces for the output, you get a -10% bonus
This is code-golf, so the program with the least amount of bytes wins!

totally different but related: Drawing Lewis Structures of Alkanes

So we can assume that the input will be correct formulas?

@TanMath, yes, you don't have to worry about invalid formulas

"consistently use spaces" - would consistently using 0 spaces count?

@Mego, no. Using 0 spaces is not using spaces at all, so the rule doesn't apply

Is C1H4 valid? Or it has to be CH4?

@Zereges, it has to be CH4

I'm disappointed at the lack of Unicode subscripts.

Is a newline character required at the end of the output?

@TomCarpenter no, that is not required

Pyth, 40 bytes
s[2z\+h*3Jv|hctz\H\1"O2>"yhJ"H2O+"yJ"CO2

Try it online. Test suite.

Python 3, 86 * 0.9 = 77.4 bytes
s=input()
N=int(s.split('H')[1])
print("2%s + %dO2 > %dH20 + %dCO2"%(s,N*1.5-2,N,N-2))

Try it online!
Extracts the number of H's rather than the number of C's from the input. This avoid special-casing CH4 and simplifies the output expressions in terms of N=2n+2.
The output has parameters plugged in via string formatting. The first summand is just the input string, and the rest have calculated numbers plugged in. Note that N*1.5-2 (same as N*3/2-2) gives a float, but the string formatting converts it to an int.

Java, 202 * 0.9 = 181.8 bytes
Sometimes, I wonder if I'm just hurting myself with Java.
Thanks to @TNT and @TFeld for shaving off a good 20 bytes!
class A{public static void main(String[]a){String s=a[0].substring(1,a[0].indexOf("H"));long n=Long.parseLong((s.length()>0)?s:"1");System.out.printf("2%s + %dO2 > %dH2O + %dCO2",a[0],3*n+1,2*n+2,2*n);}}

Pretty simple. Basically, I cut the input from C to H, and get that substring. If it's nothing, I set n to one. Otherwise, I set it to the number between C and H. The code following just prints it out and puts it into proper notation.
Ungolfed
class A{
    public static void main(String[]a) {
         String s=a[0].substring(1,a[0].indexOf("H"));
         long n=Long.parseLong((s.length()>0)?s:"1");
         System.out.printf("2%s + %dO2 > %dH2O + %dCO2",a[0],3*n+1,2*n+2,2*n);
    }
}

Good answer, but you must use STDIN and not command line args. Though you could shorten it by using printf instead of + (-11 from your raw score if I counted correctly).

I've been told that using command line arguments is an acceptable alternative to STDIN. Also, could you clarify how you mean for me to use printf? (A little finicky on that, haven't used it before. :D)

printf uses mechanics from java.util.Formatter. You can have a string to print such as "%d" in your print statement and after it some value or variable that will be printed instead. It can be useful in situations where you have a lot of variables to print, for example.

And the fact that command line arguments is acceptable in place of STDIN is new (and rather helpful) news to me. :)

@TNT I've also been told that it depends on the situation as well. But, yes, it is defaultly permitted. I'm in the midst of a debate currently on whether or not it is accepted for this question specifically.

@TNT I honestly still have no idea how to use printf. Can you help me with it, please?

Using printf:
System.out.printf("2%s + %d2 > %d2O + %dO2",a[0],3*n+1,2*n+2,2*n);

@TFeld Doesn't quite work - I'll use something similar, thanks. I get it now. :D

Yeah, I'm not sure what happened when i copied it... It seems the first letter is missing from each 'group'
Correctly should be: System.out.printf("2%s + %dO2 > %dH2O + %dCO2",a[0],3*n+1,2*n+2,2*n);

@TFeld Yup, that's what I derived from it - thank you so much!

Glad you got it to work! By the way, I posted the wrong example link; I meant to post this one. :P

@VoteToClose Yes, you are hurting yourself with Java.

Python 2, 122 91 * 0.9 = 81.9 bytes
i=input()
n=2*int(i[1:i.find('H')]or 1)
print'2%s + %dO2 > %dH2O + %dCO2'%(i,n*3/2+1,n+2,n)

Try it online!

JavaScript ES6, 63 * 0.9 = 56.7 bytes
_=>`2${_} + ${$=_.split`H`[1],$*1.5-2}O2 > ${$}H2O + ${$-2}CO2`

Similar to my ESMin answer

Pyth, 53*0.9 = 48 bytes
Previous byte count:

69 * 0.9 = 62

63 * 0.9 = 57

56 * 0.9 = 50

Js>z+xz\H1s[\2z%" + %dO2 > %dH2O + %dCO2"[-*1.5J2J-J2

It is just like xnor's answer, where I use the H values. A variable J is used to store the amount of H's in the molecular formula of the molecule.
Try it here

You spend six bytes on spacing, but gain only five bytes from the bonus, so it's not worth it.

Perl, (84 + 1) * 0.9 = 76.5
(+1 char for running with the -n flag)
My first Perl golf!
@x=(1,m/C(\d)/g);$n=$x[$#x];say"2$_ + ".(3*$n+1)."O2 > ".(($n*=2)+2)."H20 + ${n}CO2"

It's important that STDIN not contain a trailing newline. Example usage:
llama@llama:...code/perl/ppcg64412chemistry$ printf CH4 | perl -n chemistry.pl
2CH4 + 4O2 > 4H20 + 2CO2

Ungolfed-ish:
#!/usr/bin/perl
use 5.10.0;

$_ = 'C3H8';
my @x = (1, m/C(\d)/g);
my $n = $x[$#x];
say "2$_ + ".(3*$n+1)."O2 > ".(($n*=2)+2)."H20 + ${n}CO2";

The lines
my @x = (1, m/C(\d)/g);
my $n = $x[$#x];

are fairly interesting here. $#x represents the "last populated index" of @x (and SE's syntax highlighting thinks it's a comment because it's dumb), so $x[$#x] will select the captured part of the C(\d) regex if it exists, or 1 otherwise. (Perl doesn't care that it'll be a string in all other cases except 1; you can use numerical operators on strings just fine in Perl.)

, 64 * 0.9 = 57.6 bytes
a=ïČ`H”[1],`2⦃ï} + ⦃a*1.5-2}O2 > ⦃a}H2O + ⦃a-2}CO2`

Try it here (Firefox only)
Explanation
a=ïČ`H”[1],      // split input along H to get 2n+2
`  2⦃ï}          // 2C(n)H(2n+2) – this is the same as 2[input alkane's formula]
   + ⦃a*1.5-2}O2 // + 2(3n+1)O2
   > ⦃a}H2O      // > (2n+2)H2O
   + ⦃a-2}CO2    // + (2n)O2
`                // implicitly output the template string above

Python, 148 * 0.9 = 133 bytes
Prev byte counts

0.9*195 = 175
0.9*190 = 171

i=raw_input()
O=3*int(i[1:i.find('H')]or 1)+1;C=2*int(i[1:i.find('H')]or 1);print"2"+i+" + "+`O`+"O2"+" > "+i[i.find('H')+1:]+"H2O"+ " + "+`C`+"CO2"

Try it online!

You don't need a space between print and a " character, and the CO2 variable could be named something shorter :)

@undergroundmonorail thanks

Since i[1] is guaranteed to be either "H" or a digit, you can save another byte with if i[1]>"9" (or replace "9" with any other character with an ascii value from 58 to 71)

Javascript ES6, 96*0.9 = 86.4
f=s=>`2C${(n=(s.match(/\d+(?!.*\d)/)[0]-2))>2?n/2:''}H${n+2} + ${1.5*n+1}O2 > ${n+2}H2O + ${n}CO2`

CJam, 45 44 bytes
2r_'H/1=[i_((_2/1$+)@@]"+%dO2>%dH2O+%dCO2"e%

Try it online
To avoid special casing CH4, I don't use the first number at all, and only extract the number after the H. This gives the value of 2n+2. The remaining values are then calculated based on that, and formatted.
Explanation:
2       Push leading 2 for output.
r       Get input.
_'H/    Copy and split at 'H.
1=      Take second part after split, this is 2n+2.
[       Start list.
  i       Convert string value to integer.
  _((     Copy and decrement twice, giving 2n.
  _2/     Copy and divide by 2, giving n.
  1$      Copy the 2n to the top.
  +       Add, to get 3n.
  )       Increment, giving 3n+1. We now have 2n+2, 2n, 3n+1 on stack.
  @@      Rotate top 3 entries twice, to get 3n+1, 2n+2, 2n.
]       Close list.
"+%dO2>%dH2O+%dCO2"
        Format string for output.
e%      "printf" operator.

2r_[[~]W=_2/(3*)\_2-]"+%dO2>%dH2O+%dCO2"e% saves a byte.

F# (.NET Core), 113 bytes
let s=stdin.ReadLine()
float s.[1+s.IndexOf 'H'..]|>fun f->printf"2%s + %gO2 > %gH2O + %gCO2"s<|f*1.5-2.<|f<|f-2.

Try it online!

MATLAB, 96 * 0.9 = 86.4 bytes
s=input('');i=[sscanf(s,'C%dH'),1];n=i(1);fprintf('%s + %dO2 > %dH2O + %dCO2',s,3*n+1,2*n+2,2*n)

Fairly self explanatory. Takes an input string (need to wrap it in quote marks so MATLAB doesn't try to execute it!). Then converts the number between the C and the H in the input to decimal. The value 1 is appended as an array to the output of sscanf so that in the case CH4 when we extract the first index in the array into n we get a 1 if there was no number between the C and H.
Then just prints out with the spaces following the formula in the question.
This should also work with Octave using the online interpreter here.

JS, 118 (106) bytes
x=prompt();y=x.replace("CH","C1H").match(/\d{1,}/g)[0];alert(2+x+" + "+(3*y+1)+"O2 > "+(2*y+2)+"H2O + "+(2*y)+"CO2");

C++ (clang), 160 bytes
#include<iostream>
int main(){int n=1,t;std::cin.get();std::cin>>n;t=2*n;printf("2C");n-1&&printf("%i",n);printf("H%i + %iO2 > %iH2O + %iCO2",t+2,t+n+1,t+2,t);}

Try it online!
A bit more that I expected. Reads first char and discards it, then reads int and outputs the result. Problem is with n being 1. I can't think of shorter way to output it.
Ungolfed
#include <iostream>
int main()
{
    int n = 1, t;
    std::cin.get();
    std::cin >> n;
    t = 2 * n;
    printf("2C");
    n - 1 && printf("%i", n);
    printf("H%i + %iO2 > %iH2O + %iCO2", t + 2, t + n + 1, t + 2, t);
}

Now works for CH4 152 bytes

Clojure/ClojureScript, 98*0.9 = 88.2 bytes
#(let[n(max 1(int((re-find #"C(.*)H"%)1)))m(* 2 n)](str "2"%" + "(inc(* 3 n))"O2 > "(+ 2 m)"H2O + "m"CO2"))

Creates an anonymous function.  Try it by going here and entering (def f #(let...)), then (f "C3H8").

Excel, 123 * 0.9 = 110.7 bytes
=="2"&A1&" + "&(3*MID(A1,FIND("H",A1)+1,9)/2-2)&"O2 > "&MID(A1,FIND("H",A1)+1,9)&"H2O + "&(MID(A1,FIND("H",A1)+1,9)-2)&"CO2"

If we could take CH4 input as C1H4, can be reduced to 122 * 0.9 = 109.8 bytes
="2"&A1&" + "&3*MID(A1,2,FIND("H",A1)-2)+1&"O2"&" > "&MID(A1,FIND("H",A1)+1,9)&"H2O + "&(MID(A1,FIND("H",A1)+1,9)-2)&"CO2"

Jelly, 33 bytes
ṣ”HṪVµ2³”+2⁸_©+H“O2>”⁸“H2O+”®“CO2

Try it online!
The bonus doesn't help here.

source: Stack Exchange

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

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

sort: votes


text:
Clock Hand Syzygy
(massive thanks to El'endia Starman and Sp3000 for helping me design test cases for this!)
Given a positive integer n and a list of positive integer rotational periods for a number of clock hands (in seconds), output the smallest positive integer x where x seconds after starting the clock with all of the hands aligned, exactly n of the hands are aligned. They do not have to be aligned at the starting position - any position is fine, as long as x is an integer and is minimized. In addition, not all of the hands have to be aligned at the same position - for n=4, a solution where 2 groups of 2 hands are aligned is valid. Groups must be of size 2 or greater - two unaligned hands do not constitute 2 groups of 1 aligned hand, and thus is not a valid solution.
You may assume that only inputs where it is possible to have exactly n hands aligned after an integer number of seconds will be given - 2, [3,3,3] is not a valid input, because after any number of seconds, all 3 hands will be aligned, and so it is impossible to get exactly 2 aligned.
Examples:
2, [3,4] -> 12
(the only option is a multiple of 12, so we pick 12 - 4 and 3 full rotations, respectively)

3, [3,5,6,9,29] -> 18
(picking 3, 6, and 9, the hands would align after 6, 3, and 2 rotations, respectively)

2, [1,1,4,5,10] -> 1
(picking 1 and 1 - note that 0 is not a valid answer because it is not a positive integer)

3, [2,2,6,7,11] -> 3
(picking 2, 2, and 6 - the 2s would be halfway through their second revolution, and the 6 would be halfway through its first revolution)

2, [2,7,5,3,3] -> 1
(picking 3 and 3, they are always aligned, so 1 is the minimum)

5, [4, 14, 36, 50, 63, 180, 210] -> 45
(after 45 seconds, the first, third, and sixth are aligned, as well as the second and seventh, for a total of 5)

Test Data:
7, [10, 22, 7, 6, 12, 21, 19] -> 87780
6, [25, 6, 2, 19, 11, 12] -> 62700
6, [23, 1, 8, 10, 9, 25] -> 41400
7, [6, 4, 1, 8, 10, 24, 23] -> 920
3, [18, 5, 23, 20, 21] -> 180
5, [10, 8, 14, 17, 5, 9] -> 2520
6, [1, 18, 12, 9, 8, 10, 23] -> 360
6, [12, 11, 6, 23, 25, 18, 13] -> 118404
4, [18, 11, 2, 9, 12, 8, 3] -> 8
7, [18, 25, 9, 13, 3, 5, 20] -> 11700
2, [17, 20, 15, 8, 23, 3] -> 15
3, [16, 3, 24, 13, 15, 2] -> 24
5, [7, 23, 24, 8, 21] -> 1932
6, [16, 10, 12, 24, 18, 2, 21] -> 720
6, [1, 17, 16, 13, 19, 4, 15] -> 53040
2, [3, 4, 20] -> 5
3, [9, 4, 16, 14, 1, 21] -> 16
5, [5, 17, 10, 20, 12, 11] -> 330
2, [21, 5, 22, 18] -> 90
4, [7, 25, 2, 8, 13, 24] -> 84
4, [13, 19, 2, 20, 7, 3] -> 420
5, [4, 14, 36, 50, 63, 180, 210] -> 45
5, [43, 69, 16, 7, 13, 57, 21] -> 27664
3, [22, 46, 92, 43, 89, 12] -> 276
4, [42, 3, 49, 88, 63, 81] -> 882
6, [2, 4, 7, 10, 20, 21, 52, 260] -> 65
6, [2, 3, 4, 7, 10, 20, 21, 52, 260] -> 35
2, [3, 4] -> 12
3, [3, 5, 6, 9, 29] -> 18
2, [1, 1, 4, 5, 10] -> 1
3, [2, 2, 6, 7, 11] -> 3
3, [41, 13, 31, 35, 11] -> 4433
3, [27, 15, 37, 44, 20, 38] -> 540
5, [36, 11, 14, 32, 44] -> 22176
3, [171, 1615, 3420] -> 3060
3, [46, 36, 12, 42, 28, 3, 26, 40] -> 36
5, [36, 25, 20, 49, 10, 27, 38, 42] -> 1350
4, [40, 28, 34, 36, 42, 25] -> 2142
5, [24, 26, 47, 22, 6, 17, 39, 5, 37, 32] -> 1248
4, [9, 27, 12, 6, 44, 10] -> 108

Rules:

Standard loopholes are forbidden
This is code-golf, so shortest code wins!

Leaderboard
The Stack Snippet at the bottom of this post generates the leaderboard from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:
## [><>](http://esolangs.org/wiki/Fish), 121 bytes

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

Wow, I didn't even know this is a word.  What an awesome, hangman-winning, scrabble-winning word!

@DigitalTrauma Good luck finding 3 Y tiles.

Pyth, 28 27 24 bytes
fqs-hMrS.RR7%R1cLTQ8 1vz

Try it online in the Pyth Compiler.
How it works
fqs-hMrS.RR7%R1cLTQ8 1vz

                          (implicit) Save the input number in z (as string).
                          (implicit) Save the input list in Q.

f                         Find the first positive integer T such that:
               cLTQ         Compute T/α for each α in Q.
            %R1             Get the fractional part of each result.
        .RR7                Round each fractional part to 7 decimal digits.
       S                    Sort the resulting numbers.
      r            8        Perform run-length encoding.
    hM                      Get the lengths of the runs.
   -                 1      Discard runs of length 1.
  s                         Add the remaining runs.
 q                    vz    Check is the sum matches the input number.
                          If it does, break and return T.

Test cases
$ cat input
7\n[10, 22, 7, 6, 12, 21, 19]\n87780
6\n[25, 6, 2, 19, 11, 12]\n62700
6\n[23, 1, 8, 10, 9, 25]\n41400
7\n[6, 4, 1, 8, 10, 24, 23]\n920
3\n[18, 5, 23, 20, 21]\n180
5\n[10, 8, 14, 17, 5, 9]\n2520
6\n[1, 18, 12, 9, 8, 10, 23]\n360
6\n[12, 11, 6, 23, 25, 18, 13]\n118404
4\n[18, 11, 2, 9, 12, 8, 3]\n8
7\n[18, 25, 9, 13, 3, 5, 20]\n11700
2\n[17, 20, 15, 8, 23, 3]\n15
3\n[16, 3, 24, 13, 15, 2]\n24
5\n[7, 23, 24, 8, 21]\n1932
6\n[16, 10, 12, 24, 18, 2, 21]\n720
6\n[1, 17, 16, 13, 19, 4, 15]\n53040
2\n[3, 4, 20]\n5
3\n[9, 4, 16, 14, 1, 21]\n16
5\n[5, 17, 10, 20, 12, 11]\n330
2\n[21, 5, 22, 18]\n90
4\n[7, 25, 2, 8, 13, 24]\n84
4\n[13, 19, 2, 20, 7, 3]\n420
5\n[4, 14, 36, 50, 63, 180, 210]\n45
5\n[43, 69, 16, 7, 13, 57, 21]\n27664
3\n[22, 46, 92, 43, 89, 12]\n276
4\n[42, 3, 49, 88, 63, 81]\n882
6\n[2, 4, 7, 10, 20, 21, 52, 260]\n65
6\n[2, 3, 4, 7, 10, 20, 21, 52, 260]\n35
2\n[3, 4]\n12
3\n[3, 5, 6, 9, 29]\n18
2\n[1, 1, 4, 5, 10]\n1
3\n[2, 2, 6, 7, 11]\n3
3\n[41, 13, 31, 35, 11]\n4433
3\n[27, 15, 37, 44, 20, 38]\n540
5\n[36, 11, 14, 32, 44]\n22176
3\n[171, 1615, 3420]\n3060
3\n[46, 36, 12, 42, 28, 3, 26, 40]\n36
5\n[36, 25, 20, 49, 10, 27, 38, 42]\n1350
4\n[40, 28, 34, 36, 42, 25]\n2142
5\n[24, 26, 47, 22, 6, 17, 39, 5, 37, 32]\n1248
4\n[9, 27, 12, 6, 44, 10]\n108
$ while read -r; do echo -e "$REPLY" | pyth -c 'qvwfqs-hMrS.RR7%R1cLTQ8 1vz'; done < input
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True
True

Jelly, 19 16 bytes
P:×ⱮP%PĠẈḟ1Sʋ€iƓ

Takes the array as argument, the integer from STDIN.
Way too slow and memory hungry for most of the test cases.
Try it online!
Alternate version, 14 bytes
P÷€%1ĠẈḟ1Sʋ€iƓ

This works in theory, but it may fail due to floating-point inaccuracies.
Try it online!
How it works
P:×ⱮP%PĠẈḟ1Sʋ€iƓ  Main link. Argument: A (array)

P   P P           Yield the product of A.
 :                Divide the product by each n in A.
  ×Ɱ              Multiply the quotients by each k in [1, ..., prod(A)].
     %            Take the results modulo the product.
             €    Map the link to the left over the array of remainders.
            ʋ       Combine the links to the left into a dyadic chain.
       Ġ              Group indices of identical elements.
        Ẉ             Widths; yield the lengths of the groups.
         ḟ1           Filterfalse; remove all copies of 1.
           S          Take the sum.
               Ɠ  Read an integer j from STDIN.
              i   Find the first index of j in the array of sums.

CJam, 42 34 33 bytes
0{)_eas~@d\f/1f%7fmO$e`0f=1m1b-}g

Try this fiddle or this test suite in the CJam interpreter.
How it works
0       e# Push 0 (accumulator).
{       e# Do:
  )_    e#   Increment the accumulator and push a copy.
  eas~  e#   Push the command-line args, flatten and evaluate.
        e#   This pushes a number and an array.
  @d    e#   Rotate the accumulator copy on top and cast to Double.
  \f/   e#   Divide it by each of the integers in the array.
  1f%   e#   Get the fractional part of each result.
  7fmO  e#   Round all fractional parts to seven decimal digits.
  $e`   e#   Sort and perform run-length encoding.
  0f=   e#   Select the lengths of the runs.
  X-    e#   Discard runs of length 1.
  Xb    e#   Compute the sum of the remaining runs.
  -     e#   Subtract the sum from the input number (target).
}g      e# If this pushes a non-zero value, we've missed the target;
        e# repeat the loop.

Jelly, 15 bytes
÷_:ĠẈḟ1S⁼⁴
1ç1#

Try it online!
Full program.
Suffers from floating-point inaccuracies.

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

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


text:
A Mapping of Primes
Recently, I have found a bijective mapping \$f\$ from positive integers to finite, nested sequences. The purpose of this challenge is to implement it in the language of your choice.
The Mapping
Consider a number \$n\$ with the factors \$2^{a_1}3^{a_2}5^{a_3}\cdots p^{a_i}\$ where \$a_i > 0\$
$$f(n) = \{f(a_2+1),f(a_3+1),\cdots,f(a_i+1),\underbrace{\{\},\{\},\cdots,\{\}}_{a_1}\}$$
For example:
$$\begin{align} f(22308) & = \{f(2),f(1),f(1),f(2),f(3),\{\},\{\}\} \\
& = \{\{\{\}\},\{\},\{\},\{\{\}\},\{f(2)\},\{\},\{\}\} \\
& = \{\{\{\}\},\{\},\{\},\{\{\}\},\{\{\{\}\}\},\{\},\{\}\}
\end{align}$$
Rules

You may write a full program or a function to do this task.
Output can be in any format recognisable as a sequence.
Built-ins for prime factorization, primality testing, etc. are allowed.
Standard loopholes are disallowed.
Your program must complete the last test case in under 10 minutes on my machine.
This is code-golf, so the shortest code wins!

Test Cases

10: {{},{{}},{}}
21: {{{}},{},{{}}}
42: {{{}},{},{{}},{}}
30030: {{{}},{{}},{{}},{{}},{{}},{}}
44100: {{{{}}},{{{}}},{{{}}},{},{}}
16777215: {{{{}}},{{}},{{}},{},{{}},{{}},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{{}}}
16777213: pastebin

Is the same output, without the commas, still recognisable as a sequence?

@Dennis Yes, you can tell by the brackets.

How about the number 1

Ooh, that is {}.

Would this be an acceptable output format? CJam doesn't distinguish between empty lists and empty strings, so this is the natural way of representing a nested array.

@Dennis I can accept that, I just didn't want people outputting things like 83e3b5d246e61bd0 and saying that it is a sequence.

05AB1E, 10 bytes
ÓćÅ0«ε¯sF¸

Output with [] instead of {}.
Try it online or verify all test cases, where test case 16777213 is replaced with 1009 (another prime number) - the output for 16777213 would be similar, just with a lot more leading [], ..
Explanation:
Ó           # Get the exponents of the prime factorization of the (implicit) input
            #  ([a,b,c,d,...] in 2^a*3^b*5^c*7^d*...=input)
 ć          # Extract head; pop and push remainder-list and first item separated
  Å0        # Get a list of 0s with a length equal to the `a` exponent
    «       # Merge that as trailing items to the remainder-list
     ε      # Map over each integer in the list:
      ¯     #  Push an empty list
       s    #  Swap so the current number is at the top of the stack
        F   #  Loop that many times
         ¸  #   And wrap the list into a list every iteration
            # (after which the result is output implicitly)

wow, that is really short.

CJam, 51 48 44 42 41 39 34 33 31 bytes
{mf_W=)1|{mp},\fe=(0a*+{)J}%}:J

Try it online in the CJam interpreter.
Thanks to @MartinBüttner for golfing off 3 bytes!
Thanks to @PeterTaylor for golfing off 3 bytes and paving the way for 1 more!
At least on my computer, downloading the file takes longer than running the program...
I/O
This is a named function that pops and integer from STDIN and pushes an array in return.
Since CJam does not distinguish between empty arrays and empty strings – a string is simply a list that contains only characters –, the string representation will look like this:
[[""] "" [""] ""]

referring to the following, nested array
[[[]] [] [[]] []]

Verification
$ wget -q pastebin.com/raw.php?i=28MmezyT -O test.ver
$ cat prime-mapping.cjam
ri
  {mf_W=)1|{mp},\fe=(0a*+{)J}%}:J
~`
$ time cjam prime-mapping.cjam <<< 16777213 > test.out

real    0m25.116s
user    0m23.217s
sys     0m4.922s
$ diff -s <(sed 's/ //g;s/""/{}/g;y/[]/{}/' < test.out) <(tr -d , < test.ver)
Files /dev/fd/63 and /dev/fd/62 are identical

How it works
{                           }:J  Define a function (named block) J.
 mf                              Push the array of prime factors, with repeats.
   _W=                           Push a copy and extract the last, highest prime.
      )1|                        Increment and OR with 1.
         {mp},                   Push the array of primes below that integer.

                                 If 1 is the highest prime factor, this pushes
                                 [2], since (1 + 1) | 1 = 2 | 1 = 3.
                                 If 2 is the highest prime factor, this pushes
                                 [2], since (2 + 1) | 1 = 3 | 1 = 3.
                                 If p > 2 is the highest prime factor, it pushes
                                 [2 ... p], since (p + 1) | 1 = p + 2, where p + 1
                                 is even and, therefor, not a prime.

              \fe=               Count the number of occurrences of each prime
                                 in the factorization.

                                 This pushes [0] for input 1.

                  (              Shift out the first count.
                   0a*           Push a array of that many 0's.
                      +          Append it to the exponents.

                                 This pushes [] for input 1.

                       {  }%     Map; for each element in the resulting array:
                                   Increment and call J.

Blame Pastebin :P

mf e= is much better than what I'd found when I knocked up a sanity test while the question was in the sandbox, but one improvement I found which you haven't used is to do the mapping for the twos as (0a*+ - i.e. ri{}sa2*{mf_W=){mp},\fe=(0a*+0j\{)j}%*}j. And there's a much bigger improvement as well which I'll give you a few hours' headstart on...

@PeterTaylor Thanks for the golf and the hint.

Yep, changing the output representation was indeed the bigger improvement. There's a better way of handling the base case too, which I've only just found, but to beat your solution I have to use two of your ideas so: {mf_W=)1|{mp},\fe=(0a*+{)J}%}:J

@PeterTaylor That one magical 1|. Thanks again!

Mathematica, 88 bytes
f@1={};f@n_:=f/@Join[1+{##2},1&~Array~#]&@@SparseArray[PrimePi@#->#2&@@@FactorInteger@n]

The magic of undocumented internals...

Jelly, 14 bytes
ÆEµ“”WẋḢ;@‘ß€$

Try it online!
The last test case times out on TIO. The Footer runs the program over the inputs, gets their raw form (Jelly doesn't display empty lists well) and replaces the [] with {}
How it works
ÆEµ“”WẋḢ;@‘ß€$ - Main link. Takes n on the left
ÆE             - Compute the prime exponents of n
  µ            - Begin a new link with the exponents E as the argument
   “”          - []
     W         - [[]]
       Ḣ       - Take the first exponent, a
      ẋ        - Repeat each element of [[]] a times
             $ - Group the previous 2 links as a monad f(E):
          ‘    -   Increment each exponent
            €  -   Over each:
           ß   -     Recursively run the main link
        ;@     - Append the [[]] to the recursive call result

Pyth, 29 bytes
L+'MhMtbmYhbL&JPby/LJf}TPTSeJ

Demonstration
This defines a function, ', which performs the desired mapping.
A helper function, y, performs the mapping recursively given a prime decomposition. The base case and the prime decomposition are performed in '.

Stax, 34 bytes
ÑE│♂█ⁿt2N╔₧Ñ↓Ls&ûΦ}eóâÇΔ-ë╖»8Kq+╔r

Run and debug it
There's very likely a better way to do this with recursion, but I just can't seem to find anything related to it in the builtin docs. So, this is a manually built implementation.
Takes very, very long after the third test case.
Explanation (Unpacked)
z]Yx{c2>{|nBs{y@msz]s|*+c]ys+Yd}{vy@}?F|u
z]                                        array [[]]
  Y                                       write that to register Y
   x{                                 F   for i in [1..input]
     c2>                                  if i < 2,
                                {vy@}     increment and take element at that index from y
        {|n                               otherwise take prime exponents
           Bs                             push the first element and the rest of the array separately
             {  m                         map the rest of the array to:
              y@                          elements in y at those indices
                 sz]s                     push [[]] and first element
                     |*                   repeat it's elements that many times
                       +                  add those together
                        c]ys+Y            and append that to register Y
                              d}          then delete it
                                       |u convert the last element on stack to string
                                          implicit output


text:
Ducttape the Ducttape
Your boss has found out that quite a bunch of his employees (including you) like to steal code from others. He ordered you to write him a program that he can use to find people who steal code from others.
Task:
Write a program/function that detects if somebody copied (part of) his code from somewhere else.
The program will get all the existing programs and the program that it should test from two separate inputs.
Edit: Since there are no answers so far, you may use regular expressions!
Output

The program should then output all the stolen pieces of code, separated by either a space or a newline. (It may have a space or a newline at the end.)
A piece of code is considered to be stolen/copied if it consists of 10 or more successive bytes. (Sorry, Java fans!)
You have to output as much as possible, but if there are overlapping ones, you may ignore one of them or output both of them.

Twist:
As mentioned before, you also love duct tape coding. That means, everything in your code will be copy-pasted from a stack exchange site!
You can copy whatever you want (not limited to code in code blocks) and as much as you want. (But at least 10 bytes)
(Same rule as above about what is considered to be stolen/copied.)
(Please do note that any answers that were posted after this question may not be used.)
Please provide links to where you got your code from.
Examples:
Input:
x = document.getElementById("ninja'd"); (The first input)
y = document.getElementById("id"); (The second input)
Output:
 = document.getElementById("

Input:
foo (The first input)
foo+bar (The second input)
Output:
Nothing.
Input:
public static void main(String[] args) (The first input)
public  static  void  main(String[] args) (The second input)
Output:
 main(String[] args)

Input:
for(var i=0; i<x.length; i++){} (The first input)
for(var i=0; i<oops.length; i++){break;} (The second input)
Output:
for(var i=0; i<
.length; i++){

or
for(var i=0; i< .length; i++){

It's missing rules for which strings can be copied and how (for the code).

Do the copied strings have to come from code blocks, or any parts of an SE answer? If it comes from a code block does it need to use the entire block, or can a substring be used? Can the strings come from either the formatted text or the Markdown source? Can code blocks newer than this question be used? Can old revisions of a question be used?

@Vɪʜᴀɴ You are free to assume whatever makes most sense for your language! (e.g. If you happen to be answering in Brainfuck, you may assume that the input will be in the ASCII range..)

@Stefnotch My questions are about what code we use to write our program, not the inputs.

@Vɪʜᴀɴ Oh! I updated my question! Better? (Also, http://meta.codegolf.stackexchange.com/questions/5431/should-i-delete-my-comment-after-op-fixes-golfs-ops-code )

You say the substrings have to length 10 or more. Can I place a substring inside another substring? (Do the substrings have to be continuous?)

@muddyfish What do you mean?

@Stefnotch Say I had a substring "1234567890" and another one "qwertyuiop". Could "12qwertyuiop34567890" be in my code?

@muddyfish So, the existing programs are qwertyuiop and 1234567890. Your program is 12qwertyuiop34567890, right? Well, the overlapping part is qwertyuiop (That is the output.)

No, I meant can I use 12qwertyuiop34567890 as part of my source?

@muddyfish Oh, that's a good question! My intent was that that is impossible... (Editing the question)

@Doorknob I decided to allow regular expressions.

@sysreq I decided to allow regular expressions!

Easy answer: Use Unary

Python 2, 224 bytes
from difflib import SequenceMatcher
def similar(a, b):
    return SequenceMatcher(None, a, b).get_matching_blocks()
a=raw_input()
b=raw_input()
for start, _, size in similar(a, b):
 if(size > 9):
  print a[start:start+size]

Copied from this answer:
from difflib import SequenceMatcher
def similar(a, b):
    return SequenceMatcher(None, a, b).

get_matching_blocks() is copied from this answer
a=raw_input()
b=raw_input()

is copied from this question
for start, _, size in is copied from this answer and the second occurence of similar(a, b) is copied from the same place as the first.
if(size > 9) is copied from this question.
:
    print

is copied from this question
a[start: is copied from this answer.
and finally, start+size] is copied from this questipn
Finally answered after one and a half years ...

+1 Though, https://stackoverflow.com/questions/37386311/fuzzy-module-not-working-for-me was posted after this challenge was posted. I decided to remove that restriction, so your answer is fine. :)

@Stenfoch You don't need to; an earlier answer contains the same phrase

One thing I learned about [tag:duct-tape-coding] challenges: It is tricky to keep track of where you got all of your code.

Wow, the score of this post has been rising very quickly ...


text:
Define map in the fewest tokens
map is a very basic yet important function in functional programming.
All FP programming languages have it built-in but it is always fun to see how shortly you can define it yourself.
This will be scored in AST nodes, not bytes.
A token is the second-smallest building block of a program, over characters.
A token is:

anything that would be a distinct node if you drew a tree representing the source code

This scoring gives no benefit to single letter AST nodes names, and values succinctness as Paul Graham likes (this definition of AST nodes is his).
Haskell has this super cool definition:
zipWith ($) . repeat

And my lisp-ish AST of it (not required in your answer, just to show it visually)
   Apply (Apply (Var ".") (Apply (Var "zipWith") (Var "$"))) (Var "repeat")

That is 7 tokens. (Var x counts as 1)
I did not write it, so I do not post it as an answer.
Example:
(zipWith ($) . repeat) (* 3) [1, 2, 3] -- [3, 6, 9]

map should be defined as a (named or unnamed) function taking two arguments, the function and the list.
May the most AST nodes-succint code win!

exec "blah blah blah" <- 2 tokens, right?

@feersum nice loophole, but if you write code in a string, than you should count the tokens inside the string. Otherwise everything would be written in 2 tokens :)

@feersum or I may disable exec in general as it is just a cheap way to circle around the rules...

Should the map be in-place, or should it return a new array?

@Doorknob mutability is not allowed in FP. Return a new array

I'm voting to close as unclear because tokens are not precisely defined.

How should the map be implemented? As a function with two arguments, an array and another function? Or can it just assume that the variable names of the array and the function will be constant?

@feersum true, I should have used the sandbox... I will try my best to define a token

@Doorknob function with two arguments

@feersum defined a token

I don't think your definition really clears things up. If I drew an AST of your source code, it would have "apply" nodes which don't correspond to tokens of the source.

@PeterTaylor i am not good at doing AST so probably your tree is correct and mine is wrong.

@PeterTaylor in fact I suspec that [Space] should also be  a token

@PeterTaylor wonderful people on #haskell freenode gave me good info on AST

@PeterTaylor The correct tree is: Apply (Apply (Var ".") (Apply (Var "zipWith") (Var "$"))) (Var "repeat") where Var x counts as 1

I'd love to see a meta post about this "tokens" concept, to clear this all up before it's used in challenges.

@Sparr I think just saying AST nodes instead of tokens should clear it up

I chose to define map as map. Bam, 1 AST node. ;)

@MorganThrapp maybe, just maybe if a challenge is implementing x, saying x = builtin_x is a loophole ;)

@Caridorc Define a "builtin map". For example, would the Python list comprehension answer be valid?

@LegionMammal978 I would think so. It does the full workload of creating a new list, calling the transformation function for each item in the given list, and appending each resulting item to the new list. What more could you want from a self-contained map() implementation?

@BlacklightShining The thing is, thee user doesn't do that, Python does it.

@LegionMammal978: In the same way that Python creates a list when foo_list = [] is executed?

@BlacklightShining In that case, the user "does the full workload of" defining the 0 elements of [].

@LegionMammal978 How do we decide where the line is, then? I'm inclined to accept the list-comprehension answer, given that it's syntactic sugar for creating a new list, etc, etc.

@BlacklightShining Let the OP decide.

Mathematica, 36 11 nodes
Thread@#@#2&

The FullForm of this program is:
Function[Thread[Slot[1][Slot[2]]]]

which has 4 symbols, 2 numbers, and 5 function applications.

Python 3, 19 nodes.
lambda f, x: [f(y) for y in x]

Fairly self-explanatory. Applies f to each element of x and then returns the resulting list.
Interestingly, this code also uses only 19 AST nodes:
def map(f, x):
    for y in x:
        yield f(y)

I'm not totally sure if I'm counting the nodes correctly, because this is the first time I've worked with an AST. But this is what I used to count:
import ast
code = '''
lambda f, x: [f(y) for y in x]
'''
print sum(1 for node in ast.walk(ast.parse(code)))

Wouldn't this be considered a builtin map? [a(b) for b in c] is the same as map(a, c).

@LegionMammal978 Same as zipwith is a builtin map, but that was the OP's example.

@LegionMammal978 Sure, but anything that emulates map is going to be the same as calling map. Plus, the challenge technically never disallows the usage of map as a builtin. ;)

@MorganThrapp "you can define it yourself."

@LegionMammal978 I guess so, but there's nothing saying I can't just define it myself as map = map.

Using the built-in AST is surely the best way of counting

Haskell, 11(?) nodes
flip foldr ([]).((:).)

Not sure about the node count (6 symbols plus 5 function applications?).

Counting nodes is indeed hard. This is why AST-based scoring is so rare


text:
Find the center
Given a string of ASCII characters, output the character that is in the middle. If there is no middle character (when the string has an even length), output the ASCII character whose ordinal is the floored average of the two center characters. If the string is empty, an empty string should be output.
Test cases:
12345 => 3

Hello => l

Hiya => q

(empty input) => (empty output)

Shortest program in characters wins. (Not bytes.)
Leaderboard
The Stack Snippet at the bottom of this post generates the leaderboard from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
## Language Name, N characters

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
## Ruby, <s>104</s> <s>101</s> 96 characters

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
## Perl, 43 + 2 (-p flag) = 45 characters

You can also make the language name a link which will then show up in the snippet:
## [><>](http://esolangs.org/wiki/Fish), 121 characters

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

Usually we score in bytes so people can't compress their entire code, as this results in boring solutions. Are you sure you want this?

@Vɪʜᴀɴ I don't think that will be a problem here, since solutions will be very short anyway, so compressing won't be worth it.

Can you describe what you mean by floored average?

@TanMath I think it means if the average is 87.8 you should always round down to 87

Welcome to PPCG! Great first challenge!

Can we write functions?

Pro-tip: encode your answers in UTF-32. 4 bytes per character. Or maybe the OP should just get rid of the character scoring.

@Vɪʜᴀɴ Functions are allowed by default int [tag:code-golf]

@Mego See http://meta.codegolf.stackexchange.com/questions/7248/should-a-character-encoding-that-cant-actually-be-used-by-a-compiler-interprete

@AdamDavis That only matters if your compiler/interpreter can't read the encoding. Seriously, for example, is happy with any encoding, because it's all just bytes to it anyway.

Why is the center of Hiya q?

Pyth, 15 bytes
Cs.O@R/lz2_BCMz

Demonstration
Starting with "Hiya" as input:
              z    "Hiya"                                      Input
            CM     [72, 105, 121, 97]                          Character values
          _B       [[72, 105, 121, 97], [97, 121, 105, 72]]    Pair with reversal
      /lz2         2                                           Halfway index
    @R             [121, 105]                                  That element in each
  .O               113.0                                       Average
 s                 113                                         Floor
C                  "q"                                         Cast to character
                   q                                           Print implicitly

Note that this crashes with an error on empty input, and prints nothing to STDOUT, which is a valid way to output an empty string by code-golf defaults.

Bifurcate shows its utility again.

whoa bifurcate is awesome.

@KenanRhoton In response to your proposed edit, check out the commit that added the C flooring functionality: https://github.com/isaacg1/pyth/commit/0baf23ec Notice the day it was added, the same day this question was asked. That's because this question inspired me to add that functionality, making it ineligible for use on this question.

Brainf***, 61 bytes
Chinese, 16 characters
This requires the input is in the ASCII range 1-127 and is null-terminated.  It deletes pairs of characters from the start and end of the string until there are one or two characters remaining.  If there are two, it adds them together, then divides by 2, rounding down.  The remaining character is printed.
,[>,]<<<[[<]>[-]>[>]<[-]<<<]>[[->+<]>[-[-<+<]>>]<[>]<[>]<<]>.

Try it on this interpreter.
Dissection:
,[>,]         Get the null terminated input
<<<           Move to the second last character
[             While there are at least 3 characters
  [<]>           Move to the first character
  [-]            Delete it
  >[>]<          Move to the last character
  [-]            Delete it
  <<<            Move the the third last character
]
>              Move to the second last character
[              If there are two characters remaining
  [->+<]         Add the two characters together
  >[-[-<+<]>>]   Divide the character by 2 rounding down
  <[>]<[>]<<     Move to before the character to exit the if loop
]
>.             Print the remaining character

* Given each instruction could be compressed to 3 bits and encoded in UTF-32, the whole program could technically be expressed in 6 characters.
EDIT: And thanks to Jan Dvorak for introducing me to Chinese, which compresses this into 16 characters, on par with Dennis' CJam answer.
蜐蕈帑聿纂胯箩悚衅鹊颂鹛拮拮氰人

Given each instruction could be compressed to 3 bits and encoded in UTF64, the whole program could technically be expressed in 3 characters. You win. The internet. And everything else.

I don't think this is valid. Brainfuck source code is the characters +-<>,.[], in whatever encoding, not their binary representations. We have a consensus that an encoding that can't be used by an existing interpreter is invalid.

@ThomasKwa, hence I gave my score primarily in un-encoded bytes.  The character encoding was just joining in the idea that scoring by characters can be abused.

@ThomasKwa : it's time for some of us to make such an interpreter, to be used in future challenges. Imagine BF beating the best golfscript solution! :)

@vsz, I think I now have something to keep me busy tonight... ;-)

I can't find a description of UTF64 anywhere; did you mean UTF-32?

@anatolyg No, he meant UTF-64, with twice the codepoints as UTF-32 as a joke.

Then I do UTF-9000! I win :)

@anatolyg, whoops.  Yeah, I guess I meant UTF-32.  That's what I get for not compiling my super-encoded code.

@vsz https://esolangs.org/wiki/Chinese

8086 machine code + DOS, 31 bytes
Hexdump:
BA 1E 01 B4 0A CD 21 8B F2 46 8A 1C D0 EB 8A 50
01 72 06 74 08 02 10 D0 EA B4 02 CD 21 C3 FF

Assembly source code (can be assembled with tasm):
    .MODEL TINY

    .CODE
    org 100h

    MAIN PROC

    mov dx, offset buf
    mov ah, 10      ; DOS function "read string"
    int 21h

    mov si, dx
    inc si          ; si now points to the length of the string
    mov bl, [si]    ;
    shr bl, 1       ; divide the length by 2
    mov dl, [si+bx+1] ; load the middle char
    jc calc_done    ; if length was odd - done
    jz output_done  ; if length was zero - exit
    add dl, [si+bx] ; add the other middle char
    shr dl, 1       ; divide by 2
calc_done:
    mov ah, 2       ; DOS function "output char"
    int 21h
output_done:
    ret

buf db 255          ; maximum bytes to input

    MAIN ENDP
    END MAIN

There is some delicate usage of the FLAGS register here. After it shifts the length of the string right by 1 bit (which is equivalent to division by 2), two flags store additional information:

Carry flag: contains the bit that was shifted out. If the bit is 1, the length was odd.
Zero flag: shows whether the result is zero. If the carry flag is 0 and the zero flag is 1, the length was zero, and nothing should be printed.

Normally, the flags should be checked immediately, but here I use the fact that the mov instruction doesn't change flags. So they can be examined after loading the middle char.

CJam, 16 bytes
q:i_W%.+_,2/=2/c

Try it online!
How it works
q                e# Read all input.
 :i              e# Cast each character to integer.
   _W%           e# Push a reversed copy.
      .+         e# Perform vectorized addition.
        _,2/     e# Get the length, divided by 2.
            =    e# Select the corresponding sum.
             2/c e# Divide by 2 and cast to character.

Why almost any CJam/Pyth golf is 10-30 chars no matter the difficulty? O.o

Difficulty? This is a simple median calculation, minus the sorting...

@Dennis I think that's what he means. It can be about the same length for both easier and harder questions.

@Zereges Not really. 10-30 is typical for easy problems. See this if you want an example of how it looks for something more complex: http://codegolf.stackexchange.com/a/64086/32852.

TeaScript, 23 bytes 25 30 31 33
²(x[t=xn/2]c+xv[t]c)/2)

Uses @isaacg's idea of reversing the string.
Try it online
Test all of the cases
Ungolfed && Explanation
TeaScript is still JavaScript so it functions a lot like JavaScript too.
C((x[t=xn/2]c+xv[t]c)/2)

C((           // Char code to char
   x[t=xn/2]c // Floored center
   +          // Add to
   xv[t]c     // Ceil'd center
  ) / 2)      // Divide by 2

That kerning...

That header is rad. I want that header for every goddamn language.

Yeah, except the kerning.

@sysreq lol, it had to do with the fact I'm using a different font, fixed.

Please tell me will work.

Now I get TypeError: x.G is not a function even though there is no xG???

@ETHproductions huh, weird, try it now

Yep, it's better :)

@ThomasKwa The default for my computer is ISO-8859, or Latin-1. In UTF-8 encoding this is 24 bytes but in Latin-1, it is 23.

Python 3, 61 59 57 55 bytes
I try not to golf with languages I work in, but this isn't too evil.
Thanks to @xsot for 2 bytes!
lambda x:chr((ord(x[len(x)//2])+ord(x[~len(x)//2]))//2)

The full program is 59 bytes:
x=input()
l=len(x)//2
print(chr((ord(x[l])+ord(x[~l]))//2))

Try it here.

Ah, you beat me to what my next task was going to be (had I not found 10 bytes to shave off)

No, no, 10 bytes to shave off my 166 byte Go solution. Yours is far more elegant, however.

@sysreq Ah, I misunderstood. And thanks.

-1-len(x)//2 is equivalent to ~len(x)//2 because of how floor division works on negative integers.

@xsot Thanks—it makes the code a little more evil though :)

Matlab, 39 37 bytes
floor((end+[1,2])/2) returns the middle two indices of the string if the length is even, and returns the middle indice twice if the length is odd.
mean just returns the mean of those values and char automatically floors it.
@(s)char(mean(s(floor(end/2+[.5,1]))))

Husk, 11 bytes
c½S¤+öc→←½↔

Try it online!
Explanation
Delicious, delicious combinators all the way down. ö is "compose these four functions", ¤ is "apply the first argument to the results of applying the second argument to two additional arguments separately", S is "apply this function (which should take two arguments) to S's third argument and to the result of applying S's second argument to its third". Therefore,
   Function       Type                Semantics
     öc→←½        [TChar]->TInt       ASCII code of middle (floored) char in string
   ¤+öc→←½        [TC]->[TC]->TI      Sum of ASCII codes of middle of two strings
  S¤+öc→←½↔       [TC]->TI            Sum of ASCII codes of the middle of a string and its reverse
c½S¤+öc→←½↔       [TC]->TC            ASCII character represented by half the above, QEF

Edited to add:
Strictly speaking, this fails slightly to conform to the problem specification, which requests a string in the case of an empty input and a character in other cases.
Due to Husk's strict typing, it's just not possible to define a function/program that can return either of two types. I chose to return a single character in all cases, and for Husk, the most reasonable choice for a single character to represent the empty string is '(space)' because that's the "default" value (and in fact, that's why this program returns it; the default value is used when taking the last (→) item of an empty list).
I could have also reasonably chosen to return strings of zero or one characters, which would fail the specification in the other direction, but I didn't because it adds four bytes: Ṡ&ö;c½S¤+öc→←½↔, with the ; converting the character to a one-character string, another ö to explicitly compose the needful, and a Ṡ& to shortcut in the case of falsy input.

Huh, I tried this: Try it online!

Prolog, 111 bytes
Code
p(X):-atom_codes(X,L),length(L,N),I is N//2,J is(N-1)//2,nth0(I,L,A),nth0(J,L,B),Q is(A+B)//2,writef('%n',[Q]).

Explained
p(X):-atom_codes(X,L),       % Convert to list of charcodes
      length(L,N),           % Get length of list
      I is N//2,             % Get mid index of list
      J is(N-1)//2,          % Get 2nd mid index of list if even length
      nth0(I,L,A),           % Get element at mid index
      nth0(J,L,B),           % Get element at 2nd mid index
      Q is(A+B)//2,          % Get average of elements at mid indices
      writef('%n',[Q]).      % Print as character

Examples
>p('Hello').
l

>p('Hiya').
q

R, 73 bytes
function(x,y=utf8ToInt(x),n=sum(1|y))if(n)intToUtf8(mean(y[n/2+c(1,.5)]))

Try it online!
Many thanks to @ngm for coming up with this non-recursive idea - allowed to golf 20 bytes.
Old solution:
R, 101 95 bytes
"!"=function(x,n=sum(1|x))"if"(n<3,mean(x),!x[-c(1,n)])
try(intToUtf8(!utf8ToInt(scan(,""))),T)

Try it online!
Recursive solution. Corrected one issue at the price of 2 bytes:

added try(expr, silent = TRUE) to properly manage the case where the input is empty.

thanks Giusppe for 4 bytes !

doesn't intToUtf8 truncate non-integers?

@Giuseppe you are right as always :)

92 bytes non-recursive solution.

82 bytes I'd rather you post it as a separate answer - it's totally different from my answer!

Well, I wouldn't have come up with it unless you had put the original effort in. And my answer was a port of the top vote-getting Pyth answer. With a bunch of tricks we R people have come up. And then you made it shorter. So go ahead and make the edit with a clear conscience!

@ngm Many thanks, will do. I have found some more bytes though :)

O, 44 34 bytes
Crossed out 44 is still regular 44 :(
ise.eJ;2/m[(\($L;dJ{#\#+2/c}L;?o];

Bytes wasted on:

Checking if the input's length is even/odd
Getting the middle character(s)

I'm sure you posted an ungolfed version to say that ;)

@CᴏɴᴏʀO'Bʀɪᴇɴ I just got lucky :D

JavaScript (ES6), 83 bytes 89 91
Saved 2 bytes thanks to @Cᴏɴᴏʀ O'Bʀɪᴇɴ
Saved 6 bytes thanks to @ETHproductions
s=>String.fromCharCode((s[~~(t=s.length/2-.5)][q='charCodeAt']()+s[0|t+.9][q]())/2)

JavaScript's not too good at all this string char code.

You beat me to it. Oh well, least I can do is help you ;) s=>String.fromCharCode((s[~~(t=s.length/2-.5)][r="charCodeAt"]()+s[Math.ceil(t)][r])/2) is 5 bytes shorter.

@CᴏɴᴏʀO'Bʀɪᴇɴ Sweet. I need the () around charCodeAt so it's really 3 chars,but  thanks anyway!

@ןnɟuɐɯɹɐןoɯ if t is an integer that won't work

Math.ceil(t) can be changed to 0|t+.9

@ETHproductions thanks, That saved 6 bytes!

I get TypeError: s[~(~((intermediate value)))] is undefined for an empty string

C++14, 56 bytes
[](auto s){int l=s.size();return(s[(l-1)/2]+s[l/2])/2;};

Anonymous lambda taking string as an argument and returning int as char code. For "", it returns 0. Not sure how exactly the input and output should look like (is not specified in the question).
Ungolfed, with usage
#include <string>
int main()
{
    auto lmbd = [](auto str)
    {
        int len = str.size();
        return (str[(len - 1) / 2] + str[len / 2]) / 2;
    };

    std::cout << (char) lmbd("Hiya"s) << std::endl; // outputs q
}

@CᴏɴᴏʀO'Bʀɪᴇɴ done.

I don't think you can output with the character code, and I don't think you can output 0 for "" either.

It would be nice to have apparent rules.

54 bytes

Minkolang 0.13, 23 20 bytes
$oI2$%d$z,-Xz3&+2:O.

Try it here.
Explanation
$o        Read in the whole stack as characters
I2$%      Push I,2, then pop them and push I//2,I%2
d$z       Duplicate top of stack (I%2) and store in register (z)
,-X       <not> the top of stack, subtract, and dump that many off the top of stack
z3&       Retrieve value from register and jump 3 spaces if this is not zero
   +2:    Add and then divide by 2
O.        Output as character and stop.

hiya returns i instead of q

@Vɪʜᴀɴ: OH. I misread it. I thought the question was asking for the character in the middle, going to the floored average position if the length was even.

@ThomasKwa: Fixed.

@Vɪʜᴀɴ: ^ Fixed.

, 23 chars
a=ïꝈ/2,ϚĎ((ïüa+ᴙïüa)/2)

Try it here (Firefox only).
Thanks to @ETHProductions for the idea!

Lucky, a challenge measured in chars instead of bytes ;)

Oh yay! We're all tied.

Whoever downvoted this, could I please get an explanation?

Japt, 40 29 23 21 20 bytes
Saved 4 bytes thanks to @ןnɟuɐɯɹɐןoɯ
Now only half the original length! I love code golf. :-D
UcV=K*Ul)+Uw cV)/2 d

Works properly on the empty string. Try it online!
How it works
          // Implicit: U = input string, K = 0.5
Uc        // Take the char-code at position
 V=K*Ul   //  V = 0.5 * length of U
+         //  (auto-floored), plus
Uw cV     //  the char-code at position V (auto-floored) in the reversed string,
/2 d      //  divide by 2, and turn back into a character (auto-floored).
          // Implicit: output last expression

As you can see, it uses a lot of auto-flooring. (Thanks, JavaScript!) Suggestions welcome!

The reverse thing is brilliant +1

Couldn't you just do V=Ul /2;((UcV +Uw cV )/2 d?

@ןnɟuɐɯɹɐןoɯ Well, duh :P I've used c so many times without an argument that I forgot it accepted one. Thanks!

Go, 166 156 153 bytes
Go may not be the best language for golfing... but I love it, so so much, and I'm learning it, so there.
This implementation accepts blank (\n) input and will probably break with non-ASCII/ASCII-extended input. However, OP has not specified input/output encoding thus ASCII is all I've explicitly supported.
Edit: turns out if/else is shorter than switch. Now I know, I suppose.
Golfed:
package main;import ."fmt";func main(){a:="";_,_=Scanln(&a);if b:=len(a);b>0{x:=b/2;if b%2==0{Printf("%c",(a[x]+a[x+1])/2)}else{Println(string(a[x]))}}}

Ungolfed:
package main # everything in go is a package.

import . "fmt" # the dot allows for absolute package method references
# (think "from string import *" in python)

func main() {
    a := ""
    _, _ = Scanln(&a) # a pointer to a
    if b := len(a); b > 0 { # if statements allow local assignment statements
        x := b / 2
        if b%2 == 0 { # modulo 2 is the easiest way to test evenness
#in which case, average the charcodes and print the result
            Printf("%c", (a[x]+a[x+1])/2)
        } else {
# else just find the middle character (no rounding needed; integer division in Go always results in an integer)
            Println(string(a[x]))
        }
    }
}

C#, 77 bytes
s=>{int n=s.Length;return n<1?' ':(char)(n%2>0?s[n/2]:(s[n/2-1]+s[n/2])/2);};

It doesn't actually return a string, and you'll get a space character if the input string is empty because the function must always return a value. 2 more bytes would be needed to return a string.
Full program with test cases:
using System;

namespace FindTheCenter
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<string,char>f= s=>{int n=s.Length;return n<1?' ':(char)(n%2>0?s[n/2]:(s[n/2-1]+s[n/2])/2);};   //77 bytes
            Console.WriteLine(f(""));
            Console.WriteLine(f("Hello"));
            Console.WriteLine(f("Hiya"));
        }
    }
}

Alternatively, a full program which reads user input and prints the center of the entered string:
C#,  144 bytes
using C=System.Console;class P{static void Main(){var s=C.ReadLine();int n=s.Length;C.Write(n<1?' ':(char)(n%2>0?s[n/2]:(s[n/2-1]+s[n/2])/2));}}

Again, it uses the same trick of printing a space character, which the user will not notice, and not an empty string, otherwise the solution is 2 bytes longer.

Vim,  38 24 23 keystrokes
Because vim has a built in function to find the middle line but not the middle  char, we split every character on a separate line first using substitute, find the middle line, then delete everything after and before it.
:s/\./\0\r/g<cr>ddMjdGkdgg

If you want to run this, beware of .vimrc files which may change the behavior of . (magic regex) and g (gdefault). Note that it actually saves me 3 keystrokes on my machine :)
Previous answer
:exe 'norm '.(virtcol('$')/2).'|d^ld$'

Takes a one line buffer as input, updates the current buffer with the middle character. I thought there would have been a shortcut for this in vim!
Note: a potentially shorter solution seems to cause an infinite loop... If someone has an idea: qq^x$x@qq@qp (12 keystrokes) -  it works with <c-c> after the last @q...

Excel, 122 79 bytes
Actually @Sophia Lechner's answer now:
=IFERROR(CHAR(CODE(MID(A8,LEN(A8)/2+.5,1))/2+CODE(MID(A8,LEN(A8)/2+1,1))/2),"")

-5 bytes from initial solution thanks to @Taylor Scott.
=IFERROR(IF(ISODD(LEN(A1)),MID(A1,LEN(A1)/2+1,1),CHAR((CODE(MID(A1,LEN(A1)/2,1))+CODE(MID(A1,LEN(A1)/2+1,1)))/2)),"")

12 bytes needed for Empty String.

Drop Average(...,...) and use (...+...)/2 for -5 bytes. =IFERROR(IF(ISODD(LEN(A1)),MID(A1,LEN(A1)/2+1,1),CHAR((CODE(MID(A1,LEN(A1)/2,1))+CODE(MID(A1,LEN(A1)/2+1,1)))/2)),"")

Excel will accept (and floor) a non-integer second argument to MID, so you don't have to split it into cases - =IFERROR(CHAR(CODE(MID(A1,LEN(A1)/2+1,1))/2+CODE(MID(A1,LEN(A1)/2+.5,1))/2),"") for 79 bytes

Haskell, 87 bytes
A nice recursive solution is possible here:
import Data.Char
f[]=[]
f[c]=[c]
f[c,d]=[chr(ord c+div(ord d-ord c)2)]
f(c:s)=f$init s

chr and ord are not in Prelude, so according to our golfing rules you need to include the import Data.Char in your byte count. In better news, you can drop f[]=[];f[c]=[c] and add f e=e as last line to save some bytes.

Wait, you can only shorten f[]=[] to f e=e, otherwise init throws an error.

Jelly, 7 bytes
JÆṁị¹Æm

Try it online!
Takes input as a list of codepoints. Outputs a single codepoint.
How it works
JÆṁị¹Æm - Main link. Takes a string S on the left
J       - Indices of S
 Æṁ     - Median
    ¹   - Yield S
   ị    - Index into S
     Æm - Get their arithmetic mean

The Æṁ median atom returns the mean of the two central elements if the list has an even list. When the list is the indices of S (i.e. [1, 2, ..., len(S)]), this will always be half the sum of an odd and an even integer, so the result will be \$x + \frac 1 2, x \in \mathbb N\$.
When indexing with non-integers such as \$x + \frac 1 2\$, Jelly instead uses the pair \$[x, x+1]\$ to index, which, in this case, results the two central characters if the list length is even.

Vyxal K, 8 bytes
‡ḢṪ↔Ṫtṁ⌊

Try it Online!
Explanation:
          # 'K' flag - Strings are inputted as a list of ordinal values
‡ḢṪ↔      # Remove the first and last elements elements of the list until empty, returning intermittent values
    Ṫt    # Remove all but the second to last element of the list
      ṁ   # Take the average of the middle character(s)
       ⌊  # Floor
          # 'K' flag - Output numbers as characters

K, 40 bytes
{(*|r;`c$_(+/r:2#l_x)%2)@l=_l:-1+(#x)%2}

I think this can be shortened to 31 bytes as {$[l:#x;`c$.5*+/x@_.5*l,l-1;x]}. The conditional guard is necessary to handle a "" input.

pb, 83 bytes
^>>w[B!0]{<w[B!0]{t[B]>}<b[0]<b[0]<[X]>>}w[B=0]{<}t[B]<[X]t[B+T]vb[T/2]

While there are at least 3 characters in the input string, the first and last are removed. This leaves either 1 character (should be printed unmodified) or 2 (should be averaged and printed). To handle this, the first and last characters of the string are added together and divided by two. If there was only one character, (a+a)/2==a. If there was two, (a+b)/2 is the character that needs to be printed. pb "borrows" Python's expression evaluation (def expression(e): return eval(e, globals())) so this is automatically floored.
Handling empty input costs me 5 bytes. Specifically,  on the first line. Earlier, when I said "string", that was a total lie. pb doesn't have strings, it has characters that happen to be close to each other. Looking for the "last character of a string" just means moving the brush to the left until it hits a character. When no input is provided, the "while there are at least 3 characters" loop is skipped entirely and it starts looking for the last character. Without that , it would keep looking forever. That code puts a character with a value of 1 at (-1, -1) specifically to be found when the input is empty. After finding the "last character" of the string the brush assumes the first one is at (0, -1) and goes there directly, finding a value of 0. (1+0)/2 is 0 in pb, so it prints a null character.

But monorail, that's still printing! The challenge specification says (empty input) => (empty output)! Isn't printing a null character cheating? Also, this is unrelated, but you are smart and handsome.

Thanks, hypothetical question-asker. Earlier, when I said "print", that was a total lie. In pb, you don't really print values, you just place them on the canvas. Rather than "a way to output", it's more accurate to imagine the canvas as an infinitely large 2D array. It allows negative indices in either dimension, and a lot of programming in pb is really about making sure the brush gets to the location on the canvas that you want it. When the program finishes executing, anything on the canvas with non-negative X and Y coordinates is printed to the appropriate location on the console. When the program begins, the entire canvas is filled with values of 0. In order to not have to print an infinite number of lines, each with an infinite number of null bytes, each line of output is only printed up to the last nonzero character, and lines are only printed up to the last one with a nonzero character in it. So putting a 0 at (0, 0) is still an empty output.
Ungolfed:
^                # Prevent an infinite loop on empty input

>>w[B!0]{              # While there are at least 3 chars of input:

    <w[B!0]{              # Starting at the second character:
            t[B]>         # Copy all characters one position to the left
                                # (Effectively erasing the first character)
    }

    <b[0]<b[0]            # Delete both copies of the last character

    <[X]>>                # Get in place to restart loop
}

w[B=0]{<}                 # Go to last character of remaining string
t[B]<[X]t[B+T]            # Find it plus the first character
vb[T/2]                   # Divide by 2 and print

CoffeeScript, 104 103 bytes
f=(x)->((y=x.length)%2&&x[y//2]||y&&String.fromCharCode (x[y/=2][z='charCodeAt']()+x[y-1][z] 0)//2)||''

Ruby, 43 42 41 bytes
->a{s=a.size;puts s<1?'':s%2<1??q:a[s/2]}

42 bytes
->a{s=a.size;puts s==0?'':s%2<1??q:a[s/2]}

43 bytes
->a{s=a.size;puts s==0?'':s%2<1?'q':a[s/2]}

Usage:
->a{s=a.size;puts s<1?'':s%2<1??q:a[s/2]}['12345']
=> 3

Mathematica, 118 99 chars
Floor
If[#=="","",FromCharacterCode[%@Mean@#[[Ceiling[l=Length@#/2];;%[l+1]]]&@ToCharacterCode@#]]&

Mma character code manipulation is pricey...

This function only works once, unless you repeat the entire code each time you want to call it. The point of function submissions is for them to be reusable. Calling your function breaks the value of the global % which it relies on.

Why not use the shortened forms of Floor and Ceiling?

><>, 24 + 3 (for -s) = 27 bytes
l1+l4(*9$.~{~
;
o;
+2,o;

Old solution (Doesn't work for empty input):
l3(?v~{~
?vo;>l2=
;>+2,o

Both take input on the stack through -s. Both are 24 bytes.
Try it online here.

 VBA, 130 Bytes
Function a(q)
h=Len(q):a=Mid(q,(h)/2,2)
If h Mod 2=0 Then:a=Chr((Asc(Left(a,1))+Asc(Right(a,1)))\2):Else:a=Right(a,1)
End Function

Finds the Middle 2 Characters.
  If number of Characters is Odd then get the Right of the Middle 2 which will be the true middle as we rounded down.
  If not sum the ASCII asc() values of the 2 Characters divided by 2 and return the ASCII Character chr() based on that value.

I think I can golf away one of the asc() calls, but couldn't get it to work shorter.

Java 7, 152 bytes
String c(String s){char[]a=s.toCharArray();int l=a.length,x,y;return l<2?s:""+(l%2>0?a[l/2]:(char)((x=a[l/2])>(y=a[(l/2)-1])?y+((x-y)/2):x+((y-x)/2)));}

Ungolfed & test cases:
Try it here.
class M{
  static String c(String s){
    char[] a = s.toCharArray();
    int l = a.length,
            x,
            y;
    return l < 2
            ? s
            : "" + (l%2 > 0
                     ? a[l/2]
                     : (char)((x = a[l/2]) > (y = a[(l/2)-1])
                                ? y + ((x-y)/2)
                                : x + ((y-x)/2)));
  }

  public static void main(String[] a){
    System.out.println(c("12345"));
    System.out.println(c("Hello"));
    System.out.println(c("Hiya"));
    System.out.println(c(""));
    System.out.println(c("x")); // Additional test case that will fail on some other answers
  }
}

Output:
3
l
q
(empty output)
x

PHP, 147 93 bytes
Credits and special thanks to Jörg Hülsermann for golfing my answer 54 bytes down!
<?=($l=strlen($s=$argv[1]))%2?$s[($l-1)/2]:chr(floor((ord($s[$l/2])+ord($s[$l/2-1]))/2));

Previous version:
$s=$argv[1];$l=strlen($s);echo($l%2!=0?substr($s,$n=($l-1)/2,-$n):chr(floor(abs((ord($x=substr($s,$l/2-1,1))-ord(substr($s,$l/2,1)))/2))+ord($x)));

Testing code:
$argv[1] = 'Hiya';
$s=$argv[1];
$l=strlen($s);
echo($l%2!=0?substr($s,$n=($l-1)/2,-$n):chr(floor(abs((ord($x=substr($s,$l/2-1,1))-ord(substr($s,$l/2,1)))/2))+ord($x)));

Test online
I have the feeling that this can be improved, but not enough time for it...

<?=($l=strlen($s=$argv[1]))%2?$s[($l-1)/2]:chr(floor((ord($s[$l/2])+ord($s[$l/2-1]))/2)); is my proposal

@JörgHülsermann Brilliant golfing! You should post it as your own answer. If I have time I will golf my answer more with your nice solutions. Thanks.

Feel free to take it as your answer

Seriously, 22 20 bytes
,O3 >WXXaXa3 >WXkæ≈c

Thanks @Mego for being great at your language
Try it online or whatever

This fails for empty input. I have a deleted 20-byte solution which I'm also trying to fix for empty input.

,;\`@(lIƒwill leave you with the input value on the stack if itslen` is > 0, or terminate the program otherwise. Note that there's an unprintable in the backticks - character 127.

@Mego This doesn't seem to be working.

@phase You gotta quote strings for input. This works.

@Mego What is the ƒ supposed to do?

@phase It calls the \`` (terminate program function) if the length is falsely, or tries (and fails) to call the string input.

The code you have also doesn't work for odd-length strings.

This, however, does work. If I had noticed that I screwed up the implementation of the median function before this challenge was posted, this would also work. ,║ is now valid as well, because I extended median to work with strings.

Lua, 128 bytes
p=...i=math.ceil(#p/2)s=string b=s.byte a=p:sub(i,i)io.write(#p==0 and""or#p/2%1~=0 and a or s.char((b(a)+b(p:sub(i+1,i+1)))/2))

Try it online!

05AB1E, 11 15 bytes
Dg≠iÇÂ)øDg;èO;ç

+4 bytes to fix an input of length 1.
Try it online or verify all test cases.
Explanation:
Dg              # Duplicate the input, and get it's length
  ≠i            # If this length is not exactly 1:
    Ç           #  Convert each letter to its ordinal value
                #   i.e. 'Hiya' → [72,105,121,97]
     Â          #  Bifurcate (short for Duplicate and Reverse)
                #   [72,105,121,97] → [72,105,121,97] and [97,121,105,72]
      )         #  Wrap both lists in a list
                #   [72,105,121,97] and [97,121,105,72] → [[72,105,121,97],[97,121,105,72]]
       ø        #  Zip the lists with each other, creating pairs
                #   i.e. [[72,105,121,97],[97,121,105,72]]
                #    → [[72,97],[105,121],[121,105],[97,72]]
        Dg      #  Duplicate it, and get it's length
                #   i.e. [[72,97],[105,121],[121,105],[97,72]] → 4
          ;     #  Halve this length
                #   i.e. 4 → 2
           è    #  Index (0-indexed) it in the pairs
                #   i.e. [[72,97],[105,121],[121,105],[97,72]] and 2 → [121,105]
            O   #  Take the sum of the indexed pair
                #   i.e. [121,105] → 226
             ;  #  Halve it
                #   i.e. 226 → 113.0
              ç #  Convert it from this ordinal value to a character
                #   i.e. 113.0 → 'q'
                # (Implicit else: output the 1-char input itself)

Old 11 bytes version which works for all given test cases, but fails for inputs of length 1:
ÇÂ)øDg;èO;ç

Try it online or verify all test cases.

C (gcc), 54 51 bytes
-3 bytes thanks to vazt.
Returns a NULL char for empty strings.
l;f(char*s){l=strlen(s);s+=l/2;s=*s+s[l%2-!!l]>>1;}

Try it online!

l%2-!!l instead of -!(!l+l%2) for 51 bytes

Suggest s=s[l/2]+s[~-l/2+!l]>>1 instead of s+=l/2;s=*s+s[l%2-!!l]>>1

Excel VBA, 101 81 bytes
Immediate window function that takes input from cell [A1] and outputs to the VBE immediate window
l=[Len(A1)]/2:s=[A1]&" ":If l Then?Chr((Asc(Mid(s,l+.5))+Asc(Mid(s,l+1)))\2)Else?

Japt, 15 bytes
cUÊz)dUÔcUÊz¹cz

Try it

05AB1E, 5 bytes
ÅsÅAï

Try it online! Beats all other answers. Takes input as a list of codepoints, and outputs as a codepoint.
ÅsÅAï  # full program
  ÅA   # mean of...
Ås     # middle(s) of...
       # implicit input...
    ï  # as an integer
       # implicit output

This fails for Hiya. The correct output should be q (113 as ord)

@cairdcoinheringaahing Hmm, good point. I wonder why... I'm looking into it.

It fails because this isn't the median, it's the middle. Median sorts its input

Python 3.8 (pre-release), 50 bytes
lambda s:chr(ord(s[(l:=len(s)//2)])+ord(s[~l])>>1)

Try it online!
Based on @lirtosiast's answer. Errors out on empty strings and thus the interpreter writes to stderr... So technically no output? O:)
Side note: The parentheses around l:=len(s)//2 are needed because, we are inside brackets [] and Python's parser thinks that the colon is part of a slice? Shouldn't that be a bug since the walrus operator := is a seperate token?


text:
Negate a condition if a bool is FALSE
Let's say I have a condition expression x and that I want to check if it is TRUE or FALSE depending on the value of a boolean y:
y ? x : !x

Is there a way to express it without repeating x expression? Something like how we can get a number or its opposite depending on a bool, without repeating the number in the expression:
number * (opposite ? -1 : 1)

Example, note the repetition of date.hour < 12 that I want to avoid:
tellTheThruth = FALSE; // or TRUE
if (tellTheThruth && date.hour < 12 || !tellTheThruth && !(date.hour < 12) {
    print "It's AM"
} else {
    print "It's PM"
}

Is it possible in all common languages (I was thinking in Javascript and I can't find a solution)? If not, is there some language in which you can?

Checking whether the two bools are equal should work: y==x, or tellTheTruth == (date.hour < 12). Are you asking though for actual code, where readability is a concern, or for brevity in code golf contests?

You could always get 1 or 0 for truthy and falsey respectively and then XOR them, is that what you want? example: tellTheTruth ^ (date.hour < 12)

voting to re-open. golfing tips questions are on-topic here.

@Sparr Still, what in this question tells you that he's trying to golf something?

Like I said in chat, his question explicitly asks about removing repetition of an expression (x)

I'm voting to close this question as off-topic because it doesn't really look like a code-golfing tips question to me.

@isaacg I would also, but I can't.

@xnor Great, seems I and this guy fell into the same trap. How didn't I thought about that yesterday?!? As someone else one says in that popular question, I shouldn't code (or make questions about booleans) at midnight... XD

for two booleans x and y, y ? x : !x can be rewritten as y ^ !x (y XOR NOT x) or similar in most languages.

Haskell
import Data.Bool.Extras
bool=<<not

bool from Data.Bool.Extras is similar to the ? operator in other languages. It takes 3 arguments, a False case, a True case and a boolean to decide which one to use. =<< works here in function context ( i.e. (f=<<g) x is f (g x) x), so we can use it as (bool=<<not) <x> <y> which is bool (not <x>) <x> <y>.
Example: (bool=<<not) True False -> False.


text:
Happy Fibonacci Day!
Background
Today (or Yesterday) is (or was) 11/23 or Fibonacci day! What better way to celebrate than to make a Fibonacci cake?

Examples
3

    ii
i_i_ii_i_i

</>
8

              ii
              ii
              ii
              ii
              ii
              ii
              ii
              ii
            i ii i
            i ii i
            i ii i
            i ii i
            i ii i
          i i ii i i
          i i ii i i
          i i ii i i
        i i i ii i i i
        i i i ii i i i
      i i i i ii i i i i
    i i i i i ii i i i i i
i_i_i_i_i_i_i_ii_i_i_i_i_i_i_i

Challenge
You're not really making a cake, just the candles because I can't ascii-art a cake
To make the cake you must first get the first n Fibonacci numbers sorted ascending. The candle (i)'s height is determined by value of the current Fibonacci number. The candles are separated by an underscore (_).
The cake should be symmetrical. So the candles should then be flipped and concatenated.
Example Construction
Input: 6
First 6 Fibonacci Numbers: 1, 1, 2, 3, 5, 8
Candle heights:

          i
          i
          i
        i i
        i i
      i i i
    i i i i
i i i i i i
-----------
1 1 2 3 5 8

Output would be:
          ii
          ii
          ii
        i ii i
        i ii i
      i i ii i i
    i i i ii i i i
i_i_i_i_i_ii_i_i_i_i_i

Reference Fibonacci Numbers
For reference, here are the first 15 Fibonacci numbers. In this challenge, you'll be starting at 1.
1,1,2,3,5,8,13,21,34,55,89,144,233,377,610

I regret to inform the West Coast of the United States that for most of the world, 11/23 is over or almost over :( This has just turned from [tag:code-golf] to [tag:fastest-code]

@sysreq That's okay, they just need to travel to the west coast (instantly), and then they can enjoy Fibonacci day for a last 5 hours (7 for hawaii) :p

Travel thousands of miles instantly? bash: beam-me-up: command not found

Must we print all the leading whitespace to make it line up or can we just print, in effect, the tallest lines first descending?

@sysreq No, candles must be printed in ascending order as specified. This wouldn't be too much harder as all I think it would be is a " ".repeat(n*2).

Trivial, indeed, for Python and Javascript

This challenge is going to be legendary in 43 years (11/23/58).

In 43 years the mm/dd/yy date format will be history. All intelligent beings will have switched to yyyy/mm/dd... :-P

@sysreq Posting golfed answers in verbose languages is very much encouraged. Of course, you're not competing with Pyth, but you can compete with other answers in the same language or in languages of comparable verbosity.

@yeti / is an inferior separator for that.

What is the minimum value of n?

@Dennis you can assume the minimum value is 1 and the input is always an integer. You don't need to handle invalid inputs

OK, 1 is going to be a special case... Is superflous whitespace (e.g., leading blank lines) alllowed?

@Dennis Yes, as long as it doesn't interfere with the relative position of the candles.

Pyth, 31 bytes
jaPJ_.ts_BuaaGks>4GtQ]\idXeJ" _

Try it online: Demonstration
Explanation:
jaPJ_.ts_BuaaGks>4GtQ]\idXeJ" _   implicit: Q = input number
          u        tQ]\i          reduce the list [1, ..., Q-2], start with G=["i"]
            aGk                      append the empty string to G
           a   s>4G                  append the sum of the last 4 strings in G to G
                                  this gives ["i", "", "i", "", "ii", "", "iii",..]
       s_B                        extend the list with the reversed list
     .t                  d        pad to a rectangle with spaces and transposes
   J_                             reverse the order and assign to J
  PJ                              remove the last string of J
 a                                and append
                         XeJ" _   the last string of J with spaces replaced by "_"
j                                 print each string on a separate line

J, 58 bytes
3 :''' i_''{~|.|:(,|.)(#&1,2#~0&=)"*}.,0,.(%-.-*:)t.1+i.y'

Uses (%-.-*:)t. for Fibonacci generation. Explanation might come a bit later.
Usage:
   f=.3 :''' i_''{~|.|:(,|.)(#&1,2#~0&=)"*}.,0,.(%-.-*:)t.1+i.y'
   f 5
        ii
        ii
      i ii i
    i i ii i i
i_i_i_i_ii_i_i_i_i

Try it online here.

CJam, 41 39 bytes
"i""_"1$ri({1$1$4$+}*]),f{Se[}W<_W%+zN*

This prints a fair amount of leading whitespace. Try it online in the CJam interpreter.
How it works
"i""_"1$ e# Push "i", "_", and a copy of "i".
ri(      e# Read an integer from STDIN and subtract 1.
{        e# Do that many times:
  1$     e#   Copy the last underscore.
  1$4$+  e#   Copy the last strings of i's and concatenate them.
}*       e#
]),      e# Wrap the results in an array, pop the last string, and get its length.
f{       e# For each remaining string, push the string and the length; then:
  Se[    e#   Pad the string to that length by prepending spaces.
}
W<       e# Remove the last string (underscore).
         e# We have now generated the columns of the left half of the output.
_W%+     e# Append a reversed copy (columns of right half).
z        e# Transpose rows with columns.
N*       e# Separate the rows by linefeeds.

TeaScript, 93 84 76 + 1 = 77 bytes
+1 byte for "Inputs are numbers?" checkbox
r×ß(p.R((w=F(x©-F(i¬©+"i"R(F(i¬±)t¡ß(j=i<w-1?" ":"_",(A=l¿i>0?j+l:l)µ)+Av©j§

Ungolfed version:
r(x)m(#(p.R((w=F(x))-F(i+1))+"i"R(F(i+1))))t()m(#(j=i<w-1?" ":"_",(A=ls``.m(#i>0?j+l:l)j``)+Av))j`
`

Thanks to @Vɪʜᴀɴ for the tips.

You should be able to use the r function instead of A(x)f(0), e.g. r(x)m(#

@Vɪʜᴀɴ Thanks. What does Array.dupe() do, it doesn't seem to work?

Array.dupe was probably a bad name, it removes duplicates from an array.

@Vɪʜᴀɴ You should put a summary of each method in the property names section with the input/output args. Also, Array.repeat and String.reverse would be nice too.

String.reverse is v, you don't need parenthesis for v either e.g. x.v.m(# works. An Array.repeat is also a great idea but unfortunately I haven't implemented that yet

You also have some unneeded . by removing them this can get to 76 bytes

by uncompressed do you mean ungolfed or actually decompressed?

@sysreq I meant ungolfed, sorry for the confusion.

Python 2, 117 bytes
a=b='i'
l=a,
exec"l+='_',b,;a,b=b,b+a;"*~-input()
for r in map(None,*l+l[::-1])[::-1]:print''.join(x or' 'for x in r)

The idea is simple: generate the picture in columns going bottom to top, left to right, with the mirrored right half the reverse of the left. The columns are generated by iterating the Fibonacci recurrence, on strings of i's, interspersed with _'s for the bottom row.
To print the picture with columns starting from the bottom, we need to rotate it, which means transposing and reversing. Unfortunately, Python doesn't have a simple way to transpose an array of unequal-length rows. The built-in zip truncates to the shortest row. This uses the map(None,_) trick, but has to convert all the None to spaces afterwards.

Haskell, 182 176 bytes
import Data.List
f=0:scanl(+)1f
b n c s|length s<n=b n c(c:s)|0<1=s
m s=s++reverse s
c n=mapM_ putStrLn$transpose$m$map(b(f!!n)' ')$intersperse"_"$map(\x->[1..f!!x]>>"i")[1..n]

Call c.
(f shamelessly stolen from https://stackoverflow.com/questions/232861/fibonacci-code-golf)

You can replace flip replicate 'i'.(f!!) by \x->[1..f!!x]>>"i".

Great, thanks! This is the first time I actually understand a monadic golfing tip, even though I don't come up with those myself yet. No clue as to how f works still...

Jelly, 23 bytes
RÆḞ”iẋz⁶Ḣj”_ƊṭK€Ṛ$Ɗm€0Y

Try it online!
Jelly's not great at ascii-art and neither am I
How it works
RÆḞ”iẋz⁶Ḣj”_ƊṭK€Ṛ$Ɗm€0Y - Main link. Takes N on the left
R                       - [1, 2, ..., N]
 ÆḞ                     - k'th Fibonacci for each k in the range
   ”i                   - "i"
     ẋ                  - Repeat "i" k times for each k
      z⁶                - Transpose filling with spaces
                  Ɗ     - To this matrix:
            Ɗ           -   First:
        Ḣ               -     Pop and yield the first element (the base)
         j”_            -     Join with "_"
                 $      -   Then:
              K€        -     Join the other rows on spaces
                Ṛ       -     Reverse
             ṭ          -   Take the base onto the end of the rows
                   m€0  - Mirror each row
                      Y - Join on newlines

Python 2, 213
Saved 12 bytes thanks to DSM.
def f(r):
 a=b=1
 while r:yield a;a,b=b,a+b;r-=1
n=list(f(input()))
n.remove(1)
h=max(n)-1
r=1
while h:
 l='  '*(len(n)+1)+('i '*r)[:-1];print(l+l[::-1]);h-=1
 if h in n:r+=1;n.pop()
l='i_'*r+'i_i'
print l+l[::-1]

Ungolfed version.
max_height = input()
def fib(r):
    a=b=1
    while r:
        yield a
        a,b = b, a + b
        r-=1

numbers = [x for x in fib(max_height) if x>1]
highest = max(numbers) -1
rows = 1
while highest:
    line =' '*((len(numbers)+1)*2) + ' '.join('i'*rows)
    print(line + line[::-1])
    highest -= 1
    if highest in numbers:
        rows += 1
        numbers.pop()

line = '_'.join('i'*(rows+2))
print(line + line[::-1])

Ruby, 151 146 142 137 132 bytes
->n{s=1,1;3.upto(n){s<<s[-1]+s[-2]};s.map!{|i|[' ']*(s[-1]-i)+[?i]*i}.transpose.map!{|a|v=a*'_ '[a.count(?i)<=>n];puts v+v.reverse}}

137 bytes
->n{s=1,1;3.upto(n){s<<s[-1]+s[-2]};o=s.map{|i|[' ']*(s[-1]-i)+[?i]*i}.transpose.map{|a|v=a*' ';v+v.reverse};o[-1]=o[-1].tr' ',?_;puts o}

142 bytes
->n{s=1,1;(3..n).map{s<<s[-1]+s[-2]};puts s.map{|i|[' ']*(s[-1]-i)+[?i]*i}.transpose.map{|a|v=a*' ';v+v.reverse}.tap{|c|c[-1]=c[-1].tr' ',?_}}

146 bytes
->n{s=1,1;(3..n).map{s<<s[-1]+s[-2]};puts s.map{|i|[' ']*(s[-1]-i)+[?i]*i}.transpose.map{|a|v=a.join' ';v+v.reverse}.tap{|c|c[-1]=c[-1].tr' ',?_}}

151 bytes
->n{s=1,1;(3..n).map{s<<s[-1]+s[-2]};puts s.map{|i|[' ']*(s[-1]-i)+['i']*i}.transpose.map{|a|v=a.join ' ';v+v.reverse}.tap{|c|c[-1]=c[-1].tr ' ', '_'}}

Ungolfed:
-> n {
  s = 1,1
  3.upto(n) {
    s << s[-1] + s[-2]
  }
  s.map! { |i|
    [' '] * (s[-1]-i) + [?i] * i
  }.
  transpose.
  map! { |a|
    v = a * '_ '[a.count(?i)<=>n]
    puts v + v.reverse
  }
}

Usage:
->n{s=1,1;3.upto(n){s<<s[-1]+s[-2]};s.map!{|i|[' ']*(s[-1]-i)+[?i]*i}.transpose.map!{|a|v=a*'_ '[a.count(?i)<=>n];puts v+v.reverse}}[8]

Output:
              ii
              ii
              ii
              ii
              ii
              ii
              ii
              ii
            i ii i
            i ii i
            i ii i
            i ii i
            i ii i
          i i ii i i
          i i ii i i
          i i ii i i
        i i i ii i i i
        i i i ii i i i
      i i i i ii i i i i
    i i i i i ii i i i i i
i_i_i_i_i_i_i_ii_i_i_i_i_i_i_i

Matlab, 172 152 bytes
Unfortunately, Matlab hasn't a build in Fibonacci function and string Manipulation is a bit fiddly.
function t(n);f=@(n)getfield([0 1;1 1]^n,{3});m=char(flipud(bsxfun(@(a,b)(a<=f(b/2)&mod(b,2)==0)*'i',(1:f(n))',2:2*n)));m(end,2:2:end)='_';[m fliplr(m)]

With line breaks:
function t(n);
f=@(n)getfield([0 1;1 1]^n,{3});
m=char(flipud(bsxfun(@(a,b)(a<=f(b/2)&mod(b,2)==0)*'i',(1:f(n))',2:2*n)));
m(end,2:2:end)='_';
[m fliplr(m)]

Vyxal, 21 bytes
v∆F\i*∩vṄṘøɽvm‡\_ḞuV⁋

Try it Online!
How?
v∆F\i*∩vṄṘøɽvm‡\_ḞuV⁋
v∆F                   # For each item in [1, implicit input], get the nth fibonacci number
   \i*                # For each, repeat that many "i"s
      ∩               # Transpose
       vṄ             # Join each by spaces
         Ṙ            # Reverse
          øɽ          # Prepend leading spaces to each to right-align it
            vm        # Mirror each
              ‡\_ḞuV  # To the last item, replace spaces with "_"
                    ⁋ # Join on newlines