Build an Authenticating SMTP Client The basic parts of SMTP can be implemented in surprising little code. I was able to build an example SMTP client that works with Gmail and Amazon SES in about 320 characters using PHP.

Your task is to implement an SMTP client that can send UTF-8 email from at least 2 major providers listed here:

Gmail
Yahoo!
Live/Hotmail
Postmark
Amazon SES

Keep in mind that most require SSL support. Some SMTP services (like Amazon) require different SMTP Auth and From addresses. Your function can take input for the actual data transmitted. After all, it woudn't make sense to hard-code anything into the transport layer.

SMTP User
SMTP Password
SMTP Host
SMTP Port
DATA (message)
From email
To email

Sample DATA (message)

Subject: =?UTF-8?B?VGVzdCBFbWFpbA==?=\r\n
To: <him@gmail.com>\r\n
From: <you@gmail.com>\r\n
MIME-Version: 1.0\r\n
Content-Type: text/html; charset=utf-8\r\n
Content-Transfer-Encoding: base64\r\n\r\n
PGgxPlRlc3QgRW1haWw8L2gxPjxwPkhlbGxvIFRoZXJlITwvcD4=\r\n.

In Summary

Build an SMTP client that can send email through at least two of the services above.
Accepts the seven inputs needed to form a valid SMTP Auth request (above). (Might only need six inputs if you combine the "From" and "SMTP User" inputs).
Use as few characters as posible.

Python 3 864 bytes

Extremely quick and dirty. Works with AWS SES and Yahoo!. Could not get it to work with Postmark (requires STARTTLS) or Gmail (requires further authentication outside of the SMTP connection).

import socket,ssl
from base64 import*
N=b'\x00'
U='utf-8'
E=lambda s:s.encode(U)
D=lambda b:b.decode(U)
B=lambda s:D(b64encode(E(s)))
A=lambda f,t,j,b:E('\r\n'.join(['DATA','Subject: =?UTF-8?B?{}?=','To: <{}>','From: <{}>','MIME-Version: 1.0','Content-Type: text/html; charset=utf-8','Content-Transfer-Encoding: base64',B(b),'','.','']).format(B(j),t,f,b))
X=lambda s,e:s.startswith(e)
def S(h,u,p,t,f,j,b):
    c,F,W=ssl.wrap_socket(socket.create_connection((h,465))),lambda m:E(m if'amazonaws'in h else'<'+m+'>'),lambda m:c.write(m+b'\r\n')
    def R(d,o=[]):
        x,y=c.read(),str(d)
        if not(X(x,E(y))or filter(lambda i:X(i,X(x,E(y))),o)):raise RuntimeError(y+' '+repr(x))
    R(220);W(b'EHLO x');R(250);W(b'AUTH PLAIN '+b64encode(N+E(u)+N+E(p)));R(235);W(b'MAIL FROM: '+F(f));R(250);W(b'RCPT TO: '+F(t));R(250);W(A(f,t,j,b));R(250,(354,));W(b'QUIT')

Invoke like S(hostname, username, password, to, from_, subject, body)

Expect bugs and changes (kind of got bored so it feels slightly half-baked).

C# .NET, assuming all the proper namespaces have been imported and not counting newlines/whitespace as characters. Also, displays no output as it's used as a library function.

bool sm(string h, string u, string p, string r, string m) {
    try {
        SmtpClient smtp = new SmtpClient();
        smtp.Port = 587;
        smtp.Host = h;
        smtp.Credentials = new NetworkCredential(u, p);
        smtp.UseSsl = true;
        smtp.Send(u, r, "", m);
        return true;
    } catch {
        return false;
    }
}

In its compressed form, the way I would code it, it'd look like this:

bool sm(string h, string u, string p, string r, string m) { try { SmtpClient smtp = new SmtpClient(); smtp.Port = 587; smtp.Host = h; smtp.Credentials = new NetworkCredential(u, p); smtp.UseSsl = true; smtp.Send(u, r, "", m); return true; } catch { return false; } }

Call it cheating, because of using .NET, but 266 characters. Works with major providers that allow SMTP with STARTTLS authentication on port 587. I use this for my Gmail all the time, works with Windows Live Hotmail too. Can be used either client-side OR server-side, and requires .NET 2.0 or newer (so it's compatible with pretty much every Windows machine).


Is it simple or is it hard? For your hard thing to do, you must make a thing for a computer to do that finds out if some words are explained in a simple way. Something is explained in a simple way if it only uses the ten hundred most used words. If not, it is explained in a hard way. This can be a full computer thing or part of a computer thing. (full program or function)

There is a thing for a computer to read that has all of the ten hundred words in it with a space between each word. The name of the thing for the computer to read is called 'most used.txt'. You can take this thing from this computer place.

The person who uses the computer thing will enter some words. (This can be from STDIN, function arguments or command line arguments) The computer must say something like a true if the words are simple and something like a not true if it is hard. (truthy-falsy) The person who makes the shortest thing for the computer to do is the best. The things that every person knows are bad are bad. (standard loopholes apply)

More stuff to know about how the computer thing works:

It doesn't matter if the words are BIG or little.
The pictures that make what the word meaning easier to know (punctuation) don't matter. So if the person who uses the computer thing says "dont" it isn't a different word than the word "don't". Numbers and other pictures also don't matter. So if the person says "HE$$ll9o" the computer should read it like "hello"
The little lines between words (dashes) work the same way as spaces. So the word "up-goer-five" is the same as the words "up goer five".

More stuff to know about making words like this:

https://xkcd.com/1133/

http://splasho.com/upgoer5/#

R, 106 bytes

Is not sure if is understand challenge because is has hard time reading.

function(s){u=toupper;all(strsplit(gsub("[^A-Z -']","",u(s)),"[ -]")[[1]]%in%u(scan("most used.txt","")))}

This creates an unnamed part of a computer thing that accepts a string and returns something like a true or like a not true.

Ungolfed + explanation:

partOfAComputerThing <- function(s) {
    # Remove everything but letters, spaces, dashes, and single quotes
    s <- gsub("[^A-Z -']", "", toupper(s))

    # Split s into a vector on spaces/dashes
    v <- strsplit(s, "[ -]")[[1]]

    # Read the file of words (assumed to reside in the current directory)
    m <- scan("most used.txt", "")

    # Determine if all words in the input are in the file
    all(v %in% toupper(m))
}

Thanks to Dennis for inspiration thing.

Java, 248 bytes

With the Phrase passed as an argument.

void g(String s) throws Exception{String c=new java.util.Scanner(new java.io.File("most used.txt")).useDelimiter("\\Z").next(),x="false";for(String l:s.split(" "))if(c.contains(l.toLowerCase().replaceAll("![a-z]","")))x="true";System.out.print(x);}

input/output:

g("was he")         --> "true"
g("was h!e")         --> "true"
g("delicious cake") --> "false"

Spaced and tabbed out:

void g(String s) throws Exception{
    String c=new java.util.Scanner(new java.io.File("most used.txt")).useDelimiter("\\Z").next()
      ,x="false";
    for(String l:s.split(" "))
      if(c.contains(l.toLowerCase().replaceAll("![a-z]","")))
          x="true";
    System.out.print(x);
}


Find All Distinct Gozinta Chains Gozinta Chains
(Inspired by Project Euler #606)
A gozinta chain for n is a sequence {1,a,b,...,n} where each element properly divides the next.
For example, there are eight distinct gozinta chains for 12:
{1,12}, {1,2,12}, {1,2,4,12}, {1,2,6,12}, {1,3,12}, {1,3,6,12}, {1,4,12} and {1,6,12}.

The Challenge
Write a program or function that accepts a positive integer (n > 1) and outputs or returns all the distinct gozinta chains for the given number.

Order in the chains matters (ascending), order of the chains does not.
On the off-chance it exists, you cannot use a builtin that solves the challenge.
This is code-golf.

Edit: Removing 1 as a potential input.

Python 3, 68 65 bytes
Edit: -3 bytes thanks to @notjagan

f=lambda x:[y+[x]for k in range(1,x)if x%k<1for y in f(k)]or[[x]]

Try it online!
Explanation
Each gozinta chain consists of the number x at the end of the chain, with at least one divisor to the left of it. For each divisor k of x the chains [1,...,k,x] are distinct. We can therefore for each divisor k find all of its distinct gozinta chains  and append x to the end of them, to get all distinct gozinta chains with k directly to the left of x. This is done recursively until x = 1 where [[1]] is returned, as all gozinta chains start with 1, meaning the recursion have bottomed out.
The code becomes so short due to Python list comprehension allowing double iteration. This means that the values found in f(k) can be added to the same list for all of the different divisors k.

Mathematica

f[1] = {{1}};
f[n_] := f[n] = Append[n] /@ Apply[Join, Map[f, Most@Divisors@n]]

Answer is cached for additional calls.


Program that creates larger versions of itself (quine-variant) You are to write a program that will output source code that is

Larger than the original program (character wise)
Will print another program larger than itself when run (i.e. the new program is also a valid answer to this challenge)

This is code-golf, so shortest answer wins.

H9+ : 1 char
9

That's right. One character. Outputs the lyrics to 99 bottles of beer, which is a valid program. All the extraneous data does not count, but there are plenty of 9s in there.
The output of the outputted program is the lyrics to 99 bottles of beer 59 times.
This function gives the number of times the lyrics are outputted if you run the program n times (if my calculation is correct):
f(n) = 59n-1

Batch

set d=time
copy c:\>loop.bat /B loop%d%.bat
call c:\>loop.bat


Find the absolute value of a number without built-in functions The challenge is to take any real number as input and output or return the absolute value. You may not use any built-in functions other than those dealing with input and output/returning. This is code golf, so the shortest code wins. This is my first question here, so bear with me if I've left something obvious out of the challenge.

As per Quincunx's suggestion, I am limiting input to anywhere between -9E99 and 9E99.

Also, the only functions/operators you can use are input, output, return, +, -, *, /, %, ^ +=, -=, *=, /=, >, <, ==, >=, <=, !=, square, and square root or their equivalents

J, 2 bytes

**

Usage:

   f =: **
   f 9.3
9.3
   f -9.3
9.3

Explanation:

This uses the * verb in both its monadic and dyadic forms. The monadic form returns -1 if it's given a negative number, 0 if it's given 0 and 1 if it's given a positive number. The dyadic form is just plain old multiplication. Putting them in a function literal turns them into a hook which gets evaluated like this: y * (*y).


Script that outputs a script that prints a given input Write a piece of code that takes a string as input, and outputs a piece of code in the same language that, when run, will output the initial input string.

It must be able to handle any combination of characters A-Z, a-z, and 0-9.

Example in Python:

import sys
print "print('" + sys.argv[1]  + "')"

Given the input of testing123, it will return print('testing123').

Since this is code-golf, the shortest answer in bytes will win.

pl, 0 bytes
Code:

Try it online!
Explanation:
An empty program in pl is simply a cat program, outputting the exact same as the input.
In pl, all ASCII characters are essentially variables, but when the variable doesn't exist (yet), pl assumes that they are part of a string.


Antiferromagnetic ordering Antiferromagnetism is what IBM researchers used to jump from a 1 terabyte disk to a 100 terabyte disk in the same amount of atoms.

In materials that exhibit antiferromagnetism, the magnetic moments of atoms or molecules, usually related to the spins of electrons, align in a regular pattern with neighboring spins (on different sublattices) pointing in opposite directions.

Your job is to write a program that draws the ordering of antiferromagnetic atoms like the picture shown above. You must be able to have at least four sets of pairs, though you may have more.

Each pair must be shown as follows, though they must be actual arrows:

 up  down
down  up
 up  down

Your output can be in ascii art or graphical output.

You can make only a function or a whole program, but it must take an input and draw that many pairs. Examples with only words:

Input: 1

 up  down
down  up
 up  down

Input: 2

 up  down  up  down
down  up  down  up
 up  down  up  down

Acceptable arrows:

↑ and ↓
⇅ and ⇵
/|\ and \|/

Please put your answers in Language, X bytes format, as it's easy to read. The least amount of bytes wins!

APL, 18 12 bytes

⍉(2×⎕)3⍴'↑↓'

This constructs a 2n x 3 matrix, where n is the input (⎕), filled with the characters ↑ and ↓. The transpose (⍉) of this matrix is then printed.

You can try it online.


R[oman|everse] Polish Notation It is the year MDLXVII in a world in which the Roman Empire never fell, and the collapse into the dark ages never occurred. Due to the extended period of Pax Romana, the empire's economic stability enabled technology to progress at a rapid rate.

The Romans have begun to dabble with circuitry, and have invented an ingenious calculator that doesn't require the use of an "equals" button. They call it "Roman Polish Notation"

To make a calculation, they enter their operands first, then the operation.

For example, 100 + 11 * 20 would be C XI XX * +.

Additionally

The Romans have found that they often need to make multiple calculations at the same time, and would prefer for the method to return every value "on the stack" in some sort of array/list/tuple-like structure. (e.g. X I + X I - CC II + would return [11, 9, 202])

The challenge is to develop a calculator program capable of making these computations.

Clarification: Subtractive Notation is required. I hadn't realized it wasn't recognized feature in the Ancient Roman empire. The task was therefore ambiguous, and I apologize.

Minimum Guidelines

Your output will be in Arabic Numerals.
You only need to convert from Roman Numerals up to 5000.
You will need to support +, -, /, * operations (addition, subtraction, division, and multiplication).
Whether division is floating point based or integer based is implementation specific. Either works for this challenge.
Your output will need to support numbers up to 4 Billion.
Shortest answer overall, AND in each language wins. This is a Code Golf Challenge but I love the variety.

In the event of a tie, factors like support for roman numerals above 5000 or additional operations will be considered the earliest submission will win.

Python 2 + roman, 118 bytes

from roman import*
s=[]
for i in input().split():s+=[eval(s.pop(-2)+i+s.pop())if i in"+-/*"else`fromRoman(i)`]
print s

Demo
It cannot be tested online because of the module it makes use of, but you can see how  to run this here (a full program accepting input from STDIN – an expression with quotes – and printing the output to STDOUT – in the form of a list, the stack). Uses a slightly older version, because I won't bother to create a new GIF for only a few bytes:

To install the package, you can run the following in the Terminal / Command Line:
pip install roman

Python 3, 216 187 bytes

from operator import*
N=dict(I=1,V=5,X=10,L=50,C=100,D=500,M=1000)
def f(w):
	s=[]
	for t in w.split():s+=[str(sum(map(N.get,t)))if t[0]in N else str(eval(s.pop(-2)+t+s.pop()))]
	return s

Try it online!

Because it came up in the comments of both the question and this answer and likely led to down-votes: this submission doesn't support subtractive notation. Rationale: Subtractive notation was rarely used in the Roman Empire and only popularised later (see Subtractive Notation, paragraph 3, last sentence). The task presumes a Roman Empire that developed programmable integrated circuits, not one that underwent the same cultural changes as 13th century Europe. The description doesn't mention subtractive notation and none of the examples uses it.


Render "Digital Clock Style" Numbers Write the shortest program which will take a string of numbers (of up to at least 20 length) as input, and display the output using the standard digital clock style numbers.  For instance for input 81, a solution with ascii output would give:

 _
|_|  |
|_|  |

Graphical output is also acceptable, if it helps.

Funciton

Not really a language suitable for golfing... but regardless, I tried to keep the code size as small as I could — quite a different challenge than in “usual” languages. This is 1555 characters or 3110  bytes (if encoded as UTF-16; UTF-8 is larger).

Here’s a screenshot of the program running. It really works :)

Since this looks ugly in StackExchange due to the extra line spacing, consider running the following code in your browser’s JavaScript console to fix that: $('pre').css('line-height',1)

     ╓─╖ ╔╗┌─╖   ┌─╖
     ║ʜ║ ║╟┤↔╟┐ ┌┤‼╟┐
     ╙┬╜ ╚╝╘═╝│ │╘╤╝│
╔═╗  ┌┴────┐  │┌┴╖ ┌┴╖
║0║ ┌┴─┐  ┌┴─┐└┤ʜ╟─┤·╟┐
╚╤╝┌┴╖┌┴╖┌┴╖┌┴╖╘╤╝ ╘╤╝│
┌┘┌┤·╟┤ɦ╟┤·╟┤?╟ │  ┌┴╖│
│ │╘╤╝╘╤╝╘╤╝╘╤╝ └──┤‼╟┘
│┌┴╖│ ┌┴╖┌┘╔═╧╗    ╘═╝
└┤?╟┘┌┤?╟┘┌╢10║    ┌─────────┐
 ╘╤╝ │╘╤╝┌┘╚══╝ ┌─┬┘╔══╗┌──╖┌┴╖ ╓─╖
  ┘  └───┘╔════╗│┌┴┐║21╟┤>>╟┤·╟┐║ɦ║
╔════════╗║1005╟┘└┬┘╚══╝╘═╤╝╘╤╝│╙┬╜        ┌─┐
║14073768║╚════╝ ┌┴╖ ┌─╖ ┌┴╖┌┴╖└─┴─────────┘┌┴╖
║7584800 ╟───────┤?╟─┤‼╟─┤ʜ╟┤·╟─────────────┤·╟┐╔═══════╗╔══╗
╚════════╝       ╘╤╝ ╘╤╝ ╘╤╝╘╤╝    ╔══╗┌─╖┌┐╘╤╝│║2097151║║21╟┐
 ╔═══════════════╗│   ┘   │  │     ║48╟┤−╟┤├─┤┌┘╚══╤════╝╚══╝│
 ║140737555464224╟┘  ┌────┘┌┬┘     ╚══╝╘╤╝└┘┌┘│╓─╖ │┌┐┌─╖┌─╖┌┴─╖
 ╚═══════════════╝   │ ┌───┘└─────────┐┌┴─╖ │┌┘║↔║ ├┤├┤‼╟┤↔╟┤>>║
┌────────────┐┌────┐┌┴╖│┌────────────┐├┤<<║ ││ ╙┬╜┌┘└┘╘╤╝╘═╝╘╤═╝
│   ╔══╗╔═══╗├┘╓─╖ └┤·╟┘│   ╔══╗╔═══╗├┘╘╤═╝ │└─┐└─┤╔═╗┌┴╖ ┌──┘
│   ║95║║892║│┌╢‡╟┐ ╘╤╝ │   ║95║║877║│ ┌┘╔══╧═╗│  │║0╟┤?╟┬┘
│   ╚═╤╝╚═╤═╝││╙─╜│  │  │   ╚═╤╝╚═╤═╝│╔╧╗║2097║│  │╚═╝╘╤╝│
│╔══╗┌┴╖┌┐│  ││┌─╖│ ┌┴╖ │╔══╗┌┴╖┌┐│  │║1║║151 ║│  └──────┘
│║32╟┤?╟┤├┤  │└┤‼╟┘┌┤‡║ │║32╟┤?╟┤├┤  │╚═╝╚════╝│
│╚══╝╘╤╝└┘└──┴┐╘╤╝ │╘╤╝ │╚╤═╝╘╤╝└┘└──┴┐      ┌─┘
│    ┌┴╖     ┌┴╖┌─╖│ │ ┌┴╖│  ┌┴╖     ┌┴╖ ┌─╖┌┴╖
│    │‼╟─────┤·╟┤‼╟┘ │┌┤·╟┘  │‼╟─────┤·╟─┤‼╟┤‡║
└┐┌┐ ╘╤╝     ╘╤╝╘╤╝  ││╘╤╝┌┐ ╘╤╝     ╘╤╝ ╘╤╝╘╤╝
 ├┤├┐┌┴╖╔══╗  └──┐┌┐ │└┐├─┤├┐┌┴╖╔══╗  ├──┐└  │
 │└┘└┤?╟╢32║╔═══╗├┤│┌┴╖││ └┘└┤?╟╢32║╔═╧═╗│┌┐┌┴╖╔══╗
╔╧══╗╘╤╝╚══╝║881╟┘│├┤?╟┘│    ╘╤╝╚══╝║325║└┤├┤?╟╢32║
║927║╔╧══╗  ╚═══╝ └┘╘╤╝╔╧═══╗╔╧══╗  ╚═══╝ └┘╘╤╝╚══╝
╚═══╝║124╟───────────┘ ║1019║║124╟───────────┘
     ╚═══╝             ╚════╝╚═══╝

It could probably be smaller if I hadn’t made a mistake due to which the output was back to front; I fixed that by adding an extra function to reverse the input. Otherwise I would probably have to rewrite all of it.

I also made another mistake (swapping the operands in two calls to ‼) which made it necessary to declare the extra ‡ function, but this one is so small it fits inside the main function and thus doesn’t add any characters!

Perl, 145 characters

$i=<>;for$s(6,3,0){for($i=~/./g){$v=(175,9,158,155,57,179,183,137,191,187)[$_]>>$s;$o.=($v&4?'|':$").($v&2?'_':$").($v&1?'|':$")}$o.="
"}print$o

Ungolfed:

# Read STDIN
$i = <>;
# Amount to bit shift later
for $s (6,3,0)
{
  # For each character C from STDIN
  for ($i =~ /./g)
  {
    # Get the Cth array index, bit shifted right by $s
    $v = (175, 9, 158, 155, 57, 179, 183, 137, 191, 187)[$_]>>$s;
    # Concatenate each character if the bitwise masked value says it should be there
    $o .= ($v & 4 ? '|' : $") .
          ($v & 2 ? '_' : $") .
          ($v & 1 ? '|' : $");
  }
  # Concatenate a newline
  $o .= "
";
}
# Print the result
print $o;


Tips for golfing in Python What general tips do you have for golfing in Python? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Python (e.g. "remove comments" is not an answer).

Please post one tip per answer.

Use a=b=c=0 instead of a,b,c=0,0,0.

Use a,b,c='123' instead of a,b,c='1','2','3'.

1 or 0 can act as boolean operators in Python:

func = lambda x:1 if x//2==x/2 else 0
while 1:
    if func(n):
         print('Hello')
    else:
         exit()

Which is 10 characters shorter than:

func = lambda x:True if x//2==x/2 else False
while True:
    if func(n):
         print('Hello')
    else:
         exit()


Simulate move left for 2048 I have a fixed length vector of 4 elements. The inputs of which are always 0 or 2^n for n = 1 to 15 (so n = 0 excluded i.e.  2^0 = 1 will not appear)

x = [32, 4, 4, 8]

the result should be

x = [32, 8, 8, 0]

The way it works is that values that are the same will get combined, but one it's combined it can not be combined with another value for another turn.

and we want to simulate the shortest code to make simulate 2048 move left on this one row.

The shortest code wins! It's fixed-size 4 vector. So it's not the same as the other problem. Also, you need to put zeros here.

Test cases:

[0,0,0,0] -> [0,0,0,0]
[0,0,0,2] -> [2,0,0,0]
[2,0,0,4] -> [2,4,0,0]
[8,0,0,8] -> [16,0,0,0]
[16,16,32,64] -> [32,32,64,0]
[16,16,8,8] -> [32,16,0,0]
[2,2,2,0] -> [4,2,0,0]

APL (Dyalog Unicode), 36 bytesSBCS

Anonymous tacit prefix function.

⎕UCS{4↑⍺⍺t⎕R(1⌽∪¨t←2/¨⍺⍺2*⍳16)⍺⍺⍵~0}

Try it online!

⎕UCS{…} derived function where ⍵ is the argument and ⍺⍺ converts to/from code points:

 ⍵~0 the argument without zeros

 ⍺⍺ convert to code points

 t⎕R(…) Replace the texts t (defined below) with the corresponding texts from:

  ⍳16 the indices from 1 to 16

  2* two raised to the power of those

  ⍺⍺ convert them to characters

  2/¨ make two of each

  t← assign to t

  ∪¨ get the unique element from each (i.e. deduplicate them)

  1⌽ cyclically rotate the first string to the end

 ⍺⍺ convert to code points

 4↑ take the first four elements, padding with zeros

Julia 277 248 bytes

m(x)=begin
t=true
e=falses(3)
for i in 2:4
if x[i]!=0
d=!t
for j in i-1:-1:1
if x[j]!=0
if(x[j]!=x[i])|e[j]
p=x[i]
x[i]=0
x[j+1]=p
d=t
break
elseif x[j]==x[i]
x[j],x[i]=x[i]*2,0
e[j]=t
d=t
break
end
end
end
if !d
x[1],x[i]=x[i],0
end
end
end
x
end


Clockwise matrix rotation The title pretty much describes it all. Given as input a \$n \times m\$ matrix and an integer \$i\$ create a complete function/program that returns the matrix \$i\$ times clockwise rotated by \$90^\circ\$.

Rules:

as matrix you can use any convenient representation you like e.g. a list of lists etc...
matrix values can be positive and/or negative integer numbers
\$n\$ and \$m\$ are of course always positive integers between 1 and 10
\$i\$ can be any valid integer which belongs in the following range: \${0...10^5}\$
Standard code-golf rules & winning criteria apply but no "winning" answer will be chosen.

EDIT: I had to edit the initial question because for some programming languages it takes too long to compute the result for \$i\in\{0...10^7\}\$. There is a workaround to it but since it's a code-golf just make sure that it simply runs successfully for at least \$i\in\{0...10^5\}\$.

Some test cases:

==== example 1 ====
Input:
5
[[1, 3, 2, 30,],
 [4, 9, 7, 10,],
 [6, 8, 5, 25 ]]

Expected Output:
[[ 6  4  1],
 [ 8  9  3],
 [ 5  7  2],
 [25 10 30]]

==== example 2 ====
Input:
100
[[1]]

Expected Output:
[[1]]

==== example 3 ====
Input:
15
[[150,    3,  2],
 [  4, -940,  7],
 [  6, 8000,  5]]

Expected Output:
[[   2    7    5],
 [   3 -940 8000],
 [ 150    4    6]]

==== example 4 ====
Input:
40001
[[1, 3, 9]]

Expected Output:
[[1],
 [3],
 [9]]
```

APL (Dyalog Unicode), 7 bytes

⌽∘⍉⍣⎕⊢⎕

Try it online!

⎕ prompt for matrix expression from stdin

⊢ yield that

⎕ prompt for \$i\$ expression from stdin

⍣ do the following that many times

⍉ transpose

∘ and then

⌽ mirror


2048-like array shift Assume we want to shift an array like it is done in the 2048 game: if we have two equal consecutive elements in array, merge them into twice the value element.
Shift must return a new array, where every pair of consecutive equal elements is replaced with their sum, and pairs should not intersect.
Shifting is performed only once, so we don't need to merge resulting values again.
Notice that if we have 3 consecutive equal elements, we have to sum rightmost ones, so for example, [2, 2, 2] should become [2, 4], not [4, 2].

The task is to write shortest function which takes an array and returns a shifted array.

You may assume that all integers will be strictly positive.

Examples:

[] -> []
[2, 2, 4, 4] -> [4, 8]
[2, 2, 2, 4, 4, 8] -> [2, 4, 8, 8]
[2, 2, 2, 2] -> [4, 4]
[4, 4, 2, 8, 8, 2] -> [8, 2, 16, 2]
[1024, 1024, 512, 512, 256, 256] -> [2048, 1024, 512]
[3, 3, 3, 1, 1, 7, 5, 5, 5, 5] -> [3, 6, 2, 7, 10, 10]

I am also very interested in solution using reduce :)

Jelly, 10 9 8 bytes
Œg+2/€UF

TryItOnline or run all test cases
How?
Œg+2/€UF - Main link: a                 e.g. [2,2,2,4,4,8]
Œg       - group runs of equal elements      [[2,2,2],[4,4],[8]]
   2/€   - pairwise reduce for each with
  +      -     addition                      [[4,2],[8],[8]]
      U  - reverse (vectorises)              [[2,4],[8],[8]]
       F - flatten list                      [2,4,8,8]

Java 8, 130 114 bytes
Edit:

-16 bytes off. Thanks to @Kevin Cruijssen.

Snipet:
s->{int j=0,i=s.length,l[]=new int[i];for(;--i>-1;[j++]=s[i]==s[i-1]?s[i--]*2:s[i]);return Collection.reverse(l);}

Code:
public static int[] shift(int[]a){
  List<int> out = new ArrayList<>();
  for(int i = s.length-1; i>-1;i--){
    if(s[i]==s[i-1]){
      out.add(s[i]*2);
      i--;
    }else{
      out.add(s[i]);
    }
  }
  return Arrays.reverse(out.toArray());
}


Undefined Behavior Killed My Cat Undefined Behavior Killed My Cat

It's well known that undefined behavior can kill your cat [citation needed].
But can it?

Your Task

Write a program that invokes undefined behavior.
Describe a scenario that starts with the above program being run, resulting in a Felis catus ending its life while in your ownership, as a result of the aforementioned UB.
Estimate the probability for each stage in the scenario.
Calculate the total probability that a single run of the program would kill your cat.

Rules

This is a popularity-contest, so be creative if you can.
This is a programming related challenge, so the chain of events should be mostly within the computer, not in the real world (of course, if has to reach the real world if that's where your cat is).
If you choose a language that doesn't have undefined behavior, use something similar.
No animals may be harmed in the production of your answer.

Scoring

Vote count plus the scenario's total probability (which can't exceed 1).

Example in C:

main(){printf();}

Scenario:

printf called with garbage from the stack - undefined behavior. Probablity: 100%.
The first parameter happens to be the string Your cat is ugly!. Probablity: (1/256)17 = (1.148 * 10-37)%.
Seeing the message, you pick up your gun and shoot your cat. Probability: 3%.
The cat dies. Probability: 93%.

Total probability: (3.202 * 10-39)%.

C

Most answers to this question misinterpreted the question in that it was killing the cat process on a UNIX system. Here is a program which can cause the demise of a biological lifeform of the species Felis Cattus as specificed by the question.

This example runs on Windows, but it could be easily ported to most UNIX operating systems by replacing iexplore -k with the command to launch an installed web browser.

#include <stdlib.h>
#include <stdio.h>

int main() {
    char i; // uninitialised
    printf("Redirecting you to a website which will inform you how to properly feed your cat.");
    if (i != 42) {
         system("iexplore -k https://pets.stackexchange.com/questions/tagged/cats+diet");
    } else {
         system("iexplore -k https://cooking.stackexchange.com/questions/tagged/chocolate");
    }
    return 0;
}

This program pretends to provide advise about cat diet to the user.

It will start Internet Explorer and direct the user to pets stackexchange listing lots of helpful questions about how to feed cats. There is, however, a low (1/256) chance that it will send the user to cooking stackexchange instead listing tips how to prepare dishes containing chocolate, which is highly toxic to cats. To make matters worse, it will launch internet explorer in kiosk mode (fullscreen), which hides the address bar and is hard to escape from for a non-tech-savy user.

This clever ruse will coax the user into feeding their cat chocolate believing that it is an appropriate diet for it, thus causing them to inadvertedly kill it.

Java

According to spec java.util.Date will have undefined behaviour. So try your luck:

import java.util.Date;

public class App3
{
    public static void main (String args[])
    {
        String aliveOrDead;
        Date d = new Date(-1000,-1000,-1000);
        aliveOrDead = (d.getTime()<0)? "dead" : "alive";
        System.out.println("The cat is:" +aliveOrDead );
    }
}


Shortest Floor Function Your task is to implement a floor function in as few bytes as possible.

A floor function is a function that takes a real number and returns the largest integer less than or equal to the input.

Your program should support both positive and negative inputs.  Since it is provably impossible to support all real numbers you need only support a reasonable subset of them.  This subset should include positive numbers, negative numbers and of course numbers that are not integers.  Such number systems include fixed-point numbers, floating point numbers and strings.

Your code may be a complete program or function.

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

PARI/GP (10)

In gp (and some other languages) x%1 gives the decimal part of x:

f(x)=x-x%1

NOTE: For negative x, x%1 returns (1 - abs(decimal part of x)), so the above works both for positive and negative numbers.

TI-Basic, 4 bytes

X-fPart(X

fPart( is a one-byte token, stands for 'fractional part' and returns anything right of the decimal point. Parentheses don't need to be closed in TI-Basic.


Find a Similar Number We consider two integers to be similar if, when written in decimal, have the same length, and if we compare characters in any two positions for both decimal strings, the comparison results (less, equal or greater) must be the same in both strings.

Formally, for two number that can be written as decimal strings \$a_1a_2\cdots a_n\$, \$b_1b_2\cdots b_m\$, they're similar if and only if \$n=m\$ and \$a_i<a_j\ \leftrightarrow b_i<b_j\$ (\$\leftrightarrow\$ means if and only if) for all \$ i,j \in [1,n]\$.

For example, 2131 and 8090 are similar. 1234 and 1111, 1234 and 4321 are not similar.

The challenge

For a given positive integer, find a different non-negative integer similar to it. You can assume at least one such integer exists.

Your implementation shouldn't be too inefficient. It must be at least able to pass the samples in around one hour on an average computer. (If it doesn't end in a few seconds, consider providing a screenshot running it)
Your code can take the input and output as integers, strings or lists of digits. Standard loopholes are forbidden.

Since this is a code-golf, the shortest code in bytes wins!

Examples

It's (quite) possible to have different outputs on these inputs as long as inputs and outputs are different and similar.

1 - 0
3 - 9
9 - 1
19 - 23
191 - 121
1111 - 2222 (0 is not considered valid)
2020 - 9393
2842 - 1321
97892 - 31230
113582 - 113452
444615491 - 666807690
87654321000 - 98765432111
98765432111 - 87654321000
526704219279 - 536714329379
99887766553210 - 88776655443210

Sample inputs as a list:

1,3,9,19,191,1111,2020,2842,97892,113582,444615491,87654321000,98765432111,526704219279,99887766553210

Python 3, 58 52 bytes

lambda n:[9-(9in n)-sum(x>d for x in{*n})for d in n]

Try it online!

Input: The number n, as a list of digits.
Output: A similar number, as a list of digits.

-6 bytes thanks to @xnor!

How:
Reverses the list of unique digits, then maps them to 9,8,7,... or 8,7,6,... depending on whether n contains the digit 9 or not.
For example:

               | n = 1827 | n = 7899
Reverse unique |   8721   |   987
Maps to        |   9876   |   876
Results        | m = 6978 | m = 6788

Old solution

Python 3, 80 bytes

f=lambda n,i=9:(i in n)^(i-1in n)and[[d,d^i^~-i][i-2<d<=i]for d in n]or f(n,i-1)

Try it online!

Input: The number n, as a list of digits.
Output: A similar number, as a list of digits.

-1 byte thanks to @KevinCruijssen!

How
The solution tries to find a pair of consecutive digits \$(i-1,i)\$ such that one digit appears in \$n\$, and the other doesn't. It then replaces all occurrences of one digit with the other.
The pair of digits are searched from \$(8,9)\$ downward, in order to discourage replacing 1 with 0.

This is a port of @Surculose Sputum's solution in APL2.

U←((A⍳A)=⍳⍴A)/A←,A
((9∊A)⌽⌽⍳10)[U[⍒U]⍳A]

It presupposes that A is a vector of numbers and that ⎕IO=0


Prepare data for JS renderer It's asked to write a script to generate a source data to feed a JavaScript renderer.
JS Renderer documentation
The JS renderer is this script:

function o(x){
  r=x.split(' ');
  (d=document).write('<style>i{position:absolute;width:10;height:10;background:#000}</style>');
  for(i=0;i<r.length;++i){c=r[i].split(',');d.write('<i style=top:'+(e=eval)(c[0])+';left:'+e(c[1])+'></i>')
  }
}

It takes as input a list of X/Y coordinates separated by spaces and commas and prints on DOM the points as 10×10 pixel squares.
For example, if you call the script with:
o('0,0 10,0 20,0 30,0 40,0 20,10 20,20 0,30 10,30 20,30 30,30 40,30 0,50 10,50 20,50 30,50 40,50');

It will print:

Notice that the values can be expressed as calculations, so it will accept:
o('10*2,50/5');

Your task
Write a script that, given as input a string of characters ([A-Z0-9 ]; uppercase letters, numbers, spaces) prints on stdout the coordinates to feed the JS renderer.
Rules

The "line-height" of the characters should be of at least 50px
Your script doesn't need to run the JS parser
The expected output format is: x,y x,y x,y x,y
The shortest code wins

Bonus: if you could reduce the length of the JS renderer without changing the behavior would be great :)

JavScript 278

Slightly smaller renderer.

function o(x){
 (d=document).write('<style>i{position:absolute;width:10;height:10;background:#000}</style>');
  var r=/([^ ]+),([^ ]+)/g,e=eval
  while((m=r.exec(x)))d.write('<i style=top:'+e(m[1])+'px;left:'+e(m[2])+'px></i>')
}

JavaScript that writes coords to console.

function a(s) {
r=''
c=document.createElement('canvas')
c.width=c.height=w=40
t=c.getContext("2d")
t.fillText(s,0,8)
d=t.getImageData(0,0,w,w).data
x=y=0
for(p=3;p<6400;p+=4)x%=w,y+=x++?0:1,r+=d[p]>9?y+'*10,'+x+'*10 ':''
return r
}
var coords = a('TEST 9');
console.log(coords);


Generate Pascal's triangle Pascal's triangle is generated by starting with a 1 on the first row. On subsequent rows, the number is determined by the sum of the two numbers directly above it to the left and right.

To demonstrate, here are the first 5 rows of Pascal's triangle:

    1
   1 1
  1 2 1
 1 3 3 1
1 4 6 4 1

The Challenge

Given an input n (provided however is most convenient in your chosen language), generate the first n rows of Pascal's triangle. You may assume that n is an integer inclusively between 1 and 25. There must be a line break between each row and a space between each number, but aside from that, you may format it however you like.

This is code-golf, so the shortest solution wins.

Example I/O

> 1
1
> 9
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1

C, 311 bytes
r(int*s,int*o,int n){int h=1;while(h<=n){if(h==2){printf("%d %d\n",1,1);o[0]=1;o[1]=1;}else if(h==1){printf("%d\n",1);o[0]=1;}else{int j=0;int*s_p=s,*o_p=o;*o_p++=1;printf("1 ");while(j<(h-2)){*o_p+=*s_p++;*o_p+++=*s_p;printf("%d ",*(o_p-1));j++;}*o_p=1;printf("1\n");}memcpy(s,o,100);memset(o,0,100);h++;}}

The complete, readable version of the program is below:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void row(int *s,int *o,int n)
{   int h = 1;

    while (h <= n)
    {

    if(h==2){printf("%d %d\n",1,1);o[0]=1;o[1]=1;}

    else if(h==1){printf("%d\n",1);o[0]=1;}

    else
    {
        int j = 0; int *s_p=s,*o_p=o;*o_p++ =1;printf("1 ");

        while(j<(h-2))
        {
            *o_p += *s_p++;

            *o_p++ += *s_p;

            printf("%d ",*(o_p-1));

            j++;
        }

        *o_p=1;printf("1 ");puts("");
    }
        memset(s,0,100);memcpy(s,o,100);memset(o,0,100);h++;

    }

}

int main(int argc,char ** argv)
{
    const int n = strtol(argv[1],0,10);

    row(n);
}


Hash collision: "NO" means "YES" This Code Golf was inspired by the recent Daily WTF article You Can't Handle the True!, which features a string comparison written as:

String yes = "YES";
if ((delay.hashCode()) == yes.hashCode())

Imagine the trouble it would have caused for Steve's team if Java's String.hashCode method just happened to be implemented in a way that "YES".hashCode() == "NO".hashCode().  So, the challenge I propose here is:

  Write, in as few characters as possible, a hash function (I'll call it
  h) with a string parameter and integer return value, such that
  h("YES") is equal to h("NO").

Of course, this would be trivial to do with a function like def h(s): return 0, which makes a hash collision for every string.  To make this challenge more interesting, you must abide by the following additional rule:

  Of the other 18 277 possible strings consisting of three or fewer
  uppercase ASCII letters (^[A-Z]{0,3}$), there must be no hash
  collisions.

Clarification (pointed out by Heiko Oberdiek): The input string may contain characters other than A-Z, and your code must be able to hash arbitrary strings.  (You may, however, assume that the input is a character string rather than a null pointer or an object of some other data type.)  However, it does not matter what the return value is for strings that do not match ^[A-Z]{0,3}$, as long as it's an integer.

Furthermore, to obfuscate the intent of this function:

  Your code must not include any of the letters 'Y', 'E', 'S', 'N', or
  'O' (in either upper- or lowercase) within character or string
  literals.

Of course, this restriction doesn't apply to language keywords, so else, return, etc. are fine.

32-bit Python 2.x (19)

hash(w*9)%537105043

RSA uses a semiprime modulus, and that makes it secure, so using one with my hash algorithm should surely make it even better!1

This is a pure math function, works for all strings (hell, works for any hashable Python object), and doesn't contain any conditionals or special-casing! 32-bit Python can typically be called as python-32 on most systems that have both installed2.

I've tested this, and it returns 18,278 different values for the 18,279 3-letter-or-less uppercase strings. Assigning this to a function takes 11 more bytes:

h=lambda w:hash(w*9)%537105043

and h('YES') == h('NO') == 188338253.

64-bit Python 2.x (19)

hash(w*2)%105706823

Same deal as above.

To come up with these numbers, a little bit of modular math was used. I was looking for a function f and a modulus n such that hash(f('YES')) % n == hash(f('NO')) % n. This is equivalent to testing that n divides d = hash(f('YES')) - hash(f('NO')), i.e. we only have to check the factors of d for suitable values of n.

The ideal n is in the neighbourhood of 20000**2 to reduce the chance of a birthday paradox collision. Finding a suitable n turns out to be a bit of trial and error, playing with all the factors of d (there usually aren't many) and different choices for the function f. Notice though that the trial and error is only needed because I wanted to make n as small as possible (for golfing). If that wasn't a requirement, I could just choose d as my modulus, which is usually sufficiently large.

Note too that you can't pull this trick off using just f(s) = s (the identity function) because the rightmost character of the string has essentially a linear relationship (actually an XOR relationship) with the final hash (the other characters contribute in a much more nonlinear way). The repetition of the string therefore ensures that the differences between the strings are amplified to eliminate the effect of changing only the rightmost character.

1 This is patent nonsense.
2 Python string hashing depends on major version (2 vs 3) and bitness (32-bit vs 64-bit). It does not depend on platform AFAIK.

Here's a super lame one. SO LAME IT DOESN'T EVEN WORK

Python 2.7 - 79 bytes

def h(s):n=sum(100**i*ord(c)for i,c in enumerate(s));return (n-7978)*(n-836989)

First we get the sum of (each character's ascii value) * 100^(that character's position in the string). Then we multiply (that result - 7978) and (that result - 836989) to get our final answer. 7978 and 836989 are the results for "YES" and "NO" of the first bit, so for YES and NO we're multiplying by 0.

This shouldn't have any collisions? I don't feel like testing against 18000 possible counterexamples, but if there was an unintended collision I can throw another 0 on that 100 and then there really shouldn't be any collisions.

Disappointed that I couldn't use a lambda for this, but I didn't want to do the whole calculation twice so I had to save it to a variable.

Please don't let this win. It's super lame and I don't deserve it.


A newly discovered number: bleen! "The Nobel Prize in mathematics was awarded to a California professor who has discovered a new number! The number is bleen, which he claims belongs between 6 and 7."  --George Carlin

In this challenge, you will print all Integers, inclusive, within the given input range.  Print numbers ascending or descending according to their input order.  That is, for input [n1, n2], print ascending if n1 < n2, descending if n1 > n2.

Since bleen is now an Integer number it may be used as input.  It must also be included in the output, between 6 and 7 where applicable.  Also note that -bleen exists between -7 and -6.

Input

Two Integers [n1, n2] in the range [-10, 10], inclusive, via your programming language's input of choice.

(Input may also contain bleen and -bleen!)

Output

Print all Integers starting at n1 and ending with n2, including the newly discovered bleen between 6 and 7.  Output can be a range of character separated numbers in some form your language supports - that is, comma or space separated.  One trailing space of output is okay.

Examples

Input:  1 10
Output: 1 2 3 4 5 6 bleen 7 8 9 10

Input:  -9 -4
Output: -9 -8 -7 -bleen -6 -5 -4

Input:  -8 bleen
Output: -8 -7 -bleen -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 bleen

Input:  9 1
Output: 9 8 7 bleen 6 5 4 3 2 1

Input:  2 -bleen
Output: 2 1 0 -1 -2 -3 -4 -5 -6 -bleen

Input:  -bleen 0
Output: -bleen -6 -5 -4 -3 -2 -1 0

Input:  bleen bleen
Output: bleen

Input:  2 2
Output: 2

Additional notes

You may write a program or function and use any standard method of receiving input and providing output.

You may use any programming language, but standard loopholes are not allowed.

This is code-golf, so the shortest valid answer – measured in bytes – wins.

Python 3, 132 130 bytes

r=round
bleen=6.1
m=1.08
a,b=eval(input())
d=1-2*(a>b)
print(*[[r(i/m),"-bleen"[i>0:]][i*i==49]for i in range(r(m*a),d+r(m*b),d)])

Takes input in the following example format:

-8, bleen

Python 2, 100 bytes

The first four lines generate the list [-10, -9, -8, -7, 'bleen', -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 'bleen', 7, 8, 9, 10]. The next line gets input and stores it in s and e. The last two lines use .index() and list slicing notation to get the correct range.

a=range(-10,11)
b="bleen"
c=a.insert
c(17,b)
c(4,b)
s,e=eval(input())
d=a.index
print a[d(s):d(e)+1]

Works in the same way as Leaky Nun's answer but developed independently. Stole an input method from orlp.

Ungolfed:

array = range(-10, 11)
array.insert(17, "bleen")
array.insert(4, "bleen")
start, end = eval(input())
print array[array.index(start):array.index(end) + 1]


Alphanumeric Hello World Your goal is to write "Hello, World!" (minus the quotes). This is a popularity-contest, so most up votes  wins. Code length will be used to break ties.
Anything goes, as long as it is within the following rules:

All characters must be either letters or numbers, so you may only use characters in the string "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".
All code you use must be in one file, with the exception of imported modules/classes/whatever they're called in your favourite language.
Only the standard libraries/frameworks for your language of choice are allowed (for example, Python's Math module is allowed, but Numpy, Scipy, and Pygame are not). I will allow TkInter as it is the de facto standard for GUIs in Python.
No input is permitted, be it reading from stdin, reading a file, displying an image, or reading from the web.

+10 brownie points if you figure out how to do it in Java without bending the rules.

On your marks, get set, code!

EDIT: braces ({}), brackets ([]), and parentheses (()) are allowed as this would be pretty much impossible for most languages without them. I'm also removing the character limit rule. Hopefully this will make it more interesting.

EDIT^2: white space is also allowed. My brain isn't working properly, sorry. >.<

Perl

Some say perl is a language full of ascii noise and random symbols like $... That is not true :P

s zzHelloq worldmz and s zqzchr 44ze and s zmzchr 33ze and print

  Let's break this up into subexpressions:
(s zzHelloq worldmz) and (s zqzchr 44ze) and (s zmzchr 33ze) and (print)

 It should be obvious that it executes from left to right as long as every expression returns true. But what on earth is s zqzchr 44ze?
In perl, there is a group of "quote-like operators" which includes  q(str), qw(li st), /regex/, s/from/to/ among other things. It turns out all of these operators can use almost any character as a delimeter, with a couple pecularities: opening parethesis has to be closed by a matching closing parenthesis, and if you wish to use a letter as a delimiter you have to put a space after the operator letter (to disambiguate it from a bareword).
In this case we see three uses of the s/// (regex substitution) operator:
s//Helloq worldm/
s/q/chr 44/e
s/m/chr 33/e
All delimited by the character z. The /e flag on the last two causes the substitution to be interpreted as code to be evaluated, rather literal text.
A fairly well-known fact about perl is that most operations default to operating on the $_ builtin variable unless otherwise specified. All these three substitutions and the print operate on $_ in this case, so first we put the words Hello world into the variable, then we fix the punctuation by using the numeric ascii values of the characters, then we print the contents of the variable.

Common Lisp

This almost works, except that - isn't allowed.  If only there were the functions stringCapitalize and codeChar instead…

(mapcar (lambda (x)
          (princ (string-capitalize x)))
        (list (quote hello)
              (code-char 44)
              (code-char 32)
              (quote world)
              (code-char 33))))

The nice thing here is that string-capitalize takes a string designator, which can be a string, symbol, or character.  Sample use:

CL-USER> (mapcar (lambda (x)
                   (princ (string-capitalize x)))
                 (list (quote hello)
                       (code-char 44)
                       (code-char 32)
                       (quote world)
                       (code-char 33)))
Hello, World!


Print a Negative of your Code Consider a square of printable ASCII characters (code points 0x20 to 0x7E) for side length N, like the following (here, N = 6):

=\
 g \
7
m+y "g
  L ~
e> PHq

We also require each row and each column to contain at least 1 space and 1 non-space character. (The above example satisfies this.)

We define the negative of such a square, to be a square of the same size, where each space is replaced with a non-space and vice versa. E.g., the following would be a valid negative of the above example:

  1234
a b cd
 ZYXWV
   !
{} [ ]
  ?

The choice of non-space characters is irrelevant (as long as they are from the printable ASCII range).

The Challenge

You're to write a program, with square source code with side length N > 1, which prints a negative of itself to STDOUT. Trailing spaces have to be printed. You may or may not print a single trailing newline.

The usual quine rules also apply, so you must not read your own source code, directly or indirectly. Likewise, you must not assume a REPL environment, which automatically prints the value of each entered expression.

The winner is the program with the lowest side length N. In the event of a tie, the submission with the fewest non-space characters in the source code wins. If there's still a tie, the earliest answer wins.

Deadfish~, 10x10 square
 {(icdcccc
 ccccc{dd}
 ddc{d}){i
 ii}ii}cic
 cccccccch
 hhhhhhhhh
 hhhhhhhhh
 hhhhhhhhh
 hhhhhhhhh
h

Outputs
!
!
!
!
!
!
!
!
!
 !!!!!!!!!

Explanation
{           repeat 10 times
(           skip following the first time (if accumulator is 0), so repeat x9
ic          increment (will be 32 once this is run , so 33, then print as '!'
dccccccccc  decrement (to 32) and print 9 times
{dd}dd      decrement to 10 for newline
c{d}        print and decrement to 0
)           end if
{iii}ii     increment accumulator to 32
}           end loop
c           print as character (' ')
iccccccccc  increment and print 9 '!'s
h           stop the program, anything after this is junk

Try it online!


The Cake Cutting Contest It's my 17th birthday and you're invited to my party!

And as always at parties, there will be cake.

One cake...

And you need as much of it as possible.

As this is a fair party, each of us will say how much of my cake we want and the person who said the smallest amount will get it. Then everyone else gets to repeat the process until the cake is gone.

Challenge

Given the input through command line arguments in the form of total-degrees degrees-left total-people people-left, output to standard output integer-bid-in-degrees.
If your bid was the lowest, you receive that amount of cake and are out for the round.
If your bid wasn't lowest, your bot gets to bid on the remaining cake.
In the case that the lowest bids are the same, the person removed will be chosen at random.
At the end of a round, once all the cake is gone or there is nobody left to bid on it, the person with the most cake wins!
In the case at the end of a round and two people have the same sized biggest slice, the winner is chosen at random from the drawing entries.

Gameplay

There will be 17 rounds, the overall winner will be the entry with the most wins overall.
In the case of a draw, rounds will be played until there is a clear winner.
Each day, I will update the current scores so that people can upgrade their entry.

Submission

You should write your entry as

  Bot Name, Language

Insert
Code
Here

  Explanation/Random stuff here

If your entry isn't formatted in this way, the controller will NOT be able to run your entry. If I find this has happened to your entry, I will either notify you in a comment, and/or edit the answer into the correct format.

Your entry and file storage

Your bot may store files in the ./data/ directory and nowhere else.

Not required but please store your files as botname*
You may not write files in this format if botname is not your entries name.
This means you are allowed to overwrite other files you find that don't appear in this format. You shouldn't do this deliberately, please be sporting.
Your bot must not assume that the files it requires are present but it can assume ./data/ exists.
This is because I occasionally wipe the ./data directory, I will do this when the rounds actually start. (But not between them)

Your bot may not delete files at all
Your bot is only allowed to read files in the ./data/ directory

This means you may look at other entries files

Results:

Meek won the contest! Well done @Cabbie407

And now for some random stats:

A list of positions each bot came in: (Well done to any bot appearing in this list, you came in the top 5 at least once!)

Meek, Meek, Eidetic, Eidetic, Meek, Eidetic, Eidetic, Meek, Meek, Meek, Saucy, Meek, Givemethecake, Givemethecake, Givemethecake, Meek, Eidetic
Eidetic, Eidetic, Meek, AlCakeSurfer, Eidetic, AlCakeSurfer, Meek, MyFairPlusAThird, Eidetic, Eidetic, Eidetic, Eidetic, MyFairPlusAThird, MyFairPlusAThird, Meek, MyFairPlusAThird, AlCakeSurfer
Reallythecake, AlCakeSurfer, AlCakeSurfer, Meek, AlCakeSurfer, Meek, AlCakeSurfer, AlCakeSurfer, Reallythecake, AlCakeSurfer, Meek, MyFairPlusAThird, Eidetic, Eidetic, Eidetic, Eidetic, Reallythecake
AlCakeSurfer, Reallythecake, MyFairPlusAThird, MyFairPlusAThird, MyFairPlusAThird, MyFairPlusAThird, MyFairPlusAThird, Eidetic, AlCakeSurfer, MyFairPlusAThird, MyFairPlusAThird, Relinquisher, Relinquisher, bill, bill, Relinquisher, MyFairPlusAThird
bill, MyFairPlusAThird, bill, bill, bill, bill, Relinquisher, Relinquisher, MyFairPlusAThird, Relinquisher, bill, Reallythecake, bill, ALittleOffTheTop, ALittleOffTheTop, bill, bill

The full log file for the cometition whilst running can be found here. Sorry about the format change partway through.

I will not be running the contest again, if you want to post more entries, you're welcome to do so, the controller can be found on my github repo for this contest.

Magician, Java

public class Magician{
    public static void main(String[] args){
        System.out.println(720);
    }
}

The number 720 is magical.

This is was meant to test the controller and is not a serious entry.

Pig, Java

public class Pig{
    public static void main(String[] args){
        System.out.println(args[1]);
    }
}

This pig is probably not smart enough to bid low.


GottaFix for WannaCrypt? Warning
The answers to this challenge test for a specific version of the patch that helps stop WannaCrypt/WannaCry attacks. Depending on your operating system, you may have a different patch. The best way to protect yourself is to make sure your PC is fully up to date and be careful when opening attachments and web links.

Introduction
I like to think programmers are inherently good people, even if some aren't so nice, so lets help people make sure they are protected with the MS17-010 patch.
Challenge
Your challenge is to write a full program or function that returns a truthy or falsey value depending on if the MS17-010 patch is installed on the current operating system.
Input and Output
Input: No input required
Output: A truthy or falsey value (Indicate which is used for each case).
An error/exception can be considered a falsey value.
Rules

Your code should run (and output correctly) on at least one windows operating system for which the patch is available, but doesn't have to run on every operating system (Please state any limitations).
Standard loopholes apply
This is code-golf, so the submission with the least amount of bytes wins!

PowerShell 2.0, 24 20 16 bytes
hotfix KB4012212

-4 bytes thanks to @whatever by removing  -id.
-4 bytes thanks to @DankoDurbić by changing get-hotfix to hotfix.
KB4012212 is the patch for Windows 7. This can be replaced with any KB-code from the linked page of the patch.
Will return the Source, Description, HotFixID, InstalledBy and InstalledOn information when it's installed as truthy value, and will give an error if it's unable to find it as falsey value.
Here is an example of both a truthy and falsey output (so KB4012212 is installed on my machine, but KB4012215 is not):

DISM, 40 bytes
dism/online /get-packages|find "4012212"

Explanation:
dism             Deployment Image Servicing and Management command-line
/online          Look at current running PC's Operating System
/get-packages    Display some basic information about all packages in the image
|find "..."      Looks for the string in the complete output

Outputs the package identity if it's installed, or nothing otherwise.
In the screenshot below, patch 4012212 is installed, and 4012215 is not.


Draw an ASCII-O'-Lantern for Halloween Halloween is almost here, the holiday after which most people need to wean themselves off a hollow diet of sugar.

Write a program that takes in a positive integer. If the integer is less than 31 (1 through 30), output this ASCII-art jack-o'-lantern, looking to the right as if looking forward to Halloween:

 _____I_____
| | | | | | |
| | |^| |^| |
| | | |^| | |
| | |VvVvV| |
|_|_|_|_|_|_|

If the input is 31 (the October date Halloween is on), output the same ASCII-o'-lantern, but looking left:

 _____I_____
| | | | | | |
| |^| |^| | |
| | |^| | | |
| |VvVvV| | |
|_|_|_|_|_|_|

If the input is greater than 31, output a bloated-looking ASCII-o'-lantern who probably ate too much candy. He can face either left or right since queasyness can be disorientating. So output:

 _____I_____
| | | | | | |
| |o| |o| | |
| | |^| | | |
| |XXXXX| | |
|_|_|_|_|_|_|

or

 _____I_____
| | | | | | |
| | |o| |o| |
| | | |^| | |
| | |XXXXX| |
|_|_|_|_|_|_|

Whichever you prefer. It may even be different for different numbers above 31.

The shortest code in bytes wins.


Binary representation of a number is palindrome or not? Write a full program  to find whether the binary representation of a number is palindrome or not?

Sample Input
5

Sample Output
YES

Print YES if binary representation is palindrome and NO otherwise.

Python - 46 chars

n=bin(input())[2:]
print'YNEOS'[n!=n[::-1]::2]

Java, 97 85 characters

return Integer.toBinaryString(i).equals(new StringBuffer(s).reverse()+"")?"YES":"NO";

    String s=Integer.toBinaryString(i);
    return s.equals(new StringBuffer(s).reverse()+"")?"YES":"NO";


Improvise a Hardware Random-Number Generator Your task is to improvise a hardware random-number generator with whatever hardware you have lieing around.
Challenge
Write a program with the following properties:

It prints either 0 or 1 (and nothing else).
The output depends on a physical process and not just the internal state of the computer.
There is no relation between outputs of subsequent runs (one minute apart).
The output is not predictable with any realistic effort.
The probability of the output being 0 is between 0.2 and 0.8.
It runs in less than a minute with a reasonably high probability.

You must explain why your program has these properties, if it is not obvious.
Clarifications and Restrictions
The following may seem like an awful lot of restrictions for a popularity contest, but ultimatively it’s all to ensure that the program remains within the spirit of the question, somewhat works and to avoid solutions which are popular due to being a total overkill but are ultimatively rather boring.

The system time does not count as a physical process.
You may use any consumer-grade hardware you like from 8-inch floopy-disk drives to a USB rocket launcher to headphones – unless it is intended for random-number generation. A piece of hardware is consumer-grade, if it is mass-produced and costs less than 1000 $/€/£, so you cannot use radio telescopes, the CERN, MRIs or your home-built particle detector.
You can only make the most basic assumptions on the state and alignment of the hardware such as being switched on (if it has a power switch) and being properly installed and functional. For example you can assume a CD drive to be generally capable of reading a disk and not to be jammed, but you cannot assume it to be open or closed or to contain a disk. In another example you cannot assume two pieces of hardware to be aligned to allow for a special interaction, but you can assume them to be in the same room.
You may leave the hardware in any state you like, unless you break it.
You can and must assume the hardware to be in a natural environment, but nothing more. For example you can assume that the hardware is not positioned in a in tank of liquid helium nor in an extremely sound- and lightproof room nor in space. However, you cannot assume any sound- and lightsources to be present except those that are only avoidable with radical efforts.
Your program must run on a standard desktop computer with a non-esoteric operating system of your choice. You may employ any software that is not specifically designed for random-number generation.
You cannot assume Internet access.
You can neither assume humans to be present nor absent, but you can assume that nobody intentionally interfers with your program, e.g., by manually stopping a fan or running a program that does nothing but switching off the microphone as often as possible.
You can only make the most basic assumptions about the software settings. For example, you can assume drivers to be installed and activated but you must be prepared for the sound to be muted.
You may leave the software settings in any state you like.

Bonus
A special bounty was awarded to a particularly short solution. This was rather by numbers of instructions and similar than by characters. The winners were (tied according to my criteria):

This answer by Franki.
This answer by Tejas Kale.

I could only award one answer and Tejas Kale’s answer won by lot.

Shell
Reads a single sample from the microphone stream and prints its least-significant bit, which should be dominated by noise.
EDIT: Changed to unmute the microphone ... and everything else too!
# Warning - unmutes EVERYTHING!
for DEV in `amixer | grep Simple | sed -e "s/.*'\(.*\)'.*/\\1/" -e "s/ /~/g"`
do
    amixer -q -- sset "`echo $DEV | sed 's/~/ /g'`" unmute 100% 2>/dev/null
done

echo $(( `od -N1 -d < /dev/dsp | head -n1 | sed 's/.* //'` & 1 ))

Bash
I took Soham’s own suggestion (using top):
echo $[`top -bn1|sed 's/[^1-9]/+/g'`0&1]

Edit: It works the same way Soham's does. It turns all non numeric characters in the output of top into '+' and then evaulates the parity of the resulting string.
the 'b' flag to top runs it in batch mode so that it reports all processes, not just the first screenful and 'n1' says to just run 1 iteration of top.


How many countries are in the European Union? Tonight, 31 January 2020, Brexit will happen and the United Kingdom will leave the European Union, the first time that the number of EU member states will decrease.

Your job is to take a date and output the number of EU1 members on that date, according to the following table:

| Start      | End        | Number of members
| 0          | 1957-12-31 | 0
| 1958-01-01 | 1972-12-31 | 6
| 1973-01-01 | 1980-12-31 | 9
| 1981-01-01 | 1985-12-31 | 10
| 1986-01-01 | 1994-12-31 | 12
| 1995-01-01 | 2004-04-30 | 15
| 2004-05-01 | 2006-12-31 | 25
| 2007-01-01 | 2013-06-30 | 27
| 2013-07-01 | 2020-01-31 | 28
| 2020-02-01 | Inf        | 27

Input may take one of the following forms:

your language's date format
any ordering of integers for year, month and day with any separator (e.g. YYYYMMDD or DD/MM/YYYY)
number of days lapsed since some epoch.

This is code-golf, so shortest code wins!

1. or EEC before 1993

Javascript, 85 83 Bytes
a=d=>d<0?0:d<180?6:d<276?9:d<336?10:d<444?12:d<556?15:d<588?25:d<666?27:d<745?28:27

It takes an input as a float as the months / fractions of months passed since 1958-01-01
(0 for 1958-01-01T00:00:00 and a negative number for any previous date)
(Since number of days from some epoch is allowed, I assume that also a number of months is valid, as well)
Try it Online

80 Bytes
(credits: Arnauld)
a=d=>d<0?0:d<180?6:d<276?9:d<336?10:d<444?12:d<556?15:d<588?25:27+(d>=666&d<745)

Sad to see you go, UK


A crowd of blank stares Problem

Given no input write a program or a function that outputs or returns the following string:

(<(<>(<>.(<>.<(<>.<>(<>.<>)<>.<>)>.<>).<>)<>)>)

Rules

Shortest program wins.
Trailing whitespace allowed.
Trailing newlines allowed.
Unused parameters for functions allowed.

05AB1E, 16 bytes

"(<>.".∞ηJÀ24£.∞

Try it online!

Explanation

"(<>."             # push this string
                   # STACK: "(<>."
      .∞           # intersected mirror
                   # STACK: "(<>.<>)"
        η          # compute prefixes
         J         # join to string
                   # STACK: "((<(<>(<>.(<>.<(<>.<>(<>.<>)"
          À        # rotate left
           24£     # take the first 24 chars
                   # STACK: "(<(<>(<>.(<>.<(<>.<>(<>."
              .∞   # intersected mirror
                   # STACK: "(<(<>(<>.(<>.<(<>.<>(<>.<>)<>.<>)>.<>).<>)<>)>)"


Dihedral group D4 composition with custom labels The dihedral group \$D_4\$ is the symmetry group of the square, that is the moves that transform a square to itself via rotations and reflections. It consists of 8 elements: rotations by 0, 90, 180, and 270 degrees, and reflections across the horizontal, vertical, and two diagonal axes.

The images are all from this lovely page by Larry Riddle.

This challenge is about composing these moves: given two moves, output the move that's equivalent to doing them one after another. For instance, doing move 7 followed by move 4 is the same as doing move 5.

Note that switching the order to move 4 then move 7 produces move 6 instead.

The results are tabulated below; this is the Cayley table of the group \$D_4\$. So for example, inputs \$7, 4\$ should produce output \$5\$.

\begin{array}{*{20}{c}}
   {} & {\begin{array}{*{20}{c}}
   1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\
\end{array} }  \\
   {\begin{array}{*{20}{c}}
   1  \\
   2  \\
   3  \\
   4  \\
   5  \\
   6  \\
   7   \\
   8   \\
\end{array} } & {\boxed{\begin{array}{*{20}{c}}
   1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\
   2 & 3 & 4 & 1 & 8 & 7 & 5 & 6\\
   3 & 4 & 1 & 2 & 6 & 5 & 8 & 7\\
   4 & 1 & 2 & 3 & 7 & 8 & 6 & 5\\
   5 & 7 & 6 & 8 & 1 & 3 & 2 & 4\\
   6 & 8 & 5 & 7 & 3 & 1 & 4 & 2\\
   7 & 6 & 8 & 5 & 4 & 2 & 1 & 3\\
   8 & 5 & 7 & 6 & 2 & 4 & 3 & 1\\
\end{array} }}  \\
\end{array}

Challenge

Your goal is to implement this operation in as few bytes as possible, but in addition to the code, you also choose the labels that represent the moves 1 through 8. The labels must be 8 distinct numbers from 0 to 255, or the 8 one-byte characters their code points represent.

Your code will be given two of the labels from the 8 you've chosen, and must output the label that corresponds to their composition in the dihedral group \$D_4\$.

Example

Say you've chosen the characters C, O, M, P, U, T, E, R for moves 1 through 8 respectively. Then, your code should implement this table.

\begin{array}{*{20}{c}}
   {} & {\begin{array}{*{20}{c}}
   \, C  \, & \, O \, & M \, & P \, & U \, & \, T \, &  \, E \,  &  R \, \\
\end{array} }  \\
   {\begin{array}{*{20}{c}}
   C  \\
   O  \\
   M  \\
   P  \\
   U  \\
   T  \\
   E   \\
   R   \\
\end{array} } & {\boxed{\begin{array}{*{20}{c}}
   C & O & M & P & U & T & E & R \\
   O & M & P & C & R & E & U & T\\
   M & P & C & O & T & U & R & E\\
   P & C & O & M & E & R & T & U\\
   U & E & T & R & C & M & O & P\\
   T & R & U & E & M & C & P & O\\
   E & T & R & U & P & O & C & M\\
   R & U & E & T & O & P & M & C\\
\end{array} }}  \\
\end{array}

Given inputs E and P, you should output U. Your inputs will always be two of the letters C, O, M, P, U, T, E, R, and your output should always be one of these letters.

Text table for copying

1 2 3 4 5 6 7 8
2 3 4 1 8 7 5 6
3 4 1 2 6 5 8 7
4 1 2 3 7 8 6 5
5 7 6 8 1 3 2 4
6 8 5 7 3 1 4 2
7 6 8 5 4 2 1 3
8 5 7 6 2 4 3 1

Ruby, 18 bytes

->a,b{a+b*~0**a&7}

Ungolfed

->a,b{ (a+b*(-1)**a) % 8}
# for operator precedence reasons,
#-1 is represented as ~0 in the golfed version

Try it online!

Uses the following coding numbers 0 to 7

In order native to the code:

Native     Effect                    Codes per
Code                                 Question
0          rotate 0 anticlockwise    1C
1 /        flip in y=x               7E
2 /|       rotate 90 anticlockwise   2O
3 /|/      flip in x axis            5U
4 /|/|     rotate 180 anticlockwise  3M
5 /|/|/    flip in y=-x              8R
6 /|/|/|   rotate 270 anticlockwise  4P
7 /|/|/|/  flip in y axis            6T

In order per the question

Native     Effect                    Codes per
Code                                 Question
0          rotate 0 anticlockwise    1C
2 /|       rotate 90 anticlockwise   2O
4 /|/|     rotate 180 anticlockwise  3M
6 /|/|/|   rotate 270 anticlockwise  4P
3 /|/      flip in x axis            5U
7 /|/|/|/  flip in y axis            6T
1 /        flip in y=x               7E
5 /|/|/    flip in y=-x              8R

Explanation

/ represents a flip in the line y=x and | represents a flip in the y axis.

It is possible to generate any of the symmetries of the group D4 by alternately flipping in these two lines For example / followed by | gives /| which is a rotation of 90 degrees anticlockwise.

The total number of consecutive flips gives a very convenient representation for arithmetic manipulation.

If the first move is a rotation, we can simply add the number of flips:

Rotate 90 degrees   +  Rotate 180 degrees = Rotate 270 degrees
/|                     /|/|                 /|/|/|

Rotate 90 degress   +  Flip in y=x        = Flip in x axis
/|                    /                     /|/

If the first move is a reflection, we find we have some identical reflections / and | symbols next to each other. As reflection is self inverse we can cancel out these flips one by one. So we need to subtract one move from the other

Flip in x axis     +  Flip in y=x        = Rotate 90 degrees
/|/                   /                    /|/ / (cancels to) /|

Flip in x axis     +  Rotate 90 degrees  = Flip in y=x
/|/                   /|                   /|/ /| (cancels to ) /

Wolfram Language (Mathematica), 7 bytes (UTF-8 encoding)

#⊙#2&

A pure function taking two arguments. The symbol rendered here as ⊙ is actually Mathematica's private Unicode symbol F3DE (3 bytes), which represents the function PermutationProduct.

Mathematica knows about dihedral groups, and it represents the elements of various groups as permutations, written using the Cycles command. For example, running the command

GroupElements[DihedralGroup[4]]

yields the output:

{Cycles[{}], Cycles[{{2, 4}}], Cycles[{{1, 2}, {3, 4}}],
 Cycles[{{1, 2, 3, 4}}], Cycles[{{1, 3}}], Cycles[{{1, 3}, {2, 4}}],
 Cycles[{{1, 4, 3, 2}}], Cycles[{{1, 4}, {2, 3}}]}

PermutationProduct is the function that multiplies group elements when written in this form.

Since we are allowed to choose our own labels, this function assumes these labels for the group elements; the assocation between these labels and the ones in the problem post is given by:

Cycles[{}] -> 1
Cycles[{{1, 2, 3, 4}}] -> 2
Cycles[{{1, 3}, {2, 4}}] -> 3
Cycles[{{1, 4, 3, 2}}] -> 4
Cycles[{{2, 4}}] -> 5
Cycles[{{1, 3}}] -> 6
Cycles[{{1, 2}, {3, 4}}] -> 7
Cycles[{{1, 4}, {2, 3}}] -> 8

tl;dr There's a builtin.


print "Hello, World!" Yes, really.  Print it with a hardware printer  to create a hard copy.

Send the necessary commands/data to your printer such that the following text is printed on a piece of paper:

  Hello, World!

You may use any local- or network-connected printer that is available to you.

If your printer allows, you should use 8pt or greater text in black ink on white paper.

The text should appear on its own line.  It may be left or right positioned as you wish.

Digital photographic/video/GIF evidence of submissions will be helpful.

If your hardware cannot do paper, but allows other exotic hardcopy production such as 3D printing, CNC machining, or printing at the atomic level, then I will happy to accept such interesting submissions.

To clarify, the question asks "Send the necessary commands/data to your printer".  The implication of this is that no further user input should be required.  Opening a print dialog is not sufficient.  Existing answers that do this as of 10:48am PST 31st Dec 2016 will be grandfathered (but not upvoted by me).

Bash, 21 19 bytes
lp<<<Hello,\ World!

And there it is.
2 bytes saved thanks to Dennis!

Javascript, 36 bytes

print(document.write`Hello, World!`)


N in a row (or column)! N in a row

Input:

The character and a 2-Dimensional array.

The array with a size of N x N where 1 <= N <= 26, it will be filled randomly like so:

N = 1

A

N = 2

B | A
-----
A | B

N = 3

A | B | C
----------
B | A | B
----------
C | A | C

As N increases by 1, so does the number of letters. A = 1, B = 2, C = 3. There will always be N number of each letter.
N = 3, there will be 3 As... 3 Bs... 3 Cs...
N = 4, there will be 4 As... 4 Bs... 4 Cs... 4 Ds...
N = 5, there will be 5 As... 5 Bs... 5 Cs... 5 Ds... 5 Es...

Output:

The original matrix as well as a manipulated matrix where any given letter has N in a row (or column).

Manipulations occur by swapping two letters within the 2-D grid that are adjacent on the x or y axis. You may not swap characters over the boundaries of the array. I.E. You cannot swap Array[0][N-1] with Array[0][0]. You also may not swap characters diagonally.

Objective:

Your job is to pick a character C to solve for given N. Swap characters within the matrix so that there are N of C in the same row or column.

Examples:

N = 3, C = A

A | B | C
----------
B | A | B
----------
C | A | C

Swap array[0][0] (A) with array[1][0] (B)
resulting in

B | A | C
----------
B | A | B
----------
C | A | C

Complete

N = 4, C = B

A | B | C | D
--------------
B | D | B | A
--------------
D | A | C | C
--------------
A | C | B | D

swap array[1][0] (B) with array[1][1] (D)

A | D | C | D
--------------
B | B | B | A
--------------
D | A | C | C
--------------
A | C | B | D

swap array[2][3] (B) with array[3][3] (D)

A | D | C | D
--------------
B | B | B | A
--------------
D | A | C | C
--------------
A | C | D | B

swap array[3][3] (B) with array[3][2] (C)

A | D | C | D
--------------
B | B | B | A
--------------
D | A | C | B
--------------
A | C | D | C

swap array[3][2] (B) with array[3][1] (A)

A | D | C | D
--------------
B | B | B | B
--------------
D | A | C | A
--------------
A | C | D | C

Complete!

Any letter can be chosen to solve for. As this is code-golf the shortest code wins!

Have Fun and Good Luck!

Python 2, 270 bytes

from random import*
e=lambda s,n:all(sum(map(ord,l))!=n*65for l in s)
R,C,d=randint,choice,[-1,1]
def w(a):
 print a;n=len(a);
 while e(a,n)and e(zip(*a),n):
    if n==2:x,y,w,z=0,0,0,1
    else:x,y=R(1,n-2),R(1,n-2);w,z=x+C(d),y+C(d)
    a[y][x],a[z][w]=a[z][w],a[y][x]
 print a

Always chooses A as character to complete a row/col. Performs random swaps until goal is reached.
Accepts the matrix as list of lists, usage for testing:
A="""ADCD
BBBA
DACC
ACDB"""
a=[[c for c in l] for l in A.split('\n')]
w(a)

R, 41 40 bytes
This answer provides valid output, although it does not follow the algorithm suggested. Since a limitless number of swapping manipulations are permitted, restrictions on what manipulations are allowed (e.g. the diagonal restriction) are irrelevant, as any permutation of the matrix can be arrived at through a (possibly large) number of swaps. So, I've bypassed the "switching around" part of the matrix manipulation and just went straight to outputting a solved matrix.
Anonymous function that takes a matrix as input, and returns a list of the original matrix and the "solved" matrix.
function(m)list(m,array(sort(m),dim(m)))

Example input:
matrix(c("A","B","A","C","C","B","A","C","B"),3)

That is,

[,1] [,2] [,3]
[1,] "A"  "C"  "A"
[2,] "B"  "C"  "C"
[3,] "A"  "B"  "B"

Gives the following output:
[[1]]
     [,1] [,2] [,3]
[1,] "A"  "C"  "A"
[2,] "B"  "C"  "C"
[3,] "A"  "B"  "B"

[[2]]
     [,1] [,2] [,3]
[1,] "A"  "B"  "C"
[2,] "A"  "B"  "C"
[3,] "A"  "B"  "C"

While we're at it, here's a function to generate possible input matrices:
make_matrix = function(N) matrix(sample(rep(LETTERS[1:N], N)), N)

This function takes the first N letters of the alphabet, repeated N times (i.e. N*N characters) and randomly samples from them. The characters are then arranged into a matrix with N rows (and, implicitly, N columns).
Examples:
make_matrix(1)
     [,1]
[1,] "A"
> make_matrix(3)
     [,1] [,2] [,3]
[1,] "C"  "B"  "C"
[2,] "C"  "A"  "B"
[3,] "A"  "B"  "A"

And used with our function above (named f):
> f(make_matrix(10))
[[1]]
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,] "J"  "C"  "D"  "G"  "E"  "C"  "H"  "G"  "I"  "J"
 [2,] "C"  "D"  "A"  "C"  "H"  "A"  "A"  "E"  "H"  "I"
 [3,] "C"  "B"  "E"  "G"  "C"  "F"  "J"  "A"  "H"  "J"
 [4,] "I"  "E"  "F"  "I"  "B"  "G"  "E"  "F"  "F"  "C"
 [5,] "H"  "I"  "F"  "D"  "B"  "G"  "H"  "A"  "J"  "H"
 [6,] "J"  "E"  "D"  "J"  "A"  "D"  "B"  "D"  "G"  "B"
 [7,] "D"  "B"  "E"  "A"  "G"  "H"  "C"  "C"  "J"  "B"
 [8,] "H"  "D"  "I"  "J"  "B"  "I"  "I"  "F"  "E"  "I"
 [9,] "G"  "F"  "F"  "A"  "J"  "E"  "B"  "A"  "E"  "D"
[10,] "H"  "G"  "A"  "B"  "D"  "I"  "C"  "G"  "F"  "F"

[[2]]
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [2,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [3,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [4,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [5,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [6,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [7,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [8,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [9,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
[10,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"


Javascript left-pad golf Introduction

In the wake of the left-pad npm package fallout, let's have a code golf for implementing left-pad.

The left-pad function consists of 2 default arguments and 1 additional argument, in the form string, length, (padchar). If the padchar is not given, this is standardized to a space character. Let's take an example with two arguments:

left_pad("abc", 6)

First, we observe the length of the string, which is 3. After this, we need to pad this string in the left until the length of the full string has reached the length given in the function. In this case 6. Since the padchar is not given, we need to pad this with spaces:

   abc

This is a string with 3 spaces and the initial string, resulting into a string with length 6. Here is an example with the padchar given:

left_pad("abc", 6, "-")

We just do the same as the example above, but replace the spaces with the padchar. In this case, the hyphen:

---abc

The Task

Given the string, length, and maybe the additional argument padchar, output the left-padded string. You can assume that the length number is equal or greater than the length of the string. The padchar will always consist of 1 character.

Test cases

left_pad("string", length, ("padchar")) === "left-padded string"

left_pad("foo", 5) === "  foo"
left_pad("foobar", 6) === "foobar"
left_pad("1", 2, "0") === "01"
left_pad("1", 2, "-") === "-1"

This is code-golf, so the submission with the smallest number of bytes wins!

Pyth, 13 11 bytes

+*.xwd-Qlzz

Try it here.

Takes input from STDIN as the string on the first line, length on the second line, and padding char optionally on a third line.

C, 64 bytes

f(s,n,c,p){return memset(p,c,asprintf(&p,"%*s",n,s)-strlen(s));}

Try it here.


Avoid the evil integers! You are developing some code to generate ID numbers. Policy requires that no ID numbers include the digit sequence 666.

Create a function (or your language's equivalent) which takes a positive integer parameter and returns the next integer that does not include 666 when that integer is expressed in decimal. (60606 is fine, 66600 is not.)

Your code must not use a loop that adds one until it finds a result that fits the rules.

f(1) returns 2.
f(665) returns 667.
f(665999999) returns 667000000 without having looped a million times.
(Following examples added since the question was first posed.)
f(666666666) also returns 667000000.
f(66600) returns 66700.
f(456667) returns 456670.

UPDATE:
Replacing 666 with 667 won't work if there's more than one 666 in the input.

Python, no string manipulation

def f(n):
    n += 1
    p = 1
    m = n
    while m:
        if m % 1000 == 666:
            n += p - n % p
        p *= 10
        m /= 10
    return n

Works by finding powers of 10, p, where 666 appears, and adding p - n % p to n which replaces 666xxxxx with 66700000.


Many programs, few characters Your task is to create many programs. The first outputs 1, the second outputs 2, etc. The higher you can go, the better!

However, all of these programs must be made the same list of characters. You can choose which characters to put in the list. Each program can only use a character as many times as it appears in the list.

For example, using the Python shell:

List of characters:  +122
-------
Program 1:      1
Program 2:      2
Program 3:      1+2
Program 4:      2+2   (2 appears twice in the list)

It is impossible to make a program which prints 5 without reusing the + character, so there are a total of 4 programs possible with this list. (Only consecutive numbers starting from 1 count. We therefore ignore other numbers we can make, like 12.)

Scoring

Let N be the number of programs.
Let S be the size of the shortest program, or 15, whichever is less.
Let L be the length of the list.

Your score is N / Γ((L-S)/5), where Γ is the gamma function.

In the example above, N is 4; S is 1; L is 4; the score is 4 / Γ((4-1)/5) = 2.686.

Highest score wins!

Below is a Stack Snippet to help calculate your score:

var g=7,C=[0.99999999999980993,676.5203681218851,-1259.1392167224028,771.32342877765313,-176.61502916214059,12.507343278686905,-0.13857109526572012,9.9843695780195716e-6,1.5056327351493116e-7];function gamma(z) {if(z<0.5){return Math.PI/(Math.sin(Math.PI*z)*gamma(1-z));}else{z--;var x=C[0];for(var i=1;i<g+2;i++)x+=C[i]/(z+i);var t=z+g+0.5;return Math.sqrt(2*Math.PI)*Math.pow(t,(z+0.5))*Math.exp(-t)*x;}}function go(){var N=parseInt(jQuery('#programs').val()),S=parseInt(jQuery('#shortest').val()),L=parseInt(jQuery('#length').val());if(S>15){S=15;}jQuery('#score').val(N/gamma((L-S)/5));}
<form>

Number of programs:	<input id='programs' oninput="go()" value='0'/>

Size of shortest program:	<input id='shortest' oninput="go()" value='0'/>

Size of list:	<input id='length' oninput="go()" value='0'/>

Score:	<output id='score'>0</output>

</form>
Code from http://stackoverflow.com/a/15454784/3148067

Rules

You can use programs or functions.
You may use different languages for different numbers.
Each program must work by itself. For example, you can not assume that the first program will run before the second program.

Pyth, Score of 1.664 * 10^26

Since you only have L different chars to choose from, you can maximal generate O(L!) different programs.

So lets build something really close: By indexing permutations of the alphabet:

I use a following list of characters is:

abcdefghijklmnoppqrstuvwxxyzG."

With these characters I can generate 26!-1 different programs like this:

Program 1: x.pG"abcdefghijklmnopqrstuvwxzy
Program 2: x.pG"abcdefghijklmnopqrstuvwyxz
Program 3: x.pG"abcdefghijklmnopqrstuvwyzx
  ...
Program 403291461126605635583999999: x.pG"zyxwvutsrqponmlkjihgfedcba

Notice I didn't use "abcdefghijklmnopqrstuvwxyz" (sorted alphabet), since I give an index of 0.

So we got N = 403291461126605635583999999, S = 15, L = 31, which gives a score of 1.663767345141228e+26.

Explanation:

x.pG"...
   G       G is pre-initialized with "abc...xyz"
 .p        gives all possible permutations
x   "...   the index of "..." in the permutation list

Notice, that none of the programs will actually run. Because of memory and time.

edit:

You can even get way higher. For instance by using also the uppercase letters. Gives me a score of about 10^76.

edit 2: a runnable version

Since none of the programs above is actually runnable, here's one that works.

x.pSK""Kabcde

The programs are:

Program 1: x.pSK"abced"K
Program 2: x.pSK"abdce"K
Program 3: x.pSK"abdec"K
  ...
Program 117: x.pSK"edbca"K
Program 118: x.pSK"edcab"K
Program 119: x.pSK"edcba"K

Here's an online Demonstration.

Explanation:

x.pSK"abced"K
    K"abced"   K = "abced"
   S           sort it
 .p            generate all permutations of sorted(K)
x           K  index of K in the permutations.

N = 119, S = 13, L = 13 gives a score of 0. But If we simply use a dummy char to the list we get N = 119, S = 13, L = 14 and a score of 25.92

Of course we can use more chars than abcde for the permutation. If we use n different chars, we get N = n!-1, S = 15, L = n+8, which gives a score of ~n!/(n-7)!. So we can get pretty much an unlimited score.

(redone as previous was loophole - sorry about that).
(edited to fix score: N=8, due to gaps - forgot about that)

Unix/Korn Shell  (Score: 9.016)
(going a very simple method, just trying to maximize the Gamma function)

List is: (L=13)

 echo 12345678

8 Programs:

  echo 1
  echo 2
  ...
  echo 8

so:

  N=8
  S=6
  L=13

Hopefully no loopholes this time around - I just crunched the formula and figured out where to maximize it.
For my method, it maximized at S=6 and L=13.
:)

Wolfram Alpha tells me:

8 / Γ((13-6)/5) = 9.016


Reverse order of words in a string inplace The Task

You are given a mutable string that matches [a-z]+( [a-z]+)*.
You must mutate it into the string which contains the same words, but in reverse order, so that "hello there everyone" becomes "everyone there hello".
You are not permitted to use more than a constant amount of additional memory (so no copying the entire string or any whole word into a buffer you just allocated).
There are no time constraints. Being hopelessly inefficient will not harm your score.
If your language of choice does not permit mutation of strings, arrays of characters are an acceptable substitute.

Your Score

Your score is counted purely on the number of assigments you make to string elements (small scores are best). If you use a library function that writes to the string, its writes also count.
Suppose the number of assignments you need for input s is n(s). Then your score is the maximum (pedantically, supremum) over all inputs s (matching the regex specified above) of n(s)/length(s). If you cannot calculate this precisely, you can use the lowest upper bound that you can prove.
You can break a tie if you can prove that your algorithm uses asymptotically fewer assignments (this can happen even if you have the same score, see below). If you can't do this, you can break a tie by showing that you use less additional memory. However, the first tie-break condition always takes precedence.
For some inputs every character needs to change, so it is not possible to score less than 1.
I can think of a simple algorithm with score 2 (but I'm not entering it).

Notes on suprema and ties

A supremum of a set of numbers is the smallest number that is not smaller than any of them. This is much like the maximum of a set, except that some infinite sets like {2/3, 3/4, 4/5, 5/6, ...} have no single maximum element, but will still have a supremum, in this case 1.
If you manage to "save" only a constant number of assignments over my algorithm of score 2 (say), your score will still be 2, because you'll get arbitrarily close to 2 the larger your input gets. However, you win on the tie-break if it comes to that.

Perl, score 1.3̅

For each non-space character one assignment is performed, and for each space character two assignments. Because space characters cannot amount to more than one half the total number of characters, the worst case score is 1.5.

The algorithm hasn't changed, but I can prove a lower upper bound. Let us make two observations:

Spaces directly across from spaces do not need to be swapped.
Single character words directly across from spaces are not swapped during the main phase, but only once at the end.

It can then be seen that the theoretical 'worst case' with asymptotically 1/2 spaces is not worst case at all: ab c d e f g h i ...

$ echo ab c d e f g h i j k l m n o p q r s t u v w x y z|perl reverse-inplace.pl
z y x w v u t s r q p o n m l k j i h g f e d c ab
swaps: 51; len: 50
ratio: 1.02

In fact, it's quite a good case.

In order to prevent observation one and two above, each one-character word would need to be repositioned into the middle of a word three or more characters long. This would suggest a worst case containing asymptotically 1/3 spaces: a bcd a bcd a ... bc

$ echo a bcd a bcd a bcd a bcd a bcd a bc|perl reverse-inplace.pl
bc a bcd a bcd a bcd a bcd a bcd a
swaps: 45; len: 34
ratio: 1.32352941176471

Or equivalently, only two-character words: a bc de fg hi jk ...

$ echo a bc de fg hi jk lm no pq rs tu vx xy|perl reverse-inplace.pl
xy vx tu rs pq no lm jk hi fg de bc a
swaps: 49; len: 37
ratio: 1.32432432432432

Because the worst case contains asymptotically 1/3 spaces, the worst case score becomes 1.3̅.

#!perl -l
use warnings;

$words = <>;
chomp($words);
$len = length($words);
$words .= ' ';
$spaces = 0;
# iterate over the string, count the spaces
$spaces++ while $words =~ m/ /g;

$origin = 0;
$o = vec($words, $origin, 8);
$cycle_begin = $origin;
$swaps = 0;

# this possibly terinates one iteration early,
# if the last char is a one-cycle (i.e. moves to its current location)
# one-cycles previous to the last are iterated, but not swapped.
while ($i++ < $len - $spaces || !$was_cycle) {
  $w_start = rindex($words, ' ', $origin);
  $w_end = index($words, ' ', $origin);
  $pos = ($origin - $w_start) - 1;
  $target = $len - ($w_end - $pos);
  $t = vec($words, $target, 8);

  if ($t == 32) {
    $target = $len - $target - 1;
    $t = vec($words, $target, 8);
  }

  # char is already correct, possibly a one-cycle
  if ($t != $o) {
    $swaps += 1;
    vec($words, $target, 8) = $o;
  }

  $origin = $target;
  $o = $t;
  if ($origin == $cycle_begin) {
    if ($i < $len - $spaces) {
      # backtrack through everything we've done up to this point
      # to find the next unswapped char ...seriously.
      $origin += 1;
      if (vec($words, $origin, 8) == 32) {
        $origin += 1;
      }
      $bt_origin = 0;
      $bt_cycle_begin = 0;
      while ($bt_cycle_begin < $origin) {
        $w_start = rindex($words, ' ', $bt_origin);
        $w_end = index($words, ' ', $bt_origin);
        $pos = ($bt_origin - $w_start) - 1;
        $target = $len - ($w_end - $pos);
        $t = vec($words, $target, 8);

        if ($t == 32) {
          $target = $len - $target - 1;
          $t = vec($words, $target, 8);
        }

        if ($target == $bt_cycle_begin) {
          $bt_origin = ++$bt_cycle_begin;
          if (vec($words, $bt_origin, 8) == 32) {
            $bt_origin = ++$bt_cycle_begin;
          }
        } else {
          $bt_origin = $target;
        }

        if ($target == $origin) {
          $origin += 1;
          if (vec($words, $origin, 8) == 32) {
            $origin += 1;
          }
          $bt_origin = $bt_cycle_begin = 0;
        }
      }
    }

    $cycle_begin = $origin;
    $o = vec($words, $origin, 8);
    $was_cycle = 1;
  } else {
    $was_cycle = 0;
  }
}

for $i (0..$len/2-1) {
  $mirror = $len - $i - 1;
  $o = vec($words, $i, 8);
  $m = vec($words, $mirror, 8);
  # if exactly one is a space...
  if (($o == 32) ^ ($m == 32)) {
    $swaps += 2;
    vec($words, $mirror, 8) = $o;
    vec($words, $i, 8) = $m;
  }
}

chop($words);
print $words;
print "swaps: $swaps; len: $len";
print 'ratio: ', $swaps/$len;

Edit: Added a swap counter, and the ratio.

Input is taken from stdin. Sample usage:

$ echo where in the world is carmen sandiego|perl reverse-inplace.pl
sandiego carmen is world the in where
swaps: 35; len: 37
ratio: 0.945945945945946

Method

To begin, the first character of the string is moved to its final destination. The character just replaced is then moved to its destination, etc. This continues until one of two conditions is met:

The character should be swapped with a space.
When this occurs, the character is not swapped with the space, but rather into the mirror position of the space. The algorithm continues from that position.
A cycle has been reached.
When the target returns to the initial starting position of the current cycle, the next unswapped character (or rather, any unswapped character would do) needs to be found. To do this under constant memory constraints, all swaps that have been made up to this point are back-tracked.

After this phase, each non-space character has been moved at most once. To finish, all space characters are swapped with the characters at their mirror positions, requiring two assignment operations per space.

Javascript

function reverseWords(input) {
    if (input.match(/^[a-z]+( [a-z]+)*$/g)) {
        return input.split(' ').reverse().join(' ');
    }
}

Usage:

> reverseWords('hello there everyone');
'everyone there hello'

I get the strange feeling I missed something...


Write a mathematical function whose result is "hello world" Write a mathematical function that results in an integer representation of "hello world"

For example "hello world" in hex is 68656c6c6f20776f726c64 so the goal will be to write a mathematical program that results in a number representing "hello world".

Here is a example of a possible solution using python:

print(2*2*3*59*61*97*416510539*72330832279)==int("68656c6c6f20776f726c64", 16)

Any type of mathematical equations could be used, such as: powers, series, factorials, and other mathematical operations.

The rules:

You may select your own way to encode/represent "hello world" as an integer. Hash functions are also allowed
Mathematical libraries (e.g. numpy, GMP) are allowed.
The intention is to focus on the mathematics part

I'll do better than just printing it, I'll print it infinitely many times!

The rational number

1767707668033969 / 3656158440062975

returns the following base-36 expansion:

0.helloworldhelloworldhelloworldhelloworldhelloworld...

Try it out! (Wolfram Alpha)

Or, if you want a more subliminal message, try:

2399843759207982499621172523113947162810942763812298565948669
/ 1357602166130257152481187563160405662935023615

Which returns (again in base 36):

helloworld.helpimtrappedinanumberfactoryhelpimtrappedinanumberfactoryhelpimtrappedinanumberfactory...

If your program worked with only integers, you'd never see the fractional part.


Hello, World! (Every other character) Write a program that prints "Hello, World!".
But also, if you take only the first, third, fifth, etc. characters of your program, the resulting program should still print "Hello, World!".

If your program is:

abc
def

It should output "Hello, World!", but so should

acdf

No solutions with fewer than 2 characters.

Python 3, 61 bytes

rant="partisn't"
print(("HHeelllloo,,  WWoorrlldd!!"""[::2]))

Try it online!

Abusing the fact that print is a function in Python 3 :)

The least partisan solution you'll find here on PPCG.

Becomes

rn=print
rn("Hello, World!"[:])

Stacked, 60 bytes

'Hello, World!'  '''H e l l o ,   W o r l d !''' @oouutt out

Try it online!

I generated the second code with this snippet. Second code is:

'el,Wrd' 'Hello, World!' out u

The first one generates two strings, Hello, World! and 'H e l l o ,   W o r l d !'. The latter is saved to variable oouutt, and the former is printed.

The second one generates two strings, outputs the second, then errors after encountering u.


Shortest undefined behavior sample in C++ What's the shortest, well-formed C++ code that exhibits undefined behavior?

int main(){main;}

  3.6.1 Main function [basic.start.main]

  3 - [...] The function main shall not be used within a program.

Edit: this is diagnosable, so not UB.

int main(){for(;;);}

  1.10 Multi-threaded executions and data races [intro.multithread]

  24 - The implementation may assume that any thread will eventually do one of the following:
  — terminate,
  — make a call to a library I/O function,
  — access or modify a volatile object, or
  — perform a synchronization operation or an atomic operation.

int main(){int i=i;}

  4.1 Lvalue-to-rvalue conversion [conv.lval]

  1 - [...] If the object to which the glvalue refers is [...] uninitialized, a program
  that necessitates this conversion has undeﬁned behavior.

//^L.

Here ^L is the form feed character, which is part of the basic character set.  4 characters (a newline is not required per 2.2:2).  Undefined behaviour is per

  2.8 Comments [lex.comment]

  1 - If there is a
  form-feed or a vertical-tab character in [a //-style] comment, only white-space characters shall appear between it
  and the new-line that terminates the comment; no diagnostic is required.


Generate 100 Java Tuple classes Write a script that writes to standard output, or your language's equivalent, 100 lines of (valid) Java code that begins with:

class Tuple1 {public Object _0;}
class Tuple2 {public Object _0,_1;}
class Tuple3 {public Object _0,_1,_2;}
class Tuple4 {public Object _0,_1,_2,_3;}
class Tuple5 {public Object _0,_1,_2,_3,_4;}
class Tuple6 {public Object _0,_1,_2,_3,_4,_5;}
class Tuple7 {public Object _0,_1,_2,_3,_4,_5,_6;}
class Tuple8 {public Object _0,_1,_2,_3,_4,_5,_6,_7;}
class Tuple9 {public Object _0,_1,_2,_3,_4,_5,_6,_7,_8;}
class Tuple10 {public Object _0,_1,_2,_3,_4,_5,_6,_7,_8,_9;}
class Tuple11 {public Object _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10;}
class Tuple12 {public Object _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11;}

The last line should begin with class Tuple100.

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

vim 56 54 keystrokes
iclass Tuple1 {public Object _0;}<esc>qyYp<C-a>$y2bPr,<C-a>q98@y

Since V is backwards compatible, you can Try it online!
This is the perfect task for vim! I might golf it a little bit more later. Also note that <c-a> means Control-A, and it counts as one keystroke.
Explanation:
iclass Tuple1 {public Object _0;}<esc>         'Enter the starting text

qy                          'Start recording in register y
  Yp                        'Yank the current line, the print on the line below
     <C-a>                  'Increment the next digit to occur by one
          $                 'Move to the end of this line
           y2b              '(yank) 2 words (b)ack. This will grab '_0;'
              P             'Print the previously yanked word before the cursor.
               r,           '(r)eplace the char under the cursor with a comma.
                 <c-a>q     'Increment the current digit, then stop recording
                       99@y 'Playback macro 'y' 99 times.

Java 112 bytes

void p(){String x="_0";for(int i=0;i<100;){out.format("class Tuple %d {public Object %s;}\n",++i,x);x+=",_"+i;}}

Un-golfed

import static java.lang.System.*;

public class I {
public static void main(String[] args){
    I m=new I();
    m.p();
}
    void p(){
    String x="_0";
    for(int i=0;i<100;){
        out.format("class Tuple %d {public Object %s;}\n", ++i, x);
        x+=",_"+i;
    }
}

}