Is that word Feminine or Masculine? Write a program or function that takes in a single string containing only lowercase a-z, and prints or returns a truthy value if the word is the feminine version of the thing it represents and a falsy value if it is the masculine version. For example, hen is the feminine version for chicken and rooster is the masculine version, so hen might produce 1 and rooster might produce 0.

Doing this for all English words that reflect gender would of course be way too unwieldy. Your program/function only needs to support 20 masculine/feminine pairs. Below are five sets of 10 masculine/feminine pairs, categorized by topic. Choose any two of the sets; the 20 total pairs in these two sets are the 40 words your program/function must work for.

(format is masculine_version feminine_version)

General

he she
him her
man woman
boy girl
male female
masculine feminine
guy gal
lad lass
mister miss
sir madam

Familial

father mother
dad mom
pa ma
son daughter
brother sister
husband wife
grandfather grandmother
grandpa grandma
uncle aunt
nephew niece

Animal

lion lioness
rooster hen
stallion mare
bull cow
drake duck
boar sow
buck doe
ram ewe
gander goose
billy nanny

Royal

king queen
prince princess
emperor empress
duke duchess
marquess marchioness
earl countess
baron baroness
baronet baronetess
lord lady
knight dame

Fantastical

wizard witch
giant giantess
incubus succubus
nidorino nidorina
nidoking nidoqueen
ents entwives
hanuvoite inimeite
centaur centaurides
merman mermaid
khal khaleesi

So, for example, you might choose the General and Familial categories. Then any input from he to sir or father to nephew would produce a falsy value, and any input from she to madam or mother to niece would produce a truthy value.

The values don't all have to be the same truthy/falsy type, e.g. he might produce 0 but sir might produce false. You may assume only the 40 specific lowercase a-z words from your two selected categories are ever input.

The shortest answer in bytes wins. Tiebreaker is earlier post.

(This challenge is not meant to correlate with or make statements about any current gender-based social issues.)

Retina, 26 bytes (sets 4, 5)

[^u]es|ee|m.i|y|^...c|d.*a

Retina is @MartinBüttner's regex language. I haven't used anything specific to .NET regexes, so you can test the regex at Regex101 here. Alternatively you can use Retina's grep G mode like so:

G`[^u]es|ee|m.i|y|^...c|d.*a

and pipe in a file with one word per line for batch testing.

Retina outputs the number of matches by default, giving us our truthy/falsy value. The rule "the values don't all have to be the same truthy/falsy type" is pretty important though since marchioness matches twice, giving an output of 2.

(Using the mod-chaining method from the previous male/female question seems to be shorter in CJam, but I'll let someone else do that)


Compose a song, line by line It's time for CGCC to demonstrate our musical talent! In this challenge, you're going to compose songs while keeping your byte count as small as possible.
On Day 0, multiple answerers will post a function or program that outputs nothing/an empty string. They will also give a single line that next day's answers must output. More lines will be added to that line later, gradually building up a song. I'm not starting off Day 0 myself because letting multiple people answer will allow for more variety later.
On Day 1, answerers will choose an answer from Day 0. They will post a function or program that outputs the line from the Day 0 answer. This will be the song for the next answer. Like on Day 0, Day 1 answerers will also give a single line that next day's answers must add anywhere to their song.
On Day i, answerers will choose an answer from Day i-1 with partial song s and line l. They can now insert l between any two lines in s or put it at the start or end of s. This will now yield a new partial song that each must write a function or program to output. Again, answerers will also give a line for next day's answers to add to their partial song.
Rules
The rules have been changed, please see the bolded parts below. Sorry for the inconvenience.

New lines can be put between other lines, at the start of the song, or at the end of the song.
Lines may be repeated.
Lines must be at least 20 characters and at most 100 characters.
You may have trailing spaces at the end of each line when printing the song.
You may have multiple answers on a single day and you may answer on consecutive days, but you cannot continue from your answer on a consecutive day.
This isn't a hard rule, but if you take your line from a song, please link to it.
The day changes at midnight UTC+0.
Your score is the average length, in bytes, of all your answers (not including answers on Day 0), divided by the number of answers you have posted (this is a change from before, but the objective is still the same - make your answer as short as possible).

It is currently Day 19.
Examples
Note: These examples are just to show the format of each answer; they are not good examples of the kinds of songs you should write, as they lack creativity.
Day 0. Python, 0 bytes

Try it online!
Line for next day: Superman got nothing on me (from One Call Away)
Song:

Day 1. Foobarbaz, 7 bytes
DOSTUFF

Try it online!
Previous answer
Line for next day: I can eat more bananas than him
Song:
Superman got nothing on me

Day 2. Foobarbaz, 11 bytes
DOMORESTUFF

Try it online!
Previous answer
Line for next day: And I'm never gonna give you up (modified from here)
Song:
Superman got nothing on me
I can eat more bananas than him

Day 3. somelanguage, 3 bytes
foo

Try it online!
Previous answer
Line for next day: That's the only thing that matters
Song:
Superman got nothing on me
I can eat more bananas than him
And I'm never gonna give you up

A possible song for day 4 (note that the new line was inserted this time instead of being appended):
Superman got nothing on me
I can eat more bananas than him
That's the only thing that matters
And I'm never gonna give you up

Day 0. Java (OpenJDK 8), 5 bytes

a->""

Try it online!
The line for tomorrow is Baka mitai kodomo na no ne.
thanks to caird for reminding me i don't need to submit a full program lol


Arranging Fenceposts If you want to build a fence and have different length boards available, there are many different ways to set up your posts. So, given a minimum and maximum board length, a number of boards, and the total length, count how many ways you can arrange them.

Input

Input is four positive integers:

min: The smallest board usable. Will be >0.
max: The largest board available. Will be >min.
count: Number of boards to use. Will be >0.
length: Total length of the fence. For a valid fence, this should be >=min*count and <=max*count

Individual boards can be any integer length between min and max (inclusive).

Output

Output a single number representing the number of ways you can arrange the fence.

Examples

For input (in order listed above) 2 3 4 10, you can arrange the boards six ways:

2233
2323
2332
3223
3232
3322

So the output is 6. If your input was 1 3 4 6, the output is 10, since there are ten ways to do it:

1113   1212
1131   1221
1311   2112
3111   2121
1122   2211

Input          Output
5 10 6 45      4332
1 100 6 302    1204782674
27 53 8 315    4899086560
1 10 11 70     2570003777
1 6 15 47      20114111295
4 8 150 600    1              // all boards length 4
1 10 100 80    0              // invalid, you can't put 100 boards in 80 length

Of course, there's a naive method to do this:

long f(int min, int max, int count, int length){
    if(count==1)
        return 1;
    long num = 0;
    for(int i=min;i<=max;i++){
        int goal = length - i;
        if(goal <= max*(count-1) && goal >= min*(count-1)){
            num += f(min,max,count-1,goal);
        }
    }
    return num;
}

Rules

The algorithm given above works fine for small inputs, but it can easily overflow the long with larger inputs. Even with arbitrary-length numbers, it's incredibly inefficient. I believe it's O((max-min+1)^count).

To be considered valid for this challenge, you should be able to compute input 1 10 100 700 in under one hour on my i7. Given a more efficient algorithm than the one above, this should not be a problem. I will test any entries I believe may come close to the limit. If your algorithm takes more than a few minutes to run, you should use a freely available language (on linux) to facilitate testing.

Code may take the form of a complete program or function, with input/output as any of the standard methods. Shortest code in bytes wins.

Ruby: 106 98 93 bytes
Update: Changed cache key type from strings to arrays. (-5)
Update:  Storing the initial condition in the cache payed out quite well. (-8)
However, it increases the runtime for the test case to roughly 2 seconds.
I simply use memoization. I guess it can be further golfed as my Ruby skills are far from perfect.
@m={[0,0]=>1}
def f(l,u,c,s)
  @m[[c,s]]||=s<0?0:(l..u).map{|x|f(l,u,c-1,s-x)}.reduce(:+)
end

Note that it runs for only one test case at a time, since I don't cache the min and max values (l and u, respectively). Here is my output for 1 10 100 700:
121130639107583774681451741625922964085713989291260198434849317132762403014516376282321342995

real    0m0.316s
user    0m0.312s
sys     0m0.004s


Determine the Base where a Given Equation is True Given 3 integers, determine the lowest possible base for the first two integers to multiply into the third. If you think of the Answer to the Ultimate Question of Life, The Universe, and Everything, 6 * 9 == 42, is true in Base 13.

The inputs can include any numbers whose digits use the characters 0-9, a-z, and A-Z, where a equals 10 in Base 10, and Z is 61 in Base 10.

The inputs should be inputted in any way you like (except for hard-coding), and you can write either an individual function or an entire program.

The maximum base that must be considered is Base 62, and the minimum base is Base 2.

You can assume that the first two values are smaller than the third. You can also conclude that the minimum base is one greater than the highest digit/character from the inputs (for example, if the inputs are 3 1a 55, the minimum base would be Base 11, because a is the highest digit).

If there is no such base, return a junk value of your choice.

This is code golf, so the shortest code wins.

Test Cases

6 9 42     -->   13
a a 64     -->   16
aA bB 36jk -->   41
2 3 20     -->   <junk value>
10 10 100  -->   2

APL (Dyalog Unicode), 30 bytesSBCS

⊢{3⊃e=×/2↑e←⍵⊥⍺:⍵⋄⍺∇⍵+1}1+⌈/∘,

Try it online!

Thanks to Adám for the help.

Explanation:

⊢{3⊃e=×/2↑e←⍵⊥⍺:⍵⋄⍺∇⍵+1}1+⌈/∘, ⍝
⊢                              ⍝ left argument ⍺: the vector (do nothing)
                        1+⌈/∘, ⍝ right argument ⍵: our starting base.
                             , ⍝             start by flattening the matrix of arguments                               ⌈/   ⍝             reduce by max (find the highest number)
                            ∘  ⍝             compose both of these together
                        1+     ⍝             increment by one
 {         ⍵⊥⍺         }       ⍝ convert inputs to the current base
 {       e←            }       ⍝ store the converted values in 3
 {      2↑             }       ⍝ take the first 2 values
 {    ×/               }       ⍝ multiply them together (reduce-multiply)
 {  e=                 }       ⍝ compare with e (the converted inputs)
 {3⊃                   }       ⍝ only keep the result of the comparison with the 3rd element (expected result)
 {             :⍵      }       ⍝ if truthy, return the current base.
 {               ⋄     }       ⍝ otherwise...
 {                ⍺∇⍵+1}       ⍝ ...recurse with the base incremented

We use a helper function, In, to receive the input into a more palatable format. Otherwise the input is received a matrix of 3 columns.

'3 9 42' would give, for example (read top-down then left-to-right):

0 0 4
3 9 2

And for 'aA bB 36jk' (same here. a is 10, b is 11, A is 36, etc)

 0  0  3
 0  0  6
10 11 19
36 37 20


Ways to arrange the integers 1 to 9 with operators so that the result is 100 Prelude:
This task is taken from Five Problems Every Software Engineer Should Be Able to Solve in Less Than an Hour, which I really recommend.
The task:

Write a program that outputs all possibilities to put + or - or
nothing between the numbers 1, 2, ..., 9 (in this order) such that the result is always 100.

Winning Criteria:
Shortest code in bytes wins.

Perl 5.10.0 - 50 46 45B

say for grep{eval==100}glob join'{,+,-}',1..9

Usage: perl -M5.10.0 scratch.pl (I think I get the version for free)


Asciimation Jumping Jacks This is my first challenge, so I'm keeping it fairly simple.

If you've ever typed telnet towel.blinkenlights.nl on your command line and pressed enter, you will have experienced the joy of asciimation. Asciimation is, quite simply, doing an animation with ascii art. Today we will be doing a very basic asciimation of a person doing jumping jacks.

There will be two ascii pictures that we will put together into one asciimation.
Number 1:

_o_
 0
/ \

Number 2:

\o/
_0_
<blank line>

Note that the second one has a blank line at the end.

So your program should do these steps:

Clear the console screen.
Print the correct ascii art image.
Set a flag or something so you know to do the other image next time.
Wait a moment (about a second).
Continue at 1.

Rules

Your program must be a (theoretically) infinite loop.
The programming language you use must have been created before this challange was posted.
This is code-golf, so shortest code in bytes wins.
Standard loopholes apply.

Enjoy!

CJam, 51 45 42 38 36 bytes

"c\o/
_0_""^[c_o_
 0
/ \^["{_o\6e4m!}g

The above uses caret notation; the sequence ^[ is actually the ASCII character with code point 27.

I've borrowed the escape sequence (^[c) from @DomHastings' answer (with his permission) to save 4 bytes.

Verification

You can recreate the file like this:

base64 -d > jj.cjam <<< ImNcby8KXzBfIiIbY19vXwogMAovIFwbIntfb1w2ZTRtIX1n

To run the code, download the CJam interpreter and execute this:

java -jar cjam-0.6.5.jar jj.cjam

This will work on any terminal that supports console_codes or an appropriate subset.1

How it works

e# Push both jumping jacks on the stack.

"c\o/
_0_"

"^[c_o_
 0
/ \^["

e# When chained together, they contain two occurrences of the string "\ec",
e# which resets the terminal. Encoding the ESC byte in the second string
e# eliminates the need two escape a backslash before the string terminator.

{         e# Do:
  _o      e#   Copy the jumping jack on top of the stack and print the copy.
  \       e#   Swap the order of the jumping jacks.
  6e4m!   e#   Calculate the factorial of 60,000 and discard the result.
          e#   This takes "about a second".
}g        e# Since the discarded factorial was non-zero, repeat the loop.

1 The jumping jacks will look better if you hide the terminal's cursor before running the program. In Konsole, e.g., you can set the cursor's color to match the background color. This has to be done via your terminal's settings, since ^[c resets the terminal.


Sum of multiples of powers of ten of an integer Write a function to produce, for a non-negative integer, a string containing a sum of terms according to the following:

3 -> "3"

805 -> "800 + 5"

700390 -> "700000 + 300 + 90"

0 -> "0"

13 -> "10 + 3"

200 -> "200"

Any input other than a non-negative integer can be ignored. Zero terms must be skipped unless the input is 0. Terms must go from largest to smallest. The plus signs must have only a single space on either side.

This is code golf; fewest number of bytes wins.

Jelly, 14 bytes

DḊƬḌINḟ0ȯ0j”+K

A full program which prints the result

Try it online!

How?

DḊƬḌINḟ0ȯ0j”+K - Main Link: integer, n       e.g. 805
D              - to base ten                      [8,0,5]
  Ƭ            - collect until a fixed point:
 Ḋ             -   dequeue                        [[8,0,5],[0,5],[5],[]]
   Ḍ           - from base ten (vectorises)       [ 805,    5,    5,  0]
    I          - incremental differences          [    -800,   0,   -5 ]
     N         - negate                           [     800,   0,    5 ]
      ḟ0       - filter discard zeros             [     800,         5 ]
        ȯ0     - OR zero (replacing an empty list with 0)
          j”+  - join with '+' characters         [     800,  '+',   5 ]
             K - join with space characters       [800,' ','+',' ',5]
               - implicit, smashing print         "800 + 5"


Convert all the newlines in a file from \r\n to \n Inspired by what I'm doing at work right now.
Your program should take one parameter, the path to the file
It should convert all the windows style newlines (\r\n) to unix style (\n) and write the result back to the file

APL (Dyalog Unicode), 22 bytes

Anonymous tacit prefix function.
10@3∘⎕NGET⎕NPUT{⍵1}

Try it online!
⎕NGET get content,encoding,line-ending from argument file
10@3∘ replace the third element (line ending) with 10, meaning \n
⎕NPUT put that into…
{⍵1} the file name followed by an overwrite flag


Write a hash function for Morse Code Your goal is to write a hash function, that accepts morse code character and returns a hash code that you get to define.

You can be sure, passed string will be:

One of the Latin characters (A-Z) encoded into Morse Code using . and -, or
One of the digits (0-9) encoded into Morse Code using . and -, or
Empty

So, there could be any of 37 different strings passed to you.

Requirements:

The returned number should be unique for all 37 strings
For empty string the function should return 0

Score:

Initially, you have a 100 points.
You will lose

1 point for every bitwise operator in your code
2 points for every addition (subtraction) operator in your code (operators in loop clauses (e.g. inside for(;;) or while() don't count)
4 points for every multiplication (division, modulo, etc) operator
6 points for every if (else) statement
8 points for every loop statement (including loops in the called functions. You can presume that any called function has no more than one loop)
12 points for every conditional operator
200 points for using a built-in hash function

Bonuses:

If all numbers, produced by your function are less than N, you will get additional 137 - N points (of course, if the bonus is positive)

Winners:

Score matters, but be creative!

Example:

Score: 100 - 5*2 - 3*4 - 8 + (137 - 134) = 73

I know, this could be improved by removing modulo operator and make a loop starts from 1, but this is just an example

#include <iostream>
#include <map>
#include <set>

std::size_t hash_morse(const std::string& s)
{
    std::size_t ans = 0;

    for(std::size_t i = 0; i < s.size(); ++i)
    {
        ans += (s.at(i) - '-' + 2) * (i + 1) * (i + 1);
    }

    return ans % 134;
}

int main()
{
    std::map<std::string, char> m
    {
        {"",     0},
        {".-",   'A'},
        {"-...", 'B'},
        {"-.-.", 'C'},
        {"-..",  'D'},
        {".",    'E'},
        {"..-.", 'F'},
        {"--.",  'G'},
        {"....", 'H'},
        {"..",   'I'},
        {".---", 'J'},
        {"-.-",  'K'},
        {".-..", 'L'},
        {"--",   'M'},
        {"-.",   'N'},
        {"---",  'O'},
        {".--.", 'P'},
        {"--.-", 'Q'},
        {".-.",  'R'},
        {"...",  'S'},
        {"-",    'T'},
        {"..-",  'U'},
        {"...-", 'V'},
        {".--",  'W'},
        {"-..-", 'X'},
        {"-.--", 'Y'},
        {"--..", 'Z'},

        {".----",    '1'},
        {"..---",    '2'},
        {"...--",    '3'},
        {"....-",    '4'},
        {".....",    '5'},
        {"-....",    '6'},
        {"--...",    '7'},
        {"---..",    '8'},
        {"----.",    '9'},
        {"-----",    '0'}
    };

    std::map<std::size_t, std::string> hashes;

    for(const auto& elem: m)
    {
        auto hash = hash_morse(elem.first);

        if(hashes.find(hash) != hashes.end())
        {
            std::cout << "Collision" << std::endl;
            std::cout << '"' << hashes[hash] << R"(" and ")" << elem.first << '"' << std::endl;
            std::cout << "Hash: " << hash << std::endl;
            std::cout << std::endl;
        }
        else
        {
            hashes[hash] = elem.first;
        }
    }

    std::cout << "Total amount of collisions: " << (m.size() - hashes.size()) << std::endl;

    return 0;
}

Arguably perfect score

There are some possible loopholes in the scoring system. In particular,

  8 points for every loop statement (including loops in the called functions. You can presume that any called function has no more than one loop)

According to PHP documentation,

  array() is a language construct used to represent literal arrays, and not a regular function.

So it's arguable that

$hash = array(
    '' => 0,
    '.-' => -1,
    ...
);
return $hash[$morse];

contains no called functions and should score a perfect 100 + (137 - 1) = 236 points.


Build the blancmange function The blancmange function is used as an example in basic calculus of a function that is continuous everywhere, but differentiable nowhere. It achieves this effect by using  the sums of ever-diminishing triangle-wave functions.

Your task is to build a program that takes a binary fractional number in the interval [0, 1] and returns the exact height of the blancmange curve at that position. Both fractions can be represented using the notation of your choice, but if you are using a nonstandard one (e.g. not IEEE floating-point or an integer with a fixed radix point), you must explain it in your solution, and your notation must support an accuracy of at least 2-52.

Ruby, 53 characters

f=->x{x>0?f[2*x=x<0.5?x:1-x]/2+x: 0}
$><<f[gets.to_f]

expanded:

f = lambda do |x|
  if i>0
    x = 1 - x unless x < 0.5
    return x + f[2*x] / 2
  else
    return 0
  end
end

print f[gets.to_f]

The input is a decimal value, assumed to be in the range 0..1 . The output is a decimal value. The platform native double precision numeric type is used, and is assumed to be at least 53 bits of mantissa. Since every floating point value in a binary fraction, this algorithm will always terminate after at most 53 (with the default precision) steps.


Piet (Mondrian)'s Puzzle For more information, watch this video, and go to A276523 for a related sequence.

The Mondrian Puzzle (for an integer n) is the following:

Fit non-congruent rectangles into a n*n square grid. What is the smallest difference possible between the largest and the smallest rectangle?

For 6, the optimal difference for M(6) is 5, and can be demonstrated like so:

 ___________
| |S|_______|
| | |   L   |
| |_|_______|
| |     |   |
| |_____|___|
|_|_________| (fig. I)

The largest rectangle (L) has an area of 2 * 4 = 8, and the smallest rectangle (S) has an area of 1 * 3 = 3. Therefore, the difference is 8 - 3 = 5.

Keep in mind that currently, no optimal solutions for n > 44 have been found.

Your task is to create a program that generates a Mondrian grid that contains a (non-optimal) solution, given an integer n.

You will be tested on the numbers from 100 to 150. Your score for each test will be the difference between the largest and smallest rectangle. Your total score is the sum of your scores for all the tests from 100 to 150.

You must present your output like so:

{number}
{grid}

Where number is the score (the difference between largest and smallest), and grid is either:

A multi-lined string, or
A two-dimensional list.

The grid MUST clearly show where a rectangle starts and ends.

Rules:

Your program must fit within your answer.
Your program must output a value for any number between 100 and 150 within 1 hour on a modern laptop.
Your program must generate the same solution for an integer n every time the program is run.
You must provide a link to the outputs of all 51 solutions (using Pastebin, Github Gist... anything, really).
You must have at least two rectangles on the square grid for your solution.

Piet, 9625

(It finally works!)

The people demanded it, so here it is. This is an extremely naive solution (essentially the same as the loose upper bounds on the OEIS page): it divides each square into just two rectangles.

This gist contains the details in two files:

The program's output (using npiet v1.3) for all required inputs. Note that I only captured stdout, so the ? is the input prompt, followed immediately by the output score, then the grid.
The "pseudo-assembly" source I used to plan out the program.

Explanation

This program takes a single number N as input. If the number is odd, the score is the number; if even, the score is twice the number.

After outputting the score, the rest of the left-hand side of the program is spent filling the stack with five lots of the following information:

The grid width (which is N)
A number of lines to print
A character to print across the grid (either _ or space)
A character to print at each edge of the grid (either space or |)

The right-hand side of the program takes each set of four values and prints out that part of the grid.


prepend,append-Sequence Task

The prepend,append-Sequence is defined recursively, like this

a(1) = 1
a(n) = a(n-1).n  , if n is even
a(n) = n.a(n-1)  , if n is odd

where the . represents an integer concatenation.

So the first few terms are: 1,12,312,3124,53124,531246,7531246,... This is A053064.

Your task is, given an integer a > 0 to return n, such that the nth element in the prepend,append-Sequence is equal to a and if no such n exists return 0, a negative number or error out etc.

Rules

Input can be taken as an integer, string, list of characters/digits etc.
Output can be printed to STDOUT or returned (integer, string etc. is fine)
On invalid input & in the case no such n exists your program may do anything but return a positive integer (eg. loop forever, return 0 etc.)
You may choose to use 0-indexing, but then the output in case no n exists cannot be 0

Test cases

1 -> 1
12 -> 2
21 -> 0
123 -> 0
312 -> 3
213 -> 0
211917151311975312468101214161820 -> 21
2119171513119753102468101214161820 -> 0
333129272523211917151311975312468101214161820222426283031 -> 0
999795939189878583817977757371696765636159575553514947454341393735333129272523211917151311975312468101214161820222426283032343638404244464850525456586062646668707274767880828486889092949698100 -> 100

C# (.NET Core), 83, 80, 60 59 bytes

n=>{int i=0;for(var t="";t!=n;)t=++i%2<1?t+i:i+t;return i;}

Try it online!

Takes the input as a string into a lambda function. 1-indexed. Returns the index of the value for truthy, or infitnitely loops for a "falsey"


Get the IP address of google.com Challenge
In this simple challenge, you have to print the public IP address of google.com.
Rules

You have to output either the IPv6 or IPv4 address, and do it by somehow using internet.

Output does not strictly need to be the IP address, your answer will be valid if the correct IP address is somewhere in the output, like Hello - google.com - 142.250.67.78 is a valid output.

You can use DNS queries and any kind of web APIs or web scraping.

Standard loopholes apply, except usage of URL shorteners, wanna see how creative you can get ;-)

This is code-golf, so the shortest answer wins!!

Zsh, 40 bytes

echo {0..255}.{0..255}.{0..255}.{0..255}

Try it online!
Since the output only needs to contain the IP address, we can just enumerate all of them! This probably isn't the shortest option, but it's funny!


Identify the compiler The challenge
You are given a function compile(s: String): Integer which returns 0 if s could be compiled and anything other than 0 if it failed (the resulting code is not important).

The thing is that you don't know for what language the function is made for, so it is up to you to figure that out by giving the function small snippets of code and observing what it returns. The good part is that a team of scientists have tried before you and have narrowed down the list to C, C++, C#, Java and JavaScript (these are the only widespread languages which have similar syntax I could think of).

Rules

General code-golf rules apply.
There is no strict output format; as long as it's readable and understandable it's ok.
If these 5 languages are not enough for you then you can add your own favourites and you'll be rewarded with extra stars (★) (that do nothing).

Note1: the compiler is up to date with the latest standard of whatever language it's designed for.
Note2: I know JavaScript does not compile, but it goes though some parsing process; if it's valid JavaScript code then it passes

Total snippet length 8; test program 83 (C)

Distinguish JavaScript and C from C++, Java, and C#

a;

Distinguish JavaScript from C

0

Distinguish C++ from C# and Java

#

Distinguish C# and Java

[:a]

C code to determine the language

#define C(x)compile(#x)?
main(){puts(C(a;)C(#)C([:a])"J":"C#":"C+":C(0)"C":"JS");}

Snippets tested with

C: gcc 4.7.2 with -std=c99
C++: g++ 4.7.2 with -std=c++11
Java: javac 1.7.0_09
JavaScript: JavaScript-C 1.8.5
C#: Mono C# compiler version 2.10.8.0


Complete a Tournament Bracket Your task is to create a program which outputs a completed tournament bracket given a list of entrants, their seeds, and their scores in each game; in the fewest characters possible.

Input

Your entrants will have the following data. You can organize your data in whatever form you like, but you cannot pre-sort your array or do any other pre-processing. The scores represent an entrant's score in each round, in other words they determine who moves on to the next round.

Example Input #1
[   {name: "James",         seed: 1,    scores: [12, 6,]}
,   {name: "Sarah",         seed: 4,    scores: [1, 16]}
,   {name: "Andre 3000",    seed: 3,    scores: [3000, 3000]}
,   {name: "Kim",           seed: 2,    scores: [20, 4]}
]

Example Input #2
[   {name: "Andy",  seed: 1,    scores: [1, 8, 4]}
,   {name: "Kate",  seed: 4,    scores: [1, 1, 8]}
,   {name: "Steve", seed: 3,    scores: [30, 1, 0]}
,   {name: "Linda", seed: 5,    scores: [4, 4, 5]}
,   {name: "Kyle",  seed: 2,    scores: [21, 0, 18]}
]

Output

Your output should resemble the examples below, and must follow these rules:

For each round in the tournament, the entrants are paired up and those pairs are output.
In the event of an odd entrant count, your program must account for and output byes. The entrant who gets the bye is the entrant who has been given the fewest bye weeks so far, and in the event of a tie, the best seed (1 is the best).
Pairing is based on the seed. Excluding byes, the best seed (1 is the best) is paired with the worst, the next best is paired with the next worst seed, etc.
The best seeds should be first in the pair, and at the top of the bracket.
The tournament champion should be output.

.

Example Output #1 (for input #1)
Round 1
James vs Sarah
Kim vs Andre 3000
Round 2
James vs Andre 3000
Champion
Andre 3000

Example Output #2 (for input #2)
Round 1
Kyle vs Linda
Steve vs Kate
Andy BYE
Round 2
Andy vs Steve
Kyle BYE
Round 3
Andy vs Kyle
Champion
Kyle

Extra props for anyone who codes a separate version of their program which prints an actual bracket.

Scoring

Assume input is correct, standard loopholes, etc and so forth. This is code golf, so fewest bytes win. In the event of a tie, most votes win. Good luck!

CJam, 156 151 144 bytes
q~0f+{{1=}$_,2%{{W=}$())+aa\{1=}$\}L?\_,2//)W%a+z\+_{0f=_,1={~" BYE"+a}*" vs "*N\}%"Round "U):U+\+\{{2=0=}$W=_2=(;2\t}%_W=2=}g~0=a"Champion"\]N*

This can definitely be golfed further.
The input is in an array of array format, like:
[["James" 1 [12 6 15]] ["Sarah" 4 [3 2 5]] ["Franko" 2 [20 1 5]] ["Max" 5 [22 10 7]] ["Arthur" 3 [20 15 20]]]

where each array element is the detail about the user in [name seed score_array] format
The output for the above input is:
Round 1
Franko vs Max
Arthur vs Sarah
James BYE
Round 2
James vs Max
Arthur BYE
Round 3
Arthur vs Max
Champion
Arthur

Try it online here


Return Spiral Indexes! Spirals are cool , so are numbers, and number spirals are even cooler. But what if I want a specific number, in a specific place using xy coordinates...

Challenge

Using an infinite spiral moving down first, curling in a counterclockwise manner

ex:

 6  5  4
 7  0  3
 8  1  2
 9 10 11

Take negative and positive inputs(integers) in the form of (x, y)
When given those coordinates return the number at that position in the spiral
The integer inputs must be the maximum that your language can use

ex:

 6  5  4
 7  0  3
 8  1  2
 9 10 11

input : (0,0)
output : 0

input : (1,1)
output : 4

input : (-1,-1)
output : 8

input : (5,5)
output : 100

input : (-5, -6)
output : 121

input : (2, -5)
output : 87

input : (-9, 2)
output : 349

input : (-7, 8)
output : 271

input : (-5, -7)
output : 170

Scores

This is a codegolf, so smallest code wins!!!

JavaScript (ES7), 50 bytes
This is using a slightly modified version of the formula that I've used and explained in this post.

x=>y=>(i=4*(x*x>y*y?x:y)**2)-(x<y||-1)*(i**.5-x-y)

Try it online!
or Try a version that displays the spiral.


Non-palindromic numbers A strictly non-palindromic number N is a number that isn't a palindrome in any base (in bases 2 to N-2).  These numbers are listed on OEIS
For example, the number 19 in base 2,3,4,5,6,...17 is: 10011,201,103,34,31,...12.  None of these representations is palindromic, so the number is strictly non-palindromic.
For this challenge, you need to return a truthy value if the number is non-palindromic, otherwise a falsy value.

You may assume the number passed to you is greater than or equal to 0.
Your program should work for values up to your languages' integer size.

Test cases:
Truthy:
0
1
2
3
4
6
11
19
47
53
79
103
389
997
1459

Falsy:
5
7
8
9
10
13
16
43
48
61
62
101
113
211
1361

This is a code-golf, so make your answers as short as possible!

C, 82 bytes

p(n,a,b,c,r){c=0;for(b=1;++b<n-2;c+=r==n)for(a=n,r=0;a>0;a/=b)r=r*b+a%b;return!c;}

Ideone it!

Explanation

This code reverses n in base b and stores in r:

for(a=n,r=0;a>0;a/=b)r=r*b+a%b;

The outer loop counts the number of bases from 2 to n-1 in which n is a palindrome.

If n is non-palindromic, the count would be 1 (n must be a palindrome in base n-1).


Fabricate Frequently Factored Functions In  one of this question's bonuses I asked you to design a permutation on the natural numbers such that the probability of a random term being odd was \$1\$.  Now let's kick it up a notch.  I want you to design and implement a permutation, \$f\$, on the natural numbers such that, for every integer \$n\$ greater than 0, the probability on \$f\$ of a member being divisible by \$n\$ is \$1\$.

Definition of Probability

To avoid confusion or ambiguity I am going to clearly lay out what is meant by probability in this question.  This is adapted directly from my original question.

Let us say we have a function \$f\$ and a predicate \$P\$.  The probability of a number fulfilling \$P\$ will be defined as the limit of the number of members of \$f\{1..n\}\$ fulfilling the predicate \$P\$ divided by \$n\$.

Here it is in a nice Latex formula

$$
  \lim_{n\to\infty} \dfrac{\left|\left\{x : x\in \left\{1\dots n\right\}\right\},P(f(x))\right|}{n}
$$

In order to have a probability of something being \$1\$ you don't need every member to satisfy the predicate, you just need the ones that don't to get farther apart the bigger they are.

This is code-golf so answers will be scored in bytes with less bytes being better.

You may take the natural numbers to either include or exclude 0.  Both are fine.

Husk, 11 bytes

!uΣz:NCNmΠN

Try it online! Or showing the stats for the first 100 n in the first 5000 terms

Explanation

        mΠ     Map factorial over
          N    the Natural numbers
      CN       Cut into lists of lengths corresponding to the natural numbers
   z:N         ZipWith append the natural numbers and ^
  Σ            Concatenate into one list
 u             Remove duplicates
!              Index

Proof (Without the u)

For triangle numbers : f(½n*(n+1))=n

Otherwise : f(n)=k! for some k.

As the density of triangular numbers is zero, this has the same probability as the sequence of factorials: 1


Shortest way to generate 12 repeated characters in JavaScript '---------'
'-'.repeat(9) // longer!

'------------'
(x='----')+x+x
'-'.repeat(12) // same length

Is there any cleverer way of generating strings of 12 repeated characters in JavaScript?

Unfortunately, after what seems an eternity of searching documentation, I can't seem find any solution that will work with the 12-character constraint and generate for any given character given. However, there are a few neat tricks one can do to save some bytes for specific cases:

1eL-1+'' will give a string, filled with 9s, of L length.

''.padEnd(L) will give a string, filled with spaces, of L length. It's only useful when L > 10, otherwise it's too long. This one can be immediately chained with a function.

N/9+'' will give a string, starting with 0. then followed by a bunch of Ns. This does not work when N < 1 or N > 8, and the result obviously does not contain the same characters the whole way, but pretty close and pretty short.

Array(L)+'' will give a string, filled with commas, of length L - 1.


A Spintax {Task|Problem|Question} Article Spinning with Spintax

Article spinning is a search engine optimization technique by which search engine optimizers post a unique version of relevant content on article directories, web 2.0 sites, or other sources for backlinks.

It is occasionally used by website authors on their own sites but usually avoided because the quality of spun content will be lower than hand written content. Spinning works by rewriting existing articles, or parts of articles, and replacing specific words, phrases, sentences, or even entire paragraphs with any number of alternate versions to provide a slightly different variation with each spin.

This process can be completely automated or rewritten manually. Your job today will be to create a program or function which interprets a string containing Spintax, the syntax by which a program would read the different options available. Below is an example string that uses Spintax:

{Hello|Hi there|Bonjour}, user! {What's up?|How are you?|Feeling alright?|I caught a fish!}

As you can see, sections of the string that are to be 'spun' are enclosed in curly braces, where individual options are split by the | character. Here are some example sentences this could produce.

Hi there, user! What's up?
Hello, user! How are you?
Bonjour, user! Feeling alright?
Hello, user! What's up?
Hi there, user! I caught a fish!

Your Job

Your mission, should you choose to accept it, is to create a program or function which takes an input string that may or may not contain Spintax, then print 5 versions of the string, randomly selecting one of the choices from each block of options. You can make a few assumptions:

You will not need to handle nested Spintax ({This|is {an|one}|example}).
The |,{ and } characters will not occur anywhere else other than within a Spintax block.
You do not need to check if the 5 output sentences are distinct, as long as the code selects options using your language's random number function.
You may assume the input ends with a newline.

Rules

No standard loopholes.

Tests

1. {A|The|One} {quick|magnificent|charming|lucky|fast|super|cool} {gold|tan|yellow|white|brown|silver} {beaver|packrat|cat|lion|tiger|fox|dog|wolf} {consumed|ate|pilfered} my {pastry|strudel|cake}.
-------------------------------------------
One cool brown wolf consumed my pastry.
...(3 more here)...
The charming yellow beaver ate my cake.
-------------------------------------------
2. This sentence is valid, and happens to have no Spintax!
-------------------------------------------
This sentence is valid, and happens to have no Spintax!
...(3 more here)...
This sentence is valid, and happens to have no Spintax!
-------------------------------------------
3. {beg|get|ton|sun|bun|can|top|big}{2|3|4|5}{A|B|C|D|E|F|G}{2|3|4|5|6|7}{at|as|be|ex|hi|}{!|#|%}
-------------------------------------------
top2F2hi%
...(3 more here)...
big3E4ex#

A fourth test can be found here.

This is code-golf, so fewest number of bytes wins.

Pyth, 18
V5sOMcR\|scR\{cz\}

Try it online here
Explanation:
V5sOMcR\|scR\{cz\}                     : z = input()
V5                                     : do this 5 times
              cz\}                     : split z on the } character
          cR\{                         : split each element of the resulting list on {
         s                             : join the list of lists back into a list of strings
     cR\|                              : split these strings on the | character
   OM                                  : Choose a random element from each inner list
  s                                    : join those choices, and print them


Write a word equation solver Introduction

Consider the following example:

  CODE
+ GOLF
——————
 GREAT

This is an equation where each letter represents a decimal digit and the words represent natural numbers (similar letters represent similar digits and different letters represent different digits). The task is to match each letter with its digit value so that the equation is correct. One solution for the equation above is:

  9265
+ 1278
——————
 10543

Your task

Your task is to write a program or a function which can solve such equations as seen above.

Input

The input is a string in the following format:

[A-Z]+\+[A-Z]+=[A-Z]+

Example:

CODE+GOLF=GREAT
AA+BB=CC

Spaces are omitted and only letters between capital A and Z will be used (no special or small letters).

This string can be read from the standard input, from a file, or as a function parameter.

Output

You have the following two options for the output format:

the original equation with the digits substituted
list of the letters and their values

If there are multiple solutions, any (but only one) of them should be returned. If there are no solutions, the program should return an empty string or null.
The output can be returned as a string, can be written to the standard output or a file.

Example:

9265+1278=10543
A=1 B=2 C=3 (you can use any delimiter)

Rules

To make things easier, numbers are accepted to start with 0, but you can handle numbers with leading 0 as invalid solutions, it's up to you
Similar letters represent similar digits and different letters represent different digits
You can use any language and the standard library of the chosen language (no external libs)
You cannot connect to any resources on the internet (why would you anyways?)
This is a code golf task, shortest code wins. Consecutive whitespace characters count as a single character. (So any program written in whitespace automatically wins)

I have a somewhat hackish solution using 179 chars. If something is not clear, please ask me in the comments.

Python - 48 characters

exec("".join(map(chr,map(len,'                                                                                '.split("    ")))))

Abusing the whitespace rule.

First I converted every character in CesiumLifeJacket's answer to its ASCII value (I could have written my own but I am lazy, and it wouldn't have affected the final score anyway). The long string in my solution is one space for each one of those ASCII values, and tabs separating them. Split at tabs, find the lengths, convert back to characters and execute.

SE converts tabs to 4 spaces each, so copypasting won't work. You'll just have to believe me :)


Symbolic Differentiation of Polynomials Symbolic Differentiation 1: Gone Coefishin'

Task

Write a program that takes in a polynomial in x from stdin (1 < deg(p) < 128) and differentiates it. The input polynomial will be a string of the following form:

"a + bx + cx^2 + dx^3 +" ...

where the coefficient of each term is an integer (-128 < a < 128). Each term is separated by one space, a +, and another space; linear and constant terms appear as above (i.e., no x^0 or x^1). Terms will appear in order of increasing degree, and those powers with zero coefficient are omitted. All terms with coefficient 1 or -1 display that coefficient explicitly.

Your output must have precisely the same form. Note that coefficients in the output might be as big as 127*127 == 16129.

Examples

"3 + 1x + 2x^2" ==> "1 + 4x"
"1 + 2x + -3x^2 + 17x^17 + -1x^107" ==> "2 + -6x + 289x^16 + -107x^106"
"17x + 1x^2" ==> "17 + 2x"

Scoring

Your score is the length of your program in bytes, multiplied by three if you use a built-in or a library that does symbolic algebra.

Retina, 53 43 42 41 40 35 bytes

^[^x]+ |(\^1)?\w(?=1*x.(1+)| |$)
$2

For counting purposes each line goes in a separate file, but you can run the above as a single file by invoking Retina with the -s flag.

This expects the numbers in the input string to be given in unary and will yield output in the same format. E.g.

1 + 11x + -111x^11 + 11x^111 + -1x^11111
-->
11 + -111111x + 111111x^11 + -11111x^1111

instead of

1 + 2x + -3x^2 + 2x^3 + -1x^5
-->
2 + -6x + 6x^2 + -5x^4

Explanation

The code describes a single regex substitution, which is basically 4 substitutions compressed into one. Note that only one of the branches will fill group $2 so if any of the other three match, the match will simply be deleted from the string. So we can look at the four different cases separately:

^[^x]+<space>
<empty>

If it's possible to reach a space from the beginning of the string without encountering an x that means the first term is the constant term and we delete it. Due to the greediness of +, this will also match the plus and the second space after the constant term. If there is no constant term, this part will simply never match.

x(?= )
<empty>

This matches an x which is followed by a space, i.e. the x of the linear term (if it exists), and removes it. We can be sure that there's a space after it, because the degree of the polynomial is always at least 2.

1(?=1*x.(1+))
$1

This performs the multiplication of the coefficient by the exponent. This matches a single 1 in the coefficient and replaces it by the entire corresponding exponent via the lookahead.

(\^1)?1(?= |$)
<empty>

This reduces all remaining exponents by matching the trailing 1 (ensured by the lookahead). If it's possible to match ^11 (and a word boundary) we remove that instead, which takes care of displaying the linear term correctly.

For the compression, we notice that most of the conditions don't affect each other. (\^1)? won't match if the lookahead in the third case is true, so we can put those two together as

(\^1)?1(?=1*x.(1+)| |$)
$2

Now we already have the lookahead needed for the second case and the others can never be true when matching x, so we can simply generalise the 1 to a \w:

(\^1)?\w(?=1*x.(1+)| |$)
$2

The first case doesn't really have anything in common with the others, so we keep it separate.


Find primitive semiperfect numbers Semiperfect numbers

A semiperfect/pseudoperfect number is an integer equal to the sum of a part of or all of its divisors (excluding itself). Numbers which are equal to the sum of all of their divisors are perfect.

Divisors of 6 : 1,2,3
      6 = 1+2+3 -> semiperfect (perfect)
Divisors of 28 : 1,2,4,7,14
      28 = 14+7+4+2+1 -> semiperfect (perfect)
Divisors of 40 : 1,2,4,5,8,10,20
      40 = 1+4+5+10+20 or 2+8+10+20 -> semiperfect

Primitive

A primitive semiperfect number is a semiperfect number with no semiperfect divisors (except itself :))

Divisors of 6 : 1,2,3
      6  = 1+2+3 -> primitive
Divisors of 12 : 1,2,3,4,6
      12 = 2+4+6 -> semiperfect

As references, please use the OEIS series A006036 for primitive semiperfect numbers, and A005835 for semiperfects.

Goal

Write a program or a function in any language.
It will take as input a number n as a function parameter or from STDIN/your language's closest alternative, and will output all the primitive semi-perfect numbers from 1 to n (inclusive).

The output must be formated as 6[separator]20[separator]28[separator]88... where [separator] is either as newline, a space or a comma. There must not be a starting [separator] nor a ending one.

Edit : you can leave a trailing newline

Examples

input :

5

output :

input :

20

output :

6
20

input :

100

output :

6 20 28 88

Scoring

This is code-golf, so the shortest code in bytes win.

Don't try to fool us with loopholes please :).

I'd be glad you could leave an explanation of your golfed code once you think you're done golfing it!

As this challenge already have some nice answers, and is slowly getting quiet, I'll put an end to it. The winner of this code-golf will be decided on Monday 29th, 00:00 GMT. Well done to all of you that have answered, and good luck to those who will try to beat them :)

Pyth, 28 27 bytes

VQI}KhNsMyJf!%KTSNI!@JYeaYK

1 byte thanks to @Jakube

Demonstration.

VQI}KhNsMyJf!%KTSNI!@JYeaYK
                                Implicit:
                                Y = []
                                Q = eval(input())
VQ                              for N in range(Q):
    KhN                         K = N+1
           f    SN              filter T over range(1, N)
            !%KT                the logical not of K%T.
                                This is the list of divisors of K.
          J                     Store the list in J.
         y                      Create all of its subsets.
       sM                       Map each subset to its sum.
  I}K                           If K is in that list: (If K is semiperfect)
                  I!@JY         If the intersection of J (the divisors)
                                and Y (the list of primitive semiperfect numbers)
                                is empty:
                        aYK     Append K to Y
                       e        And print its last element, K.


The very weird word counter INPUT: Any string consisting exclusively of lowercase letters via function argument, command line argument, STDIN, or similar.

OUTPUT: Print or return a number that will represent the sum of the distances of the letters according to the following metric:

You take the first and second letter and count the distance between them. The distance is defined by the QWERTY keyboard layout, where every adjacent letter in the same row has distance 1 and every adjacent letter in the same column has distance 2. To measure the distance between letters that aren't adjacent, you take the shortest path between the two.

Examples:

q->w is 1 distance apart
q->e is 2 distance
q->a is 2 distance
q->s is 3 distance (q->a->s or q->w->s)
q->m is 10 distance

Then you take the second and third letter, then the third and fourth, etc., until you reach the end of the input. The output is the sum of all those distances.

Example input and output:

INPUT: qwer
OUTPUT: 3

INPUT: qsx
OUTPUT: 5

INPUT: qmq
OUTPUT: 20

INPUT: tttt
OUTPUT: 0

Here is an image showing which letters are in the same column:

This is code golf, so the shortest code in bytes wins!

Python 2, 220 ... 124 119 Bytes

Huge thanks to Sp3000 for saving a lot of bytes.

f='qwertyuiopasdfghjkl zxcvbnm'.find
g=lambda i:sum(abs(f(x)%10-f(y)%10)+2*abs(f(x)/10-f(y)/10)for x,y in zip(i,i[1:]))

Usage:

g("tttt") -> 0

Check it out here.

Slightly ungolfed + explanation:

f='qwertyuiopasdfghjkl zxcvbnm'.find  # Defining keyboard rows and aliasing find
g=lambda i:                           # Defining a function g which takes variable i
    sum(                              # Sum of
        abs(f(x)%10-f(y)%10)          # horizontal distance, and
        + 2*abs(f(x)/10-f(y)/10)      # vertical distance,
        for x,y in zip(i,i[1:]))      # for each pair in the zipped list

# Example of zipping for those unaware:
# Let i = asksis, therefore i[1:] = sksis, and zip would make
# the list of pairs [(a,s),(s,k),(k,s),(s,i),(i,s)].


Calculate the volume of an object You can determine the volume of objects based on a given set of dimensions:

The volume of a sphere can be determined using a single number, the radius (r)
The volume of a cylinder can be determined using two numbers, the radius (r) and the height (h)
The volume of a box can be determined using three numbers, the length (l), width (w) and the height (h)
The volume of an irregular triangular pyramid can be determined using four numbers, the side lengths (a, b, c)  and the height (h).

The challenge is to determine the volume of an object given one of the following inputs:

A single number (r) or (r, 0, 0, 0) => V = 4/3*pi*r^3
Two numbers (r, h) or (r, h, 0, 0) => V = pi*r^2*h
Three numbers (l, w, h) or (l, w, h, 0) => V = l*w*h
Four numbers (a, b, c, h) => V = (1/3)*A*h, where A is given by Heron's formula: A = 1/4*sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c))

Rules and clarifications:

The input can be both integers and/or decimals
You can assume all input dimensions will be positive
If Pi is hard coded it must be accurate up to: 3.14159.
The output must have at least 6 significant digits, except for numbers that can be accurately represented with fewer digits. You can output 3/4 as 0.75, but 4/3 must be 1.33333 (more digits are OK)

How to round inaccurate values is optional

Behaviour for invalid input is undefined
Standard rules for I/O. The input can be list or separate arguments

This is code golf, so the shortest solution in bytes win.

Test cases:

calc_vol(4)
ans =  268.082573106329

calc_vol(5.5, 2.23)
ans =  211.923986429533

calc_vol(3.5, 4, 5)
ans =  70

calc_vol(4, 13, 15, 3)
ans =  24

Related, but different.

Vitsy, 49 bytes

I thought you handed this one to me on a plate, but I found an unresolved bug to work around. Didn't hurt me, though.

lmN
3^43/*P*
2^*P*
**
v:++2/uV3\[V}-]V3\*12/^v*3/

Basically, with the input being a certain length for different functions, you spoon feed me my method syntax for doing this stuff. So, yay, success!

Explanation, one line at a time:

lmN
l   Get the length of the stack.
 m  Go to the line index specified by the top item of the stack (the length).
  N Output as a number.

3^43/*P*
3^
          Put to the power of 3.
  43/*    Multiply by 4/3.
      P*  Multiply by π

2^*P*
2^     Put to the second power.
  *    Multiply the top two items.
   P*  Multiply by π

**
**     Multiply the top three items of the stack.

v:++2/uV3\[V}-]V3\*12/^v*3/
v                            Save the top item as a temp variable.
 :                           Duplicate the stack.
  ++                         Sum the top three values.
    2/                       Divide by two.
      u                      Flatten the top stack to the second to top.
       V                     Capture the top item of the stack (semiperimeter)
                             as a permanent variable.
        3\[   ]              Do the stuff in the brackets 3 times.
           V}-               Subtract the semiperimeter by each item.
               V             Push the global var again.
                3\*          Multiply the top 4 items.
                   12/^      Square root.
                       v*    Multiply by the temp var (the depth)
                         3/  Divide by three.

Input is accepted as command line arguments in the exact reverse as they appear in the question, with no trailing zeroes.

Try it online!

As an aside, here's something that's currently in development.

Java w/ Vitsy Package

Note that this package is work in progress; this is just to show how this will work in the future (documentation for this is not yet uploaded) and it is not golfed, and is a literal translation:

import com.VTC.vitsy;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;

public class Volume {
    public static void main(String[] args) {
        Vitsy vitsyObj = new Vitsy(false, true);
        vitsyObj.addMethod(new Vitsy.Method() {
            public void execute() {
                vitsyObj.pushStackLength();
                vitsyObj.callMethod();
                vitsyObj.outputTopAsNum();
            }
        });
        vitsyObj.addMethod(new Vitsy.Method() {
            public void execute() {
                vitsyObj.push(new BigDecimal(3));
                vitsyObj.powerTopTwo();
                vitsyObj.push(new BigDecimal(4));
                vitsyObj.push(new BigDecimal(3));
                vitsyObj.divideTopTwo();
                vitsyObj.multiplyTopTwo();
                vitsyObj.pushpi();
                vitsyObj.multiplyTopTwo();
            }
        });
        vitsyObj.addMethod(new Vitsy.Method() {
            public void execute() {
                vitsyObj.push(new BigDecimal(2));
                vitsyObj.powerTopTwo();
                vitsyObj.multiplyTopTwo();
                vitsyObj.pushpi();
                vitsyObj.multiplyTopTwo();
            }
        });
        vitsyObj.addMethod(new Vitsy.Method() {
            public void execute() {
                vitsyObj.multiplyTopTwo();
                vitsyObj.multiplyTopTwo();
            }
        });
        vitsyObj.addMethod(new Vitsy.Method() {
            public void execute() {
                vitsyObj.tempVar();
                vitsyObj.cloneStack();
                vitsyObj.addTopTwo();
                vitsyObj.addTopTwo();
                vitsyObj.push(new BigDecimal(2));
                vitsyObj.divideTopTwo();
                vitsyObj.flatten();
                vitsyObj.globalVar();
                vitsyObj.push(new BigDecimal(3));
                vitsyObj.repeat(new Vitsy.Block() {
                    public void execute() {
                        vitsyObj.globalVar();
                        vitsyObj.rotateRight();
                        vitsyObj.subtract();
                    }
                });
                vitsyObj.globalVar();
                vitsyObj.push(new BigDecimal(3));
                vitsyObj.repeat(new Vitsy.Block() {
                    public void execute() {
                        vitsyObj.multiplyTopTwo();
                    }
                });
                vitsyObj.push(new BigDecimal(1));
                vitsyObj.push(new BigDecimal(2));
                vitsyObj.divideTopTwo();
                vitsyObj.powerTopTwo();
                vitsyObj.tempVar();
                vitsyObj.multiplyTopTwo();
                vitsyObj.push(new BigDecimal(3));
                vitsyObj.divideTopTwo();
            }
        });
        vitsyObj.run(new ArrayList(Arrays.asList(args)));
    }
}


Automate Saving the World You are Desmond Hume. For the last 3 years, you and your partner, Kelvin, have been slave to a computer that requires a very specific sequence to be entered into it every 108 minutes to save the world.

4 8 15 16 23 42

Your partner died 40 days ago (due to an unfortunate accident involving Kelvin's head and a big rock), and you have no one to talk to. No one to enter the numbers for you. No one to break the monotony. At first it wasn't too bad, but you can't handle the silence anymore. And if you have to listen to "Make Your Own Kind Of Music" one more time, you're going to scream.

You decide that You need to get out. To escape. You decide that you will build a raft and sail off the island. But then you realize the bad news: you're stuck here. You need to keep saving the world.

But then you realize the good news: You are a programmer! You can automate saving the world! Excited, you run over to the computer, and, using your trusty python skills, you whip up a quick script to enter the numbers for you.

import time

while True:
    print "4 8 15 16 23 42"
    time.sleep(60 * 107)

Quick, simple, reliable, short, and easy. Everything that a good python script should be. But then, when you try to test it, you get an error.

Bad command or file name.

Huh, strange. Oh well, let's try c++.

#include <iostream>
#include <unistd.h>

int main()
{
    while (true)
    {
        std::cout << "4 8 15 16 23 42" << std::endl;
        sleep(60 * 107);
    }
}

No! C++ isn't found either. You try every language you can think of. Javascript, Ruby, Perl, PHP, C#. Nothing. This computer was made before all of the popular languages of the day.

The Challenge

You must write a program that will:

1) Print exactly this: "4 8 15 16 23 42" (without quotes)

2) Wait some time between 104 and 108 minutes. (According to The Lost Wiki)

3) Repeat forever. (Or until you realize that this is all an elaborate scam, and that you're stuck in a weird limbo due to lazy writing, and asking questions that you don't have answers for. Thanks JJ Abrams!)

However there is a catch: You MUST use a language that the computer in the swan station would actually be capable of running. Assuming that

A) The computer was up to date at the time of construction,

B) There have been no updates to the computers software, and

C) There is no internet connection available (Meaning you can't download Golfscript...),

and making our best guess for the construction date of The Swan Station, (Again, The Lost Wiki.)

This means you have to use a language that was first released on or before Dec 31, 1977.

A few rule clarifications:

Including libraries is OK, but the same rule applies (libraries must be pre-1977).
You do not have to worry about  OS compatibility.
If you use system, or your languages equivalent, you must prove that any system commands you use would have been available before 1978. A wikipedia article is probably the best way to prove this.
It doesn't matter when you start the program, just as long as it ends up in a pattern of alternating printing and sleeping. (print-sleep-print-sleep... and sleep-print-sleep-print... are both acceptable.)

This is Code-Golf, so shortest answer in bytes wins.

MUMPS - 30 characters,  circa 1966 (ANSI standard first in 1977)

My first attempt at code golf, here we go!

f  w "4 8 15 16 23 42" h 6420

MUMPS is still a popular language for EHR software, created by Massachusetts General Hospital in Boston. Most known implementation is Epic Systems in Verona, WI.


Finding Symmetries in Squares Write a program or function that takes in a list of positive integers. Each of these integers represents the side length of a square on a 2D plane. Each square can be moved to any integer coordinates in the plane, but it can't rotate and it can't overlap other squares.

Using a different printable ASCII character for each square (excluding space which is used for emptiness) your program/function needs to print any single arrangement of the squares that has a horizontal or vertical line of reflectional symmetry. If no such arrangement exists then nothing should be printed.

The squares are different characters just so they can be told apart. Only the shape made by the union of all the squares needs to be symmetrical. You can assume the list will not contain more than 94 elements (as there are 94 characters).

For example, if the input was [2, 1, 2, 2, 2], a possible output is:

DD--
DD--
Z
FFPP
FFPP

This shape has a horizontal line of reflectional symmetry; its top and bottom halves are mirror images. Here are some other possibilities: (Note that the squares don't need to touch and any characters can be used as long as no two squares are made of the same character.)

  55
  55
  %%
  %%
@
  HH
  HH
  ((
  ((

       G

     11 33
     11 33

    22   44
    22   44

The line of symmetry could also be the boundary between characters, e.g. for [2, 4]:

!!!!
!!!!  ++
!!!!  ++
!!!!

Some sets of squares are impossible to arrange symmetrically, e.g. [1, 2, 3]:

AAA BB C
AAA BB         (these can't be vertically or horizontally symmetric => no output)
AAA

And remember that the overall shape may be symmetric even if the square boundaries aren't. e.g. a valid output for [2, 1, 1, 1, 1, 4] is:

AA----
AA----
BC----
DE----

Similarly, a valid output for [1, 1, 2, 3, 5] is:

44444
44444
44444
44444
44444
33301
33322
33322

Notes

The input list will always have from 1 to 94 elements.
Take input in any reasonable way: stdin, command line, text file, function arg. It can be slightly formatted to suit your needs, e.g. {1, 2, 3, 4} or [1 2 3 4].
Output to stdout or similar. Any amounts of leading/trailing spaces or newlines are fine as long as the resulting shape has the line of symmetry.
A diagonal line of symmetry does not count (else this would be super easy). Also, it has to be reflectional symmetry, not rotational or transitional.
I'm honestly not sure how computationally difficult this task is. You may post partial answers that solve some subset of the problem (especially if you want to show off a particularly clever algorithm). These are not eligible to win.

For example, you might assume that the input always has at least one symmetrical arrangement (so lists like [1, 2, 3] are never input).
Or, for example, you may only consider arrangements where the square boundaries, as well as the overall shape, are symmetrical. In this case, [1, 1, 2, 3, 5] would have no output.
If you want to go crazy, you could extend the idea to rectangles or even polyominoes.

Scoring

Your score is the size of your program in bytes. The lowest score wins. Tiebreaker goes the the answer posted first.

Python 2, 460 452 437 bytes

exec"""def f(L):
 if[]==L:
  X{2}[map(" ".__lt__,q)for q in G]);Z{2}zip(*X));C=Z==Z[::-1]or X==X[::-1]
  if C:print"\\n".join(map("".join,G))
  return C
 x=L[-1];T=S-x+1;R=range(x)
 for n in range(T*T):
  i=n%T;j=n/T
  if all({1}=" "{0}):
{0}:{1}chr(32+len(L))
   r=f(L[:-1])
{0}:{1}" "
   if r:return r""".format("   for a,b in[(a,b)for a in R for b in R]","G[i+a][j+b]=","=filter(sum,")
L=input()
S=sum(L)
G=[S*[" "]for _ in[0]*S]
f(L)

Only mildly golfed for now, but here's something to get things started. I tried using exec for lines 10 and 12, but for some reason it didn't let me.

Input the list L via STDIN, e.g. [2, 1, 2, 2, 2]. The program simply tries every possibility of placing squares in a sum(L) x sum(L) grid.

Sample output (blank lines removed for compactness):

[2, 1, 2, 2, 2]

%%
%%
$$
$$
"
##
##
!!
!!

[2, 4]

""""
""""
""""
""""
 !!
 !!

[2, 1, 1, 1]

$!!
#!!
 "

[1, 1, 2, 3, 5]

%%%%%
%%%%%
%%%%%
%%%%%
%%%%%
$$$##
$$$##
$$$"!

[1, 4, 1, 8]

$$$$$$$$
$$$$$$$$
$$$$$$$$
$$$$$$$$
$$$$$$$$
$$$$$$$$
$$$$$$$$
$$$$$$$$
# """" !
  """"
  """"
  """"

[8, 1, 4, 1]

$   !!!!!!!!
    !!!!!!!!
####!!!!!!!!
####!!!!!!!!
####!!!!!!!!
####!!!!!!!!
    !!!!!!!!
"   !!!!!!!!

(The algorithm starts placing from the last square first, prioritising left then up)

Slightly less confusing version (452 bytes):

def f(L):
 if[]==L:
  X=filter(sum,[map(" ".__lt__,q)for q in G]);Z=filter(sum,zip(*X));C=Z==Z[::-1]or X==X[::-1]
  if C:print"\n".join(map("".join,G))
  return C
 x=L[-1];T=S-x+1;R=range(x);V=[(a,b)for a in R for b in R]
 for n in range(T*T):
  i=n%T;j=n/T
  if all(G[i+a][j+b]<"!"for a,b in V):
   for a,b in V:G[i+a][j+b]=chr(32+len(L))
   r=f(L[:-1])
   for a,b in V:G[i+a][j+b]=" "
   if r:return r
L=input()
S=sum(L)
G=[S*[" "]for _ in[0]*S]
f(L)


Longest reverse palindromic DNA substring As you may know, in DNA there are four bases — adenine (A), cytosine (C), guanine (G) and thymine (T). Typically A bonds with T and C bonds with G, forming the "rungs" of the DNA double helix structure.

We define the complement of a base to be the base it bonds to — i.e. the complement of A is T, the complement of T is A, the complement of C is G and the complement of G is C. We can also define the complement of a DNA string to be the string with each base complemented, e.g. the complement of GATATC is CTATAG.

Because of the double-stranded structure of DNA, the bases on one strand are complementary to the bases on the other strand. However DNA has a direction, and DNA transcription occurs in opposite directions on the two strands. Hence molecular biologists are often interested in the reverse complement of a DNA string — quite literally the reverse of the complement of the string.

To extend our previous example, the reverse complement of GATATC is CTATAG backwards, so GATATC. As you may have noticed, in this example the reverse complement is equal to the original string — we call such a string a reverse palindrome.*

Given a string of DNA, can you find the longest substring which is a reverse palindrome?

*I use the term "reverse palindrome", taken from Rosalind, to differentiate from the usual meaning of palindrome.

Input

Input will be a single string consisting of only the characters ACGT in upper case. You may write either a function or a full program for this challenge.

Output

You may choose to output via either printing or returning (the latter choice is only available in the case of a function).

Your program should output the longest reverse palindromic substring of the input string, if there is a unique solution. If multiple solutions exist, then you may either output any single one of them, or all of them (your choice). Duplicates are okay if you choose to output all of them.

The input is guaranteed to have a solution of at least length 2.

Worked example

ATGGATCCG -> GGATCC

The reverse complement of GGATCC is itself (GGATCC --complement--> CCTAGG --reverse--> GGATCC), so GGATCC is a reverse palindrome. GATC is also a reverse palindome, but it is not the longest one.

Test cases

AT -> AT
CGT -> CG
AGCA -> GC
GATTACA -> AT, TA
ATGGATCCG -> GGATCC
CCCCCGGGGG -> CCCCCGGGGG
ACATATATAGACT -> ATATAT, TATATA
ATTCGATCTATGTAAAGAGG -> TCGA, GATC
CGCACGTCTACGTACCTACGTAG -> CTACGTAG
TCAATGCATGCGGGTCTATATGCAT -> ATGCAT, GCATGC [, ATGCAT]
CGCTGAACTTTGCCCGTTGGTAGAACGGACTGATGTGAACGAGTGACCCG -> CG, GC, TA, AT [, GC, CG, CG, CG, CG]
CTCGCGTTTGCATAACCGTACGGGCGGAACAGTCGGCGGTGCCTCCCAGG -> CCGTACGG

Scoring

This is code golf, so the solution in the fewest bytes wins.

Pyth, 37 36 28 24 bytes
ef&}TzqmaCd6T_mx4aCk6Tyz

Combining the tips from FryAmTheEggman and the reverse palindrome check trick from Peter, this is a super short version.
However, this only works with Pyth 3.0.1 which you can download from this link and run like
python3 pyth.py -c "ef&}TzqmaCd6T_mx4aCk6Tyz" <<< "ATTCGATCTATGTAAAGAGG"

(linux bash only. On windows, press Enter instead of the <<< and then type the input)

This is my previous submission - 28 bytes solution
J"ACGT"ef&}TzqTjk_m@_JxJdTyz

Thanks to FryAmTheEggman for this version. This one creates all possible subsets of the input DNA string, filters the subsets on the condition that the subset is a substring of input and the reverse of transform is equal to the subset itself.
Due to all possible subset creation, this takes up even more memory than Peter's answer.

This is my first submission - 36 byte solution.
J"ACGT"eolNfqTjk_m@_JxJdTm:zhkek^Uz2

This is the exact translation of my CJam answer. I was hoping that this would be much smaller but turns out that lack of translation method made it almost similar size (still 2 bytes smaller though)
Try it online here


Congratulations on getting 10,000 reputation! After @MartinBüttner achieved exactly 10,000 reputation, we now have three full rows of 10k users on the users page! Now, since we're all programmers here, we like to automate things instead of doing them manually. Your challenge is to write a program to automatically congratulate new 10k users.

Specification

Input

The input will be n lines of space-separated numbers. (If you would like, you may also take a single comma-separated list of space-separated numbers, if that makes your code shorter.) For example:

10 20 30 40 50
15 25 35 45 55
20 30 40 50 60

Or:

10 20 30 40 50,15 25 35 45 55,20 30 40 50 60

Each list of numbers represents a list of users' reputation values on a single day.

Output

The output will be the same amount of n lines (or a comma-separated list of the same length). Each line / list item will be:

:D if there was a user whose reputation just became >= 10,000.

Multiple space-separated :Ds if there were multiple users who met or passed the 10,000 rep count. For example, :D :D :D for 3 new 10k users.

:( and then halt further output if the input is ambiguous or impossible (more on this in the next section).
nothing if neither of these conditions is true.

Ambiguity

It is possible that the input is ambiguous. For the purposes of this challenge, we assume that:

The reputation cap is 200 per day, ignoring accepts and bounties and the like for the sake of the challenge.
Users may not lose reputation (again for simplicity and for the challenge).

Input is considered ambiguous when it is impossible to determine which reputation values correspond to which user. For example, in the input 10 20,30 40, you can't tell whether the 10-rep user became the 30-rep user or the 40-rep user.

Input is considered impossible when the users from one day could not possibly have become the users from the next day. For example, in the input 10 20,310 320, this situation is clearly impossible because the users could not have gained 300 reputation in a day. Users losing reputation is also impossible.

Edge cases

The initial reputation values can start at anything (i.e. a user can start with 1337 reputation).
There is no output for the first line / list item.
The input will always be syntactically valid, meaning that the reputation values will always be positive integers, there will always be the same amount of reputation values per line / list item, etc.
The reputation values are not sorted; they may be in any order.

Test cases

Input: 9900,10000
Output: :D

Input: 9900 9950 9910,10100 9950 9910,10300 10150 10110
Output: :D,:D :D

Input: 10 20 30,42 10 20,10 242 20,442 42 10,0 0 0,442 42 10
Output: ,,,:(

Input: 10 20,15 25,15 25
Output: ,,

Input: 9999 9998 9997,10000 9998 9997,10000 10000 9997,10300 10000 10000
Output: :D,:D,:(

Input: 100,90,80,70
Output: :(

Input: 10000 10000 10000 9999,10000 10000 10000 10000,10010 10020 10030 10040
Output: :D,:(

Input: 9999 9998 9997 9996,10196 10197 10198 10199,10399 10199 10197 10196
Output: :D :D :D :D,

Ruby, 209 bytes

Edit: I switched to Ruby which shortened this by about 30%. See the edit history for the original Mathematica version. I suppose the main savings come from Ruby's permutation not ignoring switched positions of identical elements (which I had to trick Mathematica into).

This uses the newline-separated format.

gets.split('
').map{|s|s.split.map &:to_i}.each_cons(2){|a,b|a.permutation.map{|q|q.zip(b).map{|x,y|y-x}}.reject{|d|d.any?{|x|x<0||x>200}}.size!=1?abort(':('):(puts':D '*(a.count{|d|d<1e4}-b.count{|d|d<1e4}))}

The gist is this:

Get all consecutive pairs of days.
Get all permutations of the former day, and subtract each of these from the current day.
Ditch all results which contain differences that are negative or greater 200.
If the number of remaining permutations isn't 1, output :(.
Otherwise, output as many :D as there are new 10k users.
At the end, drop all days after the first :(.

Less golf:

gets.split("\n").map{|s|
  s.split.map &:to_i
}.each_cons(2){|a,b|
  a.permutation.map{|q|
    q.zip(b).map{|x,y|
      y-x
    }
  }.reject{|d|
    d.any?{|x|
      x<0||x>200
    }
  }.size!=1 ? abort(':(') : (puts ':D '*(a.count{|d|d<1e4}-b.count{|d|d<1e4}))
}

I think that's one beautiful chain of enumerators. :)

PS: Is it weird that I was the first one to submit an answer to this?


Squares in Movement Range There are two inputs, the first input is a map in 2D array, where 2 represents an obstacle and 0 represents a regular ground, and 1 represents the player's location (implies that the player is standing on ground), the second input is the player's movement range.

A player can move on the map (horizontally, vertically, but not diagonally) within the movement range (0 to movement range inclusive), and the player can travel through an obstacle, but only one at a time. At last, a player cannot stand on an obstacle.

The program outputs an 2D array of booleans, showing all possible squares the player can move to.

Here are some examples:

Input

________
_____#__
___+__#_
#__#____
________, range=2
(_ = 0, + = 1, # = 2)

Output

___+____
__+++___
_+++++__
__+_+___
___+____ (+ = true, _ = false)

Input

__________
__________
______#___
__#_+##___
__________
____#_____
__________, range=4

Output

___+++____
__+++++___
_+++++_+__
++_++_____
_+++++++__
__++_++___
___+++____

There will be two winners: shortest brute-force and shortest efficient algorithm (the map and the movement range can get arbitrarily large)

Python, 284 characters

def M(A,R):
 X,Y=range(len(A[0])),range(len(A))
 G,P,H=[set(x+1j*y for x in X for y in Y if A[y][x]>=z) for z in(0,1,2)]
 P-=H
 for i in' '*R:P|=G&reduce(lambda x,y:x|y,[set(p+d for p in P)-(H&set(p+d for p in H))for d in(1,1j,-1,-1j)])
 return[[x+1j*y in P-H for x in X]for y in Y]

def display(A):print'\n'.join(''.join('_+'[c]for c in r)for r in A)

A=[[0,0,0,0,0,0,0,0],
   [0,0,0,0,0,2,0,0],
   [0,0,0,1,0,0,2,0],
   [2,0,0,2,0,0,0,0],
   [0,0,0,0,0,0,0,0]]
display(M(A,2))

A=[[0,0,0,0,0,0,0,0,0,0],
   [0,0,0,0,0,0,0,0,0,0],
   [0,0,0,0,0,0,2,0,0,0],
   [0,0,2,0,1,2,2,0,0,0],
   [0,0,0,0,0,0,0,0,0,0],
   [0,0,0,0,2,0,0,0,0,0],
   [0,0,0,0,0,0,0,0,0,0]]
display(M(A,4))

The main M routine takes the 2D array containing the map and the range, and returns the 2D array of booleans.
G is the set of all indexes of (in-bounds) squares, encoded as complex numbers.  H is the same but for the obstacles, and P is the same for the player.  The main loop updates P by moving P in each of the 4 cardinal directions, filtered by the obstacles and the bounds of the array.


Summation under Zeckendorf Representation Zeckendorf's theorem shows that every positive integer can be uniquely represented as a sum of non-adjacent Fibonacci numbers. In this challenge, you have to compute the sum of two numbers in Zeckendorf representation.

Let Fn be the n-th Fibonacci number where

  F1 = 1,
  F2 = 2  and
  for all k > 2, Fk = Fk - 1 + Fk - 2.

The Zeckendorf representation Z(n) of a non-negative integer n is a set of positive integers such that

  n = Σi ∈ Z(n) Fi  and
  ∀i ∈ Z(n) i + 1 ∉ Z(n).

(in prosa: the Zeckendorf representation of a number n is a set of positive integers such that the Fibonacci numbers for these indices sum up to n and no two adjacent integers are part of that set)

Notably, the Zeckendorf representation is unique. Here are some examples for Zeckendorf representations:

  Z(0) = ∅ (the empty set)
  Z(1) = {1}
  Z(2) = {2}
  Z(3) = {3} ({1, 2} is not the Zeckendorf representation of 3)
  Z(10) = {5, 2}
  Z(100) = {3, 5, 10}

In this challenge, Zeckendorf representations are encoded as bit sets where the least significant bit represents if 1 is part of the set, etc. You may assume that the Zeckendorf representations of both input and output fit into 31 bits.

Your task is to compute Z(n + m) given Z(n) and Z(m). The solution with the shortest length in octets wins.

You can find a reference implementation written in ANSI C here. It can also be used to generate Zeckendorf representations or compute a number from its Zeckendorf representation.

Here are some pairs of sample input and output, where the first two columns contain the input and the third column contains the output:

73865           9077257         9478805
139808          287648018       287965250
34              279004309       279004425
139940          68437025        69241105
272794768       1051152         273846948
16405           78284865        83888256
9576577         4718601         19013770
269128740       591914          270574722
8410276         2768969         11184785
16384           340             16724

APL (Dyalog Extended), 39 bytes

⊥1↓⍧|/⌽(+/g[⍸⌽+/⊤⎕]),↑,\⌽g←(2+/,)⍣38⍨⍳2

Try it online!

Changed into a full program taking one argument of length 2, and also changed the Fibonacci generator. Thanks to @ngn for lots of ideas.

Uses ⎕IO←0 so that ⍳2 evaluates to 0 1.

Fibonacci generator (new)

Note that the last two numbers are inaccurate, but it doesn't change the output of the program.

(2+/,)⍣38⍨⍳2
→ 0 1 ((2+/,)⍣38) 0 1

Step 1
0 1 (2+/,) 0 1
→ 2+/ 0 1 0 1
→ (0+1) (1+0) (0+1) ⍝ 2+/ evaluates sums for moving window of length 2
→ 1 1 1

Step 2
0 1 (2+/,) 1 1 1
→ 2+/ 0 1 1 1 1
→ 1 2 2 2

Step 3
0 1 (2+/,) 1 2 2 2
→ 2+/ 0 1 1 2 2 2
→ 1 2 3 4 4

Zeckendorf to plain (partial)

⍸⌽+/⊤⎕
     ⎕  ⍝ Take input from stdin, must be an array of 2 numbers
    ⊤   ⍝ Convert each number to base 2; each number is mapped to a column
  +/    ⍝ Sum in row direction; add up the counts at each digit position
 ⌽      ⍝ Reverse
⍸       ⍝ Convert each number n at index i to n copies of i

APL (Dyalog Extended), 47 bytes

g←1↓(1,+\⍤,)⍣20⍨1
{⊥1↓⍧|/⌽⍵,↑,\⌽g}+⍥{+/g[⍸⌽⊤⍵]}

Try it online!

Changed Part 1 of the previous answer to reuse the Fibonacci numbers. Also, drop the duplicate 1 to save some bytes in other places.

Part 1 (new)

{+/g[⍸⌽⊤⍵]}
       ⊤⍵    ⍝ Argument to binary digits
     ⍸⌽      ⍝ Reverse and convert to indices of ones
   g[    ]   ⍝ Index into the Fibonacci array of 1,2,3,5,...
 +/          ⍝ Sum

APL (Dyalog Extended), 52 bytes

{⊥1↓¯1↓⍧|/⌽⍵,↑,\⌽(1,+\⍤,)⍣20⍨1}+⍥({+∘÷⍣(⌽⍳≢⊤⍵)⍨1}⊥⊤)

Try it online!

How it works

No fancy algorithm to do addition in Zeckendorf because APL isn't known for operation on individual elements in an array. Instead, I went ahead to convert the two inputs from Zeckendorf to plain integers, add them, and convert it back.

Part 1: Zeckendorf to plain integer

{+∘÷⍣(⌽⍳≢⊤⍵)⍨1}⊥⊤  ⍝ Zeckendorf to plain integer
                ⊤  ⍝ Convert the input to array of binary digits (X)
{    (  ≢⊤⍵)  }    ⍝ Take the length L of the binary digits and
      ⌽⍳           ⍝   generate 1,2..L backwards, so L..2,1
{+∘÷⍣(     )⍨1}    ⍝ Apply "Inverse and add 1" L..2,1 times to 1
                   ⍝ The result looks like ..8÷5 5÷3 3÷2 2 (Y)
               ⊥   ⍝ Mixed base conversion of X into base Y

Base |             Digit value
-------------------------------
13÷8 | (8÷5)×(5÷3)×(3÷2)×2 = 8
 8÷5 |       (5÷3)×(3÷2)×2 = 5
 5÷3 |             (3÷2)×2 = 3
 3÷2 |                   2 = 2
 2÷1 |                   1 = 1

Part 2: Add two plain integers

+⍥z2i  ⍝ Given left and right arguments,
       ⍝   apply z2i to each of them and add the two

Part 3: Convert the sum back to Zeckendorf

"You may assume that the Zeckendorf representations of both input and output fit into 31 bits" was pretty handy.

{⊥1↓¯1↓⍧|/⌽⍵,↑,\⌽(1,+\⍤,)⍣20⍨1}  ⍝ Convert plain integer N to Zeckendorf
                 (1,+\⍤,)⍣20⍨1   ⍝ First 41 Fibonacci numbers starting with two 1's
                ⌽                ⍝ Reverse
             ↑,\                 ⍝ Matrix of prefixes, filling empty spaces with 0's
          ⌽⍵,                    ⍝ Prepend N to each row and reverse horizontally
        |/                       ⍝ Reduce by | (residue) on each row (see below)
       ⍧                         ⍝ Nub sieve; 1 at first appearance of each number, 0 otherwise
  1↓¯1↓                          ⍝ Remove first and last item
 ⊥                               ⍝ Convert from binary digits to integer

The Fibonacci generator

(1,+\⍤,)⍣20⍨1
→ 1 ((1,+\⍤,)⍣20) 1  ⍝ Expand ⍨
→ Apply 1 (1,+\⍤,) x 20 times to 1

First iteration
1(1,+\⍤,)1
→ 1,+\1,1  ⍝ Expand the train
→ 1,1 2    ⍝ +\ is cumulative sum
→ 1 1 2    ⍝ First three Fibonacci numbers

Second iteration
1(1,+\⍤,)1 1 2
→ 1,+\1,1 1 2  ⍝ Expand the train
→ 1 1 2 3 5    ⍝ First five Fibonacci numbers

⍣20  ⍝ ... Repeat 20 times

This follows from the property of Fibonacci numbers: if Fibonacci is defined as

$$
F_0 = F_1 = 1; \forall n \ge 0, F_{n+2} = F_{n+1} + F_n
$$

then

$$
\forall n \ge 0, \sum_{i=0}^{n} F_i = F_{n+2} - 1
$$

So cumulative sum of \$ 1,F_0, \cdots, F_n \$ (Fibonacci array prepended with a 1) becomes \$ F_1, \cdots, F_{n+2} \$. Then I prepend a 1 again to get the usual Fibonacci array starting with index 0.

Fibonacci to Zeckendorf digits

Input: 7, Fibonacci: 1 1 2 3 5 8 13

Matrix
0 0 0 0 0 0 13 7
0 0 0 0 0 8 13 7
0 0 0 0 5 8 13 7
0 0 0 3 5 8 13 7
0 0 2 3 5 8 13 7
0 1 2 3 5 8 13 7
1 1 2 3 5 8 13 7

Reduction by residue (|/)
- Right side always binds first.
- x|y is equivalent to y%x in other languages.
- 0|y is defined as y, so leading zeros are ignored.
- So we're effectively doing cumulative scan from the right.
0 0 0 0 0 0 13 7 → 13|7 = 7
0 0 0 0 0 8 13 7 →  8|7 = 7
0 0 0 0 5 8 13 7 →  5|7 = 2
0 0 0 3 5 8 13 7 →  3|2 = 2
0 0 2 3 5 8 13 7 →  2|2 = 0
0 1 2 3 5 8 13 7 →  1|0 = 0
1 1 2 3 5 8 13 7 →  1|0 = 0
Result: 7 7 2 2 0 0 0

Nub sieve (⍧): 1 0 1 0 1 0 0
1's in the middle are produced when divisor ≤ dividend
(so it contributes to a Zeckendorf digit).
But the first 1 and last 0 are meaningless.

Drop first and last (1↓¯1↓): 0 1 0 1 0
Finally, we apply base 2 to integer (⊥) to match the output format.


Finding prime numbers without using "prime characters" Your task, if you choose to accept it, is to write a program/function that accepts an integer \$N\$ as input. The program/function should output/return a list of the first \$N\$ prime numbers. But here's the catch: you are not allowed to use prime characters in your code. A prime character is a character whose Unicode code point is a prime number. In the printable ASCII range, these are:
%)+/5;=CGIOSYaegkmq

But the rule also applies to non-ASCII characters if your code uses those.

A valid input is an integer \$N\$ where \$0 < N \le T\$, where you can choose \$T\$, but it has to be greater than or equal to \$10000\$. \$T\$ does not have to be finite.
For invalid inputs (non-integers, integers out of range), throw an exception or output/return nothing/null.
An integer with leading/trailing whitespace as input is considered invalid.
An integer with a + as sign character as input is considered invalid.
An integer with leading zeros as input is considered valid.
If your language allows you to pass an already-parsed integer as input, the above parsing rules (except the range one) don't apply, because the int is already parsed.
The input is always base-10.
Use of built-in prime generators and primality testers (this includes prime factorization functions) is not allowed.
The source restriction is imposed on Unicode characters, but the byte counting for the score can be in another encoding if you wish.
The output can contain a single trailing newline, but this is not required.
If you output/return the prime number list as a string, then every prime number must be delimited by one or multiple non-digit char(s). You can choose which delimiter you use.
This is a code-golf challenge, the shortest code in bytes wins.

Stack Snippet to verify your code
You can use the below Stack Snippet to verify that your code does not contain prime chars:

var primes=[],max=10000;for(var i=2;i<=max;i++){primes.push(i);}for(var N=2;N<Math.sqrt(max);N++){if(primes.indexOf(N)===-1){continue;}primes=primes.filter(function (x){return x===N||x%N!==0;});}function setText(elem,text){var z=('innerText' in elem)? 'innerText' : 'textContent';elem[z]=text;}function verify(inputCode,resultSpan){var invalidChars=[];var success=true;for(var i=0;i<inputCode.length;i++){var cc = inputCode.charCodeAt(i);if (cc>max){setText(resultSpan,"Uh oh! The char code was bigger than the max. prime number calculated by the snippet.");success = false;break;}if (primes.indexOf(cc)!==-1){invalidChars.push(inputCode[i]);}}if (invalidChars.length===0&&success){setText(resultSpan, "Valid code!");}else if(success) {  var uniqueInvalidChars = invalidChars.filter(function (x, i, self){return self.indexOf(x)===i;});setText(resultSpan, "Invalid code! Invalid chars: " + uniqueInvalidChars.join(""));    }}document.getElementById("verifyBtn").onclick=function(e){e=e||window.event;e.preventDefault();var code=document.getElementById("codeTxt").value;verify(code,document.getElementById("result"));};
Enter your code snippet here:
<textarea id="codeTxt" rows="5" cols="70"></textarea>
<button id="verifyBtn">Verify</button>

CJam, 19 18 30 34 33 19 17 21 20 bytes

Try it online.

{_3\#,2>__ff*:~-<N*}

This is probably one of the most horribly inefficient algorithms I've ever implemented. But I did it for the size!

My answer consists of a code block, which acts like an anonymous function in CJam. Run it with an integer immediately preceding it on the stack, and the resulting list is dumped onto the stack. I treat the upper bound on the input as infinite so I don't have to check that bound.

My algorithm starts by raising 3 to the inputth power, which is guaranteed to give a number larger than the input-th prime if the input is valid. Then a list of the integers from 2 to this number minus one is generated, which is a large enough swath to contain all the prime numbers we want. To get rid of the composite numbers... sigh... we create a list of every pairwise product, which should generate all composite numbers from 4 to some stupidly large value, large enough for our purposes. Then it's just a matter of removing every element from the original list that is in this composite list, trimming it down to the first input elements, and joining the elements with the newline character.

The algorithm should work for any input. However, whether or not the interpreter/computer has enough memory or time is a whole other question, because the time and space requirements are exponential with respect to the input. So if the input is larger than about 5 for the online interpreter or about 8 for the offline one, then the answer to that question is probably no.


Guess the hidden communities Background

This challenge is about the stochastic block model.
Basically, you are given an undirected graph, where the nodes represent people, and the edges represent social connections between them.
The people are divided into two "communities", and two people are more likely to have a connection if they are in the same community.
Your task is to guess these hidden communities based on the connections.

Input

Your input is a 2D array of bits of size 100×100.
It represents the adjacency matrix of an undirected graph of size 100.
The graph is generated by the following random process:

Each node is placed in community 0 with probability 0.5, otherwise it's placed in community 1. The communities are not visible in the input.
For each pair of distinct nodes that are in the same community, put an edge between them with probability 0.3.
For each pair of distinct nodes that are in different communities, put an edge between them with probability 0.1.

All random choices are independent.

Output

Your output is a 1D array of bits of length 100.
It represents your program's guess about the underlying communities.
You are not required to correctly guess which nodes belong to community 0 and which to community 1 (which would be impossible), just the partition into two communities.

Scoring

In this repository, you'll find a text file containing 30 lines.
Each line represents a graph generated by the above process, and it consists of the array of the hidden communities, a semicolon, and a comma-separated list of rows of the adjacency matrix.
You should read this text file, call your submission program on the adjacency matrix of each line, and compare its output to the underlying community structure.

Your submission's score on a particular graph is

min(sum_i(V[i] == W[i]), sum_i(V[i] == 1-W[i]))

where V is the array of hidden communities, W is your program's guess based on the adjacency matrix, and i ranges over their indices.
Basically, this measures the number of mis-classified nodes, taking into account that you're not required to guess which community is which.
The lowest average score over all 30 test cases wins, with byte count used as a tie breaker.

Example

Consider the input matrix (6×6 for clarity)

011000
101100
110000
010011
000101
000110

It corresponds to the 6-node graph

a-b-d
|/ /|
c e-f

consisting of two triangles with one edge between them.
Your program might guess that each triangle is a separate community, and output 000111, where the first three nodes are in community 0 and the rest in community 1.
The output 111000 is equivalent, since the order of the communities doesn't matter.
If the true community structure was 001111, then your score would be 1, because one node is mis-classified.

Additional rules

Your program should take no more than 5 seconds on any single test case on a reasonably modern computer (I'm unable to test most answers, so I'll just trust you here).

You can write a full program or a function, and standard loopholes are disallowed.
You are allowed to optimize your answer toward the parameters used here (size 100, probabilities 0.3 and 0.1), but not the actual test cases.
I keep the right to generate a new set of graphs if I suspect foul play.

Test program

Here's a Python 3 function that computes the score of a Python 3 function submission.

import time

def test_from_file(submission, filename):
    f = open(filename)
    num_graphs = 0
    total_score = 0
    for line in f:
        num_graphs += 1
        a, _, c = line.partition(';')
        V = [int(node) for node in a]
        E = [[int(node) for node in row] for row in c[:-1].split(',')]
        start = time.perf_counter()
        W = submission(E)
        end = time.perf_counter()
        x = sum(V[i]==W[i] for i in range(len(V)))
        score = min(x, len(V) - x)
        print("Scored {0:>2d} in {1:f} seconds".format(score, end - start))
        total_score += score
    f.close()
    return total_score / num_graphs

R, 16/30 = 0.53333...

Edit:
Here is a version that has been golfed down to 259 bytes. I am sure a much better bytecount is possible. This version takes advantage of the fact that T is a global variable in R which can be treated as having a value of 1. If T has been reassigned in your R environment, results may differ.
The code produces some warnings, but they can be ignored.

f=function(A){L=function(p){q=1-p;z=.1*p%o%q;x=z+t(z)+.3*(p%o%p+q%o%q);c(sum(log(x^A*(1-x)^(1-A))),(A/x-(1-A)/(1-x))%*%(2*p-1))};x=tanh(rnorm(100))/2+.5;for(i in x){t=.5+tanh(atanh(2*x-1)+T*2*(L(x)[2:101]>0)-T)/2;if(L(t)>L(x)){x=t;T=2*T}else{T=T/2}};round(x)}

If the adjacency matrix of your graph is saved as a 100x100 matrix A in R, then the vector of communities is f(A). It will probably make less than one mistake!

Explanation
It treats the problem as fitting a statistical model (it helps that it knows the values 0.3 and 0.1) and fits it using a sort of gradient ascent algorithm. The community membership vector is treated as containing values in [0,1], rather than just zeroes and ones. This enables the model to be fitted using a sort of gradient ascent. (Ascent and descent is actually by a fixed amount delta in each coordinate, to avoid various problems. If a step of gradient ascent fails, delta is adjusted down.) It's quite fast and does pretty well.
I used today's date as the random seed.
LL <- function(p, A){
# log-lieklihood of the model
  q <- 1-p
  x <- 0.1*(p %o% q) + 0.1*(q %o% p) + 0.3*(p %o% p) + 0.3*(q %o% q)
  sum(A*log(x) + (1-A)*log(1-x))
}

expit <- function(x) exp(x)/(1+exp(x))

gradLL <- function(p, A){
# (scalar multiple of) the gradient of the log-likelihood
  q <- 1-p
  x <- 0.1*(p %o% q) + 0.1*(q %o% p) + 0.3*(p %o% p) + 0.3*(q %o% q)
  drop((A/x - (1-A)/(1-x)) %*% (0.4*p - 0.2))
}

fit_model <- function(A, N=100){
# gradient ascent
  x <- rnorm(100)
  score <- LL(expit(x), A)
  delta <- 1
  for (i in 1:N){
    grad <- gradLL(expit(x), A)
    test <- x + delta*((grad > 0) - (grad < 0))

    test_score <- LL(expit(test), A)
    if (test_score > score){
      score <- test_score
      x <- test
      #print(score)
      delta <- (1/0.7)*delta
    } else {
      delta <- 0.7*delta
    }
  }
round(expit(x))
}

generate_A <- function(){
# generate a matrix for testing
  comms <- sample(0:1, 100, replace=T)
  A <- matrix(rep(0, 100^2), nc=100)
  for (i in 1:(nrow(A)-1)){
    for (j in (i+1):ncol(A)){
      prob <- ifelse(comms[i]==comms[j], 0.3, 0.1)
      if (runif(1) < prob) A[i,j] <- 1
    }
  }
  A <- (A + t(A))/2
  list(A=A, comms=comms)
}

test <- function(){
# test the fitting function once
  dat <- generate_A()
  fit <- fit_model(dat$A)
  sum(fit==dat$comms)
}

### performance ###

strings <- readLines("community-graphs.txt", 30)

total <- 0

set.seed(011215) # note that output is random!

for (i in 1:30){
  str_data <- strsplit(strings[i], ";")[[1]]
  comms <- as.numeric(strsplit(str_data[1], "")[[1]])
  A_str <- strsplit(str_data[2], ",")[[1]]
  A <- matrix(rep(0, 100^2), nc=100)
  for (r in 1:100){
    A[r,] <- as.numeric(strsplit(A_str[r], "")[[1]])
  }
  out <- fit_model(A)
  total <- total + min(sum(out==comms), sum(out!=comms))
}

total # 16