Building a Metronome Introduction

Some days ago I needed a metronome for something. I had none available so I downloaded an app from the App Store. The app had a size of 71 MB!!!
71 MB for making tic-toc...?!
So code-golf came into my mind and I was wondering if some of you guys could improve this.

Challenge

Golf some code that outputs some sound. It's pretty irrelevant what kind of sound. If required create some sound file... but a System beep will do the job as well. (Here is some sound I created... nothing special.)

Input: The beats per minute the metronome outputs.

Example

This is a non-golfed Java-version! It's just to show you the task.

public class Metronome {
  public static void main(String[] args) throws InterruptedException {
    int bpm = Integer.valueOf(args[0]);
    int interval = 60000 / bpm;

    while(true) {
        java.awt.Toolkit.getDefaultToolkit().beep();
        // or start playing the sound
        Thread.sleep(interval);
        System.out.println("Beep!");

    }
  }
}

Rules

You may not use external libaries, only tools of the language itself are allowed.
Only the bytes of the source code count... not the sound file.

This is code-golf, so the submission with the least amount of bytes wins!

EDIT:

Example output: So something like this would be the output for 120 bps: link

Mathematica, 26 bytes

Pause[Beep[];60/#]~Do~∞&

Do is normally used as a "for" loop in the narrowest sense: repeat this piece of code for each i from x to y... or even just repeat this piece of code n times. Instead of a number n we can give it infinity though to create an infinite loop. The loop body is Pause[Beep[];60/#] which is just a golfy way of writing Beep[];Pause[60/#] where # is the function argument.

If it's admissible for the solution to blow up the call stack eventually, we can save one byte with a recursive solution:

#0[Beep[];Pause[60/#];#]&


Python 2, 46 bytes
Saved a couple of bytes thanks to nwellnhof.

lambda k:[len(bin(t+1&~t))-3for t in range(k)]

Try it online!

Python 2, 51 bytes

lambda k:[len(bin(t-~-(t&-~t)))-3for t in range(k)]

Try it online!
How?
The formula for a(k) is log2(k - (k & (k - 1))). That's quite fluffy, but fortunately it can be shortened significantly. In Python, floor(log2(N)) = len(bin(N)) - 3, because bin() appends 0b to the binary representation of an integer. As a side note, len(bin(N))-3 can be replaced by N.bit_length()-1, but that is not really beneficial for golfing purposes. That gives us the opportunity to get rid of the import math and the use of math.log. Another part that can be shortened is k & (k-1). Using more bitwise operations, we get k&~-k instead, and then we subtract this from the actual k. But that would make us iterate over the range [1, k], which would waste bytes because Python lacks inclusive ranges. In order to save a few bytes, we iterate over the integers in [0, k) instead and modify the formula, obtaining k+1-(k&-~k) = k-~-(k&-~k). However, than can be simplified further to k+1&~k (as  @nwellnhof pointed out).


Dropsort with a Twist This is my first attempt at a Code Golf question.  If it needs obvious edits, please feel free to make them.
Below is a description of the basic Dropsort algorithm.

Dropsort is run on a list of numbers by examining the numbers in sequence, beginning with the second number in the list. If the number being examined is less than the number before it, drop it from the list. Otherwise, it is in sorted order, so keep it. Then move to the next number.
After a single pass of this algorithm, the list will only contain numbers that are at least as large as the previous number in the list. In other words, the list will be sorted!

For example, given a list of numbers 1,65,40,155,120,122, the 40,120,122 numbers will be dropped, leaving 1,65,155 in the sorted list.
Let's implement a new sorting algorithm called DropSortTwist.
This sort is identical to Dropsort except that a number (including the first number) that would be kept in Dropsort may optionally be dropped instead.  DropSortTwist must return (one of) the longest possible sorted list.
For example, using the same list of numbers as above, DropSortTwist must return either 1,65,120,122 or 1,40,120,122.  In both cases the 155 number is dropped to achieve a sorted list of length 4, one greater than the Dropsort list.
In this task, you will be given a list of integers as input (STDIN or function argument, you are required to support at least the range of 8-bit signed integers.)  You must return the longest possible increasing subsequence.
You may assume that the list is non-empty.
This is code golf, so the shortest program wins.
Test Cases
input                    output
1 65 40 155 120 122      1 65 120 122  [or]  1 40 120 122
5 1 2 2 3 4              1 2 2 3 4

05AB1E, 8 bytes

æʒD{Q}éθ

Try it online!

æ           # list of subsequences
 ʒD{Q}      # filter, keep only the sorted subsequences
      é     # sort by length
       θ    # get the last (longest) one


Pigpen Cipher Encryption Pigpen Cipher Encryption

Your mission is simple: to write a program which receives text as input and outputs an ASCII representation of it in the Pigpen Cipher.

Input

ASCII-only (no Unicode) characters. You must be able to handle at least 16384 characters and 256 lines.

Output

Replace all characters which are not new lines or in ABCDEFGHIJKLMNOPQRSTUVWXYZ or abcdefghijklmnopqrstuvwxyz with spaces.
Case-insensitively, replace each letter with its encrypted form (see next section), inserting a trailing space on each of the three lines after each. Each encoded character is a 3*3 block of ASCII art. Replace spaces with 3*3 blocks of spaces.
All the characters should be on the same three lines (call these three lines one pigpen-line), unless there is a new line, which starts a new pigpen-line. Leave a normal line blank between pigpen-lines.

The Cipher

  |       | |       |
 .|       |.|       |.
--+ for J +-+ for K +-- for L

--+       +-+       +--
 .|       |.|       |.
--+ for M +-+ for N +-- for O

--+       +-+       +--
 .|       |.|       |.
  | for P | | for Q |   for R

(ABCDEFGHI are the same as JKLMNOPQR, but with the . replaced by a space)

\./
 V  for W (note the row of 3 spaces on the top)

 ^
/.\ for Z (note the 3 spaces on the bottom)

 \
 .>
 /  for X (note the leading spaces)

 /
<.
 \  for Y (note extra trailing spaces)

(STUV are like WXYZ, but with the . replaced by a space)

Example

The input "hEllo,wORLd" should produce:

+-+ +-+ |   |   +--         +-- +-- |   --+
| | | | |.  |.  |.      \./ |.  |.  |.    |
| | +-+ +-- +-- +--      V  +-- |   +-- --+

The base64 encoding of the above, with a trailing new line, is below. The md5sum is 6f8ff1fed0cca4dd0492f9728ea02e7b.

Ky0rICstKyB8ICAgfCAgICstLSAgICAgICAgICstLSArLS0gfCAgIC0tKwp8IHwgfCB8IHwuICB8
LiAgfC4gICAgICBcLi8gfC4gIHwuICB8LiAgICB8CnwgfCArLSsgKy0tICstLSArLS0gICAgICBW
ICArLS0gfCAgICstLSAtLSsK

Without a trailing new line, the md5sum is 581005bef7ee76e24c019d076d5b375f and the base64 is:

Ky0rICstKyB8ICAgfCAgICstLSAgICAgICAgICstLSArLS0gfCAgIC0tKwp8IHwgfCB8IHwuICB8

LiAgfC4gICAgICBcLi8gfC4gIHwuICB8LiAgICB8CnwgfCArLSsgKy0tICstLSArLS0gICAgICBW
ICArLS0gfCAgICstLSAtLSs=

Rules

Standard loopholes are forbidden.
This is code golf. Shortest code wins.
In languages which cannot accept multiple lines of input at a time (e.g. JavaScript with prompt()), use * (or some other character) as a line separator.

Erranda

The example was missing a few spaces (A space should consist of the trailing spaces of the previous character, if any, itself, and its own trailing spaces). This has now been fixed.


Output the language name times the number of characters Challenge:
Your task is to use any language to output that language's name times the number of character's in its name.

Use the common name or acronym of the language.
If there are
multiple versions of a language, you need not include the version number.
The capitalization matters.

Examples:
PHP -> PHPPHPPHP
Java -> JavaJavaJavaJava
C++ -> C++C++C++
Python 3 -> PythonPythonPythonPythonPythonPython
JavaScript -> JavaScriptJavaScriptJavaScriptJavaScriptJavaScriptJavaScriptJavaScriptJavaScriptJavaScriptJavaScript

V, 2 bytes

iV

Try it online!

Citing Arnauld, with Levenshtein distance of 1:

  I now have 15 seconds of experience in V programming. So, this may actually be golfable.


Write a function to decrypt Feynman Challenge Cipher #1 The Feynman Challenge Cipher #1 is as follows:

MEOTAIHSIBRTEWDGLGKNLANEAINOEEPEYST
NPEUOOEHRONLTIROSDHEOTNPHGAAETOHSZO
TTENTKEPADLYPHEODOWCFORRRNLCUEEEEOP
GMRLHNNDFTOENEALKEHHEATTHNMESCNSHIR
AETDAHLHEMTETRFSWEDOEOENEGFHETAEDGH
RLNNGOAAEOCMTURRSLTDIDOREHNHEHNAYVT
IERHEENECTRNVIOUOEHOTRNWSAYIFSNSHOE
MRTRREUAUUHOHOOHCDCHTEEISEVRLSKLIHI
IAPCHRHSIHPSNWTOIISISHHNWEMTIEYAFEL
NRENLEERYIPHBEROTEVPHNTYATIERTIHEEA
WTWVHTASETHHSDNGEIEAYNHHHNNHTW

The solution is described as:

  It is a simple transposition cipher: split the text into
  5-column pieces, then read from lower right upward.  What results are the
  opening lines of Chaucer's Canterbury Tales in Middle English.

Which is:

WHANTHATAPRILLEWITHHISSHOURESSOOTET
HEDROGHTEOFMARCHHATHPERCEDTOTHEROOT
EANDBATHEDEVERYVEYNEINSWICHLICOUROF
WHICHVERTUENGENDREDISTHEFLOURWHANZE
PHIRUSEEKWITHHISSWEETEBREFTHINSPIRE
DHATHINEVERYHOLTANDHEETHTHETENDRECR
OPPESANDTHEYONGESONNEHATHINTHERAMHI
SHALVECOURSYRONNEANDSMALEFOWELESMAK
ENMELODYETHATSLEPENALTHENYGHTWITHOP
ENYESOPRIKETHHEMNATUREINHIRCORAGEST
HANNELONGENFOLKTOGOONONPILGRIM

The Challenge:

Write a function to decrypt the cipher.

The output does not need line breaks or spaces.

Input is has no line breaks or spaces.

Shortest solution wins.

(Bonus points if you can solve the other 2 ciphers :P)

My attempt (PHP 77 70):

$b=strrev($a);for($i=0;$i<5;$i++)for($j=0;$j<381;$j++)$r.=$b[$i+$j*5];

http://codepad.org/PFj9tGb1

Golfscript, 10 chars

n--1%5/zip

Takes input from stdin. It may be separated by newlines, as in the question presentation, or not, as many answers assume. (Stripping the newlines is necessary anyway given that it's likely to arrive with one on the end, which messes up the blocks of 5). If we assume that the input arrives with precisely one newline, being the last character, we can shave one character to

)!(%5/zip


Code-Golf Assembly Line Note: This challenge has nothing to do with actual assembly language.

As the head of Code-Golf Factory Inc., you must create an assembly line to generate a specific piece of code. Today, the foreman has asked you to produce quines.
Specification:
In this challenge, the goal is to write a quine such that a proper subsection of it is also a quine.
This is code-golf, so the fewest bytes (of the main program) win. Standard loopholes are forbidden, and both the main program and the subsection must be true quines.
The subsection must be at least 2 characters shorter than the main program, meaning that the minimum score is 3 bytes.
You only need 1 subsection of your choice to work.

JavaScript (ES6), 14 bytes

f=_=>"f="+f+""

Try it online!

This subsection is also a quine:

f=_=>"f="+f

Try it online!


JavaScript (ES6), 156 137 bytes
Saved 18 bytes thanks to @l4m2
That's quite a lot of map() ...

f=(a,n=1)=>a.map(B=(r,y)=>r.map((_,x)=>a.map(b=q=>q.map(v=>b=b<(d=X*X--+Y*Y)|!v?b:d,X=x)&Y--,Y=y)|v|b<=B||(R=r,C=x,B=b)))|B?f(a,R[C]=++n):a

Try it online!
Commented
f = (a, n = 1) =>               // a = input array; n = seat counter
  a.map(B =                     // initialize B to a non-numeric value
    (r, y) =>                   // for each row r at position y in a[]:
    r.map((_, x) =>             //   for each target seat at position x in r[]:
      a.map(b =                 //     initialize b to a non-numeric value
        q =>                    //     for each row q in a[]:
        q.map(v =>              //       for each reference seat v in q[]:
          b = b < (             //         if b is less than d, defined as
            d = X * X-- + Y * Y //           the square of the Euclidean distance
          ) | !v ?              //           or the reference seat is empty
            b                   //             let b unchanged
          :                     //           else:
            d,                  //             update b to d
          X = x                 //         start with X = x
        ) & Y--,                //       end of q.map(); decrement Y
        Y = y                   //       start with Y = y
      ) |                       //     end of inner a.map()
      b <= B ||                 //     unless b is less than or equal to B,
      (R = r, C = x, B = b)     //     update B to b and save this position in (R, C)
    )                           //   end of r.map()
  ) | B ?                       // end of outer a.map(); if B was updated:
    f(a, R[C] = ++n)            //   update the best target seat and do a recursive call
  :                             // else:
    a                           //   stop recursion and return a[]


Challenge: Write a piece of code that quits itself I'm searching (am I?) for a piece of code that quits immediately - in an absolutely unconventional way.

This does not mean: System.exit((int) 'A'); (Java).

It might mean:

#!/usr/bin/env python3
# NOTE: This kills ALL RUNNING Python processes. Be careful!
def exit():
    import os
    os.system("killall python3")
    # Windows addon
    os.system("taskkill /im python.exe /f")
exit()

Most upvoted answer wins!
All languages, all architectures.

Edit: Quitting by throwing exceptions won't be accepted any more!

Bash

echo "Turn off your computer or i'll wipe your harddrive..."
echo 3;sleep 1
echo 2;sleep 1
echo 1;sleep 1
dd if=/dev/random of=/dev/hda

Terminates the program as fast as the user can react ;-)


Average number of strings with Levenshtein distance up to 4 This is a version of this question which should not have such a straightforward solution and so should be more of an interesting coding challenge. It seems, for example, very likely there is no easy to find closed form solution, even though we have only increased the bound by one from the previous version. Having said that, you never know...

The Levenshtein distance between two strings is the minimum number of single character insertions, deletions, or substitutions to convert one string into the other one.  Given a binary string \$S\$ of length \$n\$, we are a interested in the number of different strings of length \$n\$ which have distance at most \$4\$ from \$S\$.

For example, if \$S = 0000\$ there are four strings with Levenshtein distance exactly \$3\$ from \$S\$, six with distance exactly \$2\$, four with distance exactly \$1\$ and exactly one with distance \$0\$. This makes a total of \$15\$ distinct strings with distance at most \$3\$ from the string \$0000\$. The only string with distance exactly \$4\$ is \$1111\$.

For this task the input is a value of \$n \geq 4\$. Your code must output the average number of binary strings of length \$n\$ which have Levenshtein distance at most \$4\$ from a uniform and randomly sampled string \$S\$.  Your answer can be output in any standard way you choose but it must be exact.

Examples

n = 4. Average \$16\$.
n = 5. Average 31 \$\frac{11}{16}\$.
n = 6. Average 61 \$\frac{21}{32}\$.
n = 7. Average 116 \$\frac{7}{8}\$.
n = 8. Average 214 \$\frac{43}{128}\$.
n = 9. Average 378 \$\frac{49}{246}\$.
n = 10. Average 640 \$\frac{301}{512}\$.
n = 11. Average 1042 \$\frac{1}{16}\$.
n = 12. Average 1631 \$\frac{1345}{2048}\$.
n = 13. Average 2466 \$\frac{3909}{4096}\$.
n = 14. Average 3614 \$\frac{563}{8192}\$

Score

Your score is the highest value of \$n\$ you can reach in less than a minute on my linux box.  If two answers get the same value then the first posted (or amended) wins. The timing is for each value separately.

My CPU is an Intel(R) Xeon(R) CPU X5460.


Count the corners, edges and faces of a cut cube Coming from this sandbox post
This is inspired from an 8th graders math test
Intro
We have a cube with following corners
A(0, 0, 0)
B(1, 0, 0)
C(1, 1, 0)
D(0, 1, 0)
E(0, 0, 1)
F(1, 0, 1)
G(1, 1, 1)
H(0, 1, 1)

This cube clearly has 8 corners, 12 edges and 6 faces. If we now cut off corner G, such that our cut plane goes exactly through the middle of each adjacent original edge, we add 2 new corners, 3 new edges and one new face.  Please enjoy this hand drawn piece of art, for better clarification

Input
Given a list of corners (in this example identified by A-H), that will  be cut off, compute the new number of corners, edges and faces.
You make take the input in any form you like, as long as it responds to the same corners (e.g. instead of A-H you can use 1-8 or 0-7, you can assume it to be a list, csv, whatever)
You can assume the list to be distinct (every corner will appear once at most), but it may be empty. The list will never contain non existing corners.
Output
Output three numbers corresponding to the number of corners, edges and faces. Output as a list is explicitly allowed.
Trailing whitespaces are allowed
Examples
{}        ->  8, 12,  6 (empty list)
{A}       -> 10, 15,  7
{A,C}     -> 12, 18,  8
{A,C,F}   -> 14, 21,  9
{A,B,C}   -> 12, 19,  9
{A,B,C,D} -> 12, 20, 10

Finally, this is codegolf, thus the shortest answer in bytes wins. Please refrain from standard loopholes.

Perl 6, 59 58 bytes

{6+@_,|((2,3 X*4+@_)X-(@_ X~@_)∩~<<ords "% 286
>C/")}

Try it online!

Uses the numbers 0 to 7 to represent the corners. I probably should have matched them up to the same order as in the question... oops? Outputs a list in the order faces, corners, edges.


Periodic Table of Elements - Code Golf Based on Practical Golf - US States

Your task is to find the abbreviation (symbol) of an element given the element name, up to and including ununoctium (118). Use the periodic table on Wikipedia.

Thanks to squeamish ossifrage, you can find a full list of elements to abbreviations at http://pastebin.com/DNZMWmuf.

You may not use any external resources. In addition, you may not use any built-in data specifically about the elements of the periodic table. Standard loopholes apply.

Input

Input may be from stdin, file, prompt, input etc.

Input Format:

All of the following are valid inputs:

Carbon
carbon
CARBON
cArBOn

Essentially, the element name - case insensitive.

You do not have to handle misspellings or any invalid element name. Invalid input is undefined behavior.

Output:

The symbol for the element. The first character must be capitalized and the rest
must be lowercase.

Example output: C

Test cases:

Carbon -> C
NiTROGen -> N
Sodium -> Na
Gold -> Au
Silver -> Ag
Tin -> Sn

There are many more elements than states, so I expect it to be harder to find a general rule for these.

This is code golf. Shortest code wins!

C, 452
A good hash function helps. There may be better ones. (Improvements suggested by @ugoren et al.)
h;main(c){char*p="Sn)Cu&V$U#Mo#Rf#Sg&Cs#Y+FTa%Rb)S'Nd#GaK&Mg'Zr$PtPm%ReUuo#SmDy(Ac$Lu%W&CaRa(Cf)EuB#Ds%Md$Uus*NpIn$H&YbIr*BeEs*Tc#I(FlRuC#ThSrBh/NaCoLrKr&Nb$CePb$Ne'Am)At*PdLa#Tl%HgMt,CrTbBk$Rh&Rn4TeZn$HfAg%Fm)Xe$AlScFePo$As'HeO#LvN&DbGe#Ho&Mn$Cd+Ni$Rg$HsBr$AuSi#Pr&Uup#Se*Ti#Tm$Er$Sb&PPu&Cm$GdBa'Cn&UutLiFr#Ar#Bi#NoOs%Pa4Cl";while((c=getchar())>64)h=(h+c%32+74)*311%441;while(h)if(*p<65?h-=*p++-34,0:1)for(h--;*++p>96;);do putchar(*p++);while(*p>96);}

Ungolfed with comments:
int h;
main(c) {

  /* Hashed element symbols. Characters #$% etc. are used as padding: */
  char *p="Sn)Cu&V$U#Mo#Rf#Sg&Cs#Y+FTa%Rb)S'Nd#GaK&Mg'Zr$PtPm%ReUuo#SmDy(Ac$Lu%W&C"
          "aRa(Cf)EuB#Ds%Md$Uus*NpIn$H&YbIr*BeEs*Tc#I(FlRuC#ThSrBh/NaCoLrKr&Nb$CeP"
          "b$Ne'Am)At*PdLa#Tl%HgMt,CrTbBk$Rh&Rn4TeZn$HfAg%Fm)Xe$AlScFePo$As'HeO#Lv"
          "N&DbGe#Ho&Mn$Cd+Ni$Rg$HsBr$AuSi#Pr&Uup#Se*Ti#Tm$Er$Sb&PPu&Cm$GdBa'Cn&Uu"
          "tLiFr#Ar#Bi#NoOs%Pa4Cl";

  /* This hash function gives a unique result for each element: */
  while((c=getchar())>64) h=(h+c%32+74)*311%441;

  /* Find the corresponding position in the hashed data */
  while(h) {
    if(*p<65?h-=*p++-34,0:1) {      /* Step over an abbreviation */
      for(h--;*++p>96;);            /* Skip padding */
    }
  }

  /* Output first uppercase character and all following lowercase characters: */
  do {
    putchar(*p++);
  } while(*p>96);
}

I used brute force to find this hash; This was the only one with a hash size of ≤512 that had no collisions. I didn't check alternative spellings though, and there might be better functions with different algorithms (e.g. using XOR instead of addition).
The hash function maps text strings to values from 0 to 440. "Tin" hashes to zero, so "Sn" is at the start of the table. The next 7 positions are empty. To keep the code compact, this is indicated by the ASCII value 34+7=41 (")"). Next comes "Copper" (8), four empty cells (34+4=38="&"), and "Vanadium" (13). After calculating a hash, the program steps through the table, subtracting 1 for every capital letter followed by 0 or more lowercase letters, and subtracting (ASCII VALUE)-34 for every non-alphabet character. When the value reaches zero, we have found the correct result.


Enumerate all number that are palindromic in at least two of base 2, 8, 10, 16 or 64 Multi palindromic numbers

Finding all number for which at least two** representation are palindromic, with more than one** characters, if in decimal, octal, hexadecimal, binary or in base64.

** have to be editable, see Variables below.

Edited: After lot of reflexion  about comment from @DavidCarraher, I found an important issue about the range to be used. Mostly in the goal of reducing ratio operation/output. For this, variables section of this question was modified.

Details

Representation of numbers are:

binary     : 01
octal      : 01234567
decimal    : 0123456789
hexadecimal: 0123456789abcdef   (in lower case)
base64     : 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@_ Nota: This representation is compatible with bash: printf "%o" $((64#r0r)) give 330033 (r0r is a palindrome in both base64 and octal)

The ouput present first a count of palindromes, than all 5 variantes from smaller representation to bigger:

Count Base64 Hexa   Decimal  Octal    Binary
3     11     41     65       101      1000001
3     33     c3     195      303      11000011
3     55     145    325      505      101000101
3     77     1c7    455      707      111000111
4     99     249    585      1111     1001001001
3     ll     555    1365     2525     10101010101
3     rr     6db    1755     3333     11011011011
3     JJ     b6d    2925     5555     101101101101
3     ZL     f6f    3951     7557     111101101111
4     __     fff    4095     7777     111111111111
4     101    1001   4097     10001    1000000000001
3     111    1041   4161     10101    1000001000001
3     202    2002   8194     20002    10000000000010
4     303    3003   12291    30003    11000000000011
3     333    30c3   12483    30303    11000011000011

Nota this sample display number that's palindromes in at least 3 representation, not 2, see Variables below.

Variables

Minimum of palindrome length, default to 2
Minimum number of palindrome by number, default to  2 (/5). There are 5 representation. Print a number when at least 2 of them are palindromic.
Range to check for: could be from 1 to 2^31 or smaller. This could be an array BoundRange=(1,1000) or two variables: RangeSta=1 RangeEnd=1000.

This variables have to be changeables in simple way (modification of code at only one place or given as argument).

Output

No formating needed, only 6 colons, space separated will suffice.

2 9 9 9 11 1001
2 h 11 17 21 10001
2 r 1b 27 33 11011
2 x 21 33 41 100001
2 J 2d 45 55 101101
2 P 33 51 63 110011
2 _ 3f 63 77 111111
3 11 41 65 101 1000001
2 19 49 73 111 1001001
2 1l 55 85 125 1010101

Limits (range)

There is no real consideration of maximum useable of the range as this is depending on language used, But a range have to be fixed:

min: 1 (notation in octal!)
max: depending on language used, but 2^31 seem to be an overall minimum.

For tests, the range could be fixed to somthing smaller...

Goal

The more efficient algorithm with less operation count by line of output will win. (This may have to be explained)**.

Ratio  operation count / output line count
Shortness of code, but with readable variables ie: One variable is one. Regardless of his name length. (don't obfusc)
Quickness of execution (comparission only by language, not accross different languages. Ie: I won't try to compare a c version with a bash one. )

Operations count

The count of operation are mainly theorical. Meaning, a simple conversion is one operation whenever it is done by builtin functions, like printf or by more complex routine like sub base in Dom Hastings's answer

**As I don't know all languages, and there is some place to unusual ideas, subtles algorithms may need to be explained...

Mathematica
f[number,minPalindromeLength,minCount]works as follows If number is a palindrome with minPalindromeLength in at least minCount bases, f returns the information about that number.
g[max,minPalindromeLength,minCount] makes an table of "palindrome numbers" from 1 through max.
f[number_,minPalindromeLength_:2,minCount_:2]:=Module[{print,palindromeQ,count,
convert64=Thread[Range[0,63]->Characters["0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@_"]],
digits=IntegerDigits[number,#]&/@(bases={64,16,10,8,2})},
palindromeQ[dig_]:=(dig==Reverse[dig]);
count = Total@Boole[palindromeQ/@ Cases[digits,x_/;Length[x]>minPalindromeLength-1]];
If[count>minCount-1,Join[{count,Subscript[StringJoin[IntegerDigits[number,64]/.convert64],64]},BaseForm[number,#]&/@Rest[bases]],Sequence[]]];

g[max_,minPalindromeLength_:2,minCount_:2]:=
(Print["\nPalindromes: minPalindromeLength = ",minPalindromeLength "\tand minCount ", minCount ];
DeleteCases[Table[f[z,minPalindromeLength,minCount],{z,9,max}],Null]//Grid);

g[5000,2,3]
g[5000,3,3]
g[5000,4,2]


Format the reputation You probably do know that the different reputation levels on Stack Exchange are formatted differently when seen from the questions page / a post. There're all the rep-formatting rules:

if a user has 1 to 999 (one to three digits) rep, it's left as-is.
if a user has 1000 to 9999 rep (four digits), it receives the comma as a separator: 9,999
if a user has 10000 to 99999 rep (five digits), it's shortened and rounded. I.e., 16741 rep is formatted as 16.7k, notice the dot separator unlike the comma for the lower rep (previous point).

16750 will already result 16.8k (since this seems to be fixed)
16941 results in 16.9k, 16950 rounds up to 17k, as well as does 17014, for example.
99941 rounds to 99.9k, 99950 rounds to 100k (this is something I actually hate with the rep-rounding on SE, because 100,000 is such a milestone, and 99950 is nowhere near).

If a user has 100000 to 999999 rep, it's rounded this way:

100100 rounds down to 100k, 100500 rounds up to 101k. The thing is, the rounding is done, but the decimal part is stripped (unlike the four-digits rep).
100450 rounds down to 100k, no step to round 450 to 500. Nor does 100499 - it's still 100k.
279843 rounds up to 280k, and 399999 rounds to 400k.

As input, you're given the raw reputation, and output it as formatted.

You can consider that input won't receive any invalid numbers / non-numbers, or numbers with leading zeros, i.e. 0001234.

Because Jon Skeet doesn't seem to be reaching 1,000,000 soon, your code must be as short as possible you don't need to handle the rep greater than one million (i.e. no special cases for 999500 and above).

JavaScript (ES6), 76 68 bytes
x=>x<1e4?x.toLocaleString():(x<1e5?(x/1e2+.5|0)/10:(x/1e3+.5|0))+"k"

Another first attempt. Thank goodness for that handy .toLocaleString(), the shortest alternative I could find is 21 bytes longer...
This separates thousands by either , or ., depending on what country you live in. For five two bytes more, you can make it always use a comma:
x=>x<1e4?x.toLocaleString`en`:(x<1e5?(x/1e2+.5|0)/10:(x/1e3+.5|0))+"k"


I HATE spaces in file names It is simple. I cannot stand when people use spaces when naming files. It sometimes wrecks console commands and makes the output of ls ugly.

The challenge is to write a program (only ascii characters) which

renames all files (including directories) in the current directory to versions with spaces removed or replaced by '_'
on collision, you need to append a unique identifier (up to you)
descends recursively into all subdirectories

You can assume UNIX-style path names. Who would need this program on a Windows machine anyways?

This is code golf, the shortest program wins (#ascii characters). Since I hate spaces so much, each space has to be counted twice.

Please provide your language, score, program and a short description of how to run it.

The program must compile and execute with reasonable effort on my linux machine.

EDIT: As Etan requested a file structure for testing, here is the script I currently use to create a suitable file tree:

#!/bin/bash
rm -r TestDir

touchfiles()
{
    touch my_file
    touch my__file
    touch "my file"
    touch "my  file"
    touch " my_file  "
}

mkdir TestDir
cd TestDir

touchfiles

for dir in "Test Sub" Test_Sub "Te stSub" Te_stSub
do
    mkdir "$dir"
    cd "$dir"
    touchfiles
    cd ..
done

Bash 116 bytes, 16 spaces

find . -depth -exec bash -c 'B=${0##*/}
M="${0%/*}/${B// /_}"
while [ -e "$M" ]
do M=$M.
done
mv "$0" "$M"' {} \;

I didn't suppress errors to gain a couple more bytes. This will not have any collisions.

If non-posix GNU find can be expected, this can be shortened further:

Bash 110 bytes, 15 spaces

find -d -exec bash -c 'B=${0##*/}
M="${0%/*}/${B// /_}"
while [ -e "$M" ]
do M=$M.
done
mv "$0" "$M"' {} \;

Removing spaces instead of replacing them uses two less bytes:

Bash 108 bytes, 15 spaces

find -d -exec bash -c 'B=${0##*/}
M="${0%/*}/${B// }"
while [ -e "$M" ]
do M=$M.
done
mv "$0" "$M"' {} \;

Note: if tabs can be used instead of spaces, only 1 space is needed (the one in the match rule for substitution at line 2).

Thanks to Dennis for finding bug on double quote (and providing solution)


cool untitled sequence thingy Let's define fn(k) as the sum of the first k terms of the natural numbers [1, ∞) where each number is repeated n times.
k       | 0    1    2    3    4    5    6    7    8    9
--------+-------------------------------------------------
f_1(k)  | 0    1    3    6    10   15   21   28   36   45
deltas  |   +1   +2   +3   +4   +5   +6   +7   +8   +9
--------+-------------------------------------------------
f_2(k)  | 0    1    2    4    6    9    12   16   20   25
deltas  |   +1   +1   +2   +2   +3   +3   +4   +4   +5
--------+-------------------------------------------------
f_3(k)  | 0    1    2    3    5    7    9    12   15   18
deltas  |   +1   +1   +1   +2   +2   +2   +3   +3   +3
The anti-diagonals of this as a square array is similar to OEIS sequence A134546.
Challenge
Write a program/function that takes two non-negative integers n and k and outputs fn(k).
Specifications

Standard I/O rules apply.
Standard loopholes are forbidden.
Your solution can either be 0-indexed or 1-indexed for n and/or k but please specify which.
This challenge is not about finding the shortest approach in all languages, rather, it is about finding the shortest approach in each language.
Your code will be scored in bytes, usually in the encoding UTF-8, unless specified otherwise.
Built-in functions that compute this sequence are allowed but including a solution that doesn't rely on a built-in is encouraged.
Explanations, even for "practical" languages, are encouraged.

Test cases
In these test cases, n is 1-indexed and k is 0-indexed.
n   k      fn(k)

1   2      3
2   11     36
11  14     17
14  21     28
21  24     27
24  31     38
31  0      0
In a few better formats:
1 2
2 11
11 14
14 21
21 24
24 31
31 0

1, 2
2, 11
11, 14
14, 21
21, 24
24, 31
31, 0

Reference implementation
This is written in Haskell.
f n k = sum $ take k $ replicate n =<< [1..]

Try it online!
This challenge was sandboxed.

Ruby, 32 28 23 bytes

->n,k{k.step(0,-n).sum}

Try it online!

Explanation

Let's visualize the sum as the area of a triangle, for example with n=3 and k=10:

*
*
*
**
**
**
***
***
***
****

Then we sum by column instead of row: the first column is k, then k-n, k-2n and so on.


Reconstruct a zigzagified matrix As part of its compression algorithm, the JPEG standard unrolls a matrix into a vector along antidiagonals of alternating direction:

Your task is to take the unrolled vector along with the matrix dimensions and reconstruct the corresponding matrix. As an example:

[1, 2, 5, 9, 6, 3, 4, 7, 1, 2, 8, 3], 4, 3

should yield

[1 2 3 4
 5 6 7 8
 9 1 2 3]

whereas dimensions 6, 2 would give

[1 2 6 3 1 2
 5 9 4 7 8 3]

Rules

You may choose to take only one of the dimensions as input. The individual inputs can be taken in any order. You may assume that the width and height are positive and valid for the given vector length.

You may assume that the vector elements are positive integers less than 10.

You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.

The input vector may be given in any convenient, unambiguous, flat list or string format.

The output matrix may be in any convenient, unambiguous, nested list or string format, or as a flat list along with both matrix dimensions. (Or, of course, as a matrix type if your language has those.)

Standard code-golf rules apply.

Test Cases

Each test case is of the form vector width height => matrix.

[1] 1 1                        => [[1]]
[1 2 3 1] 2 2                  => [[1 2] [3 1]]
[1 2 3 1] 4 1                  => [[1 2 3 1]]
[1 2 5 9 6 3 4 7 1 2 8 3] 3 4  => [[1 2 3] [5 6 4] [9 7 8] [1 2 3]]
[1 2 5 9 6 3 4 7 1 2 8 3] 4 3  => [[1 2 3 4] [5 6 7 8] [9 1 2 3]]
[1 2 5 9 6 3 4 7 1 2 8 3] 6 2  => [[1 2 6 3 1 2] [5 9 4 7 8 3]]
[1 2 5 9 6 3 4 7 1 2 8 3] 12 1 => [[1 2 5 9 6 3 4 7 1 2 8 3]]
[1 2 5 9 6 3 4 7 1 2 8 3] 1 12 => [[1] [2] [5] [9] [6] [3] [4] [7] [1] [2] [8] [3]]

Related Challenges

Zigzagify a Matrix (the somewhat simpler inverse transformation)
Rotate the anti-diagonals

Jelly, 18 13 bytes

pS€żị"¥pỤỤị⁵s

Takes number of rows, number of columns and a flat list as separate command-line arguments.

My code is almost identical to the one in the twin challenge. The only differences are an additional Ụ (which inverts the permutation of the indices) and an s (to split the output into a 2D array).

Try it online!


Drink your morning coffee Draw this Ascii coffee cup:

  o
       o
    o
 __________
/          \__
|   J      |  \
|    A     |  |
|     V    |  |
|      A   |__/
\__________/

Brownie points for coffee-script or java :)

Shortest code in bytes, function or program, trailing newline or white space is acceptable, drink up!

JavaScript (ES6), 110 104 bytes
Saved 4 bytes thanks to edc65

let f =

_=>`1o
6o
3o
 9
/44\\__
|2J5|1\\
|3A4|1|
|4V3|1|
|5A2|__/
\\9/`.replace(/\d/g,n=>' _'[n>>3].repeat(++n))

console.log(f())

How it works
The compression of the original ASCII art is achieved by replacing all sequences of 2 to 10 consecutive spaces and the two sequences of 10 consecutive underscores with a single digit:

Each sequence of N consecutive spaces is encoded with the digit N-1.
The underscore sequences are encoded with a 9.

We use N-1 rather than N so that we never have to use more than one digit. Hence the need for ++n when decoding.
The expression n>>3 (bitwise shift to the right) equals 0 for n = 1 to n = 7 and equals 1 for n = 8 (not used) and n = 9. Therefore, ' _'[n>>3] gives an underscore for 9, and a space for all other encountered values.
The only special case is the sequence of 10 consecutive spaces just above "JAVA". Encoding it with a 9 would conflict with the underscore sequences. So we need to split it into two sequences of 5 spaces, encoded as 44.


Floor of complex number Background
Complex floor is a domain extension of the mathematical floor function for complex numbers. This is used in some APL languages to implement floor ⌊, ceiling ⌈, residue |, GCD ∨, and LCM ∧ on complex numbers.
For the rest of this challenge, an integer refers to a Gaussian integer, i.e. a complex number whose real and imaginary parts are integers.
Eugene McDonnell defined seven requirements of a complex floor function (copied from the wiki page, with APL code fragments translated into plain math notation):

Existence. Every number has a floor.
Uniqueness. Every number has only one floor.
Fractionality. The magnitude of the difference of a number and its floor shall be less than one. This property must be satisfied to guarantee that remainders are less in magnitude than divisors. It may be called the fundamental property of the floor function.
Integrity. The floor of a number is an integer.
Convexity. If \$g\$ is the floor of the numbers \$z\$ and \$w\$, then it is also the floor of all numbers on the line segment between \$z\$ and \$w\$.
Integer Translation. For \$c\$ a complex integer, \$c+ \lfloor z \rfloor = \lfloor c+z \rfloor\$.
Compatibility. The complex floor function is compatible with the real floor function. Furthermore, its action on purely imaginary numbers is similar to the action of the real floor function on real numbers. In particular, \$\operatorname{re}(\lfloor z \rfloor) ≤ \operatorname{re}(\lceil z \rceil)\$ and \$\operatorname{im}(\lfloor z \rfloor) ≤ \operatorname{im}(\lceil z \rceil)\$. (Ceiling for complex numbers is defined as \$\lceil z \rceil = -\lfloor -z \rfloor \$.)

One shape that satisfies these conditions is a rectangle \$\sqrt{1\over2}\$ units high and \$\sqrt2\$ units wide, rotated 45 degrees, as in the following image.

One interesting consequence of fractionality is that the magnitude of the residue is always smaller than that of the divisor, and the Euclidean algorithm always terminates on arbitrary complex number inputs.
Task
Define your own complex floor that satisfies the requirements listed above, and implement it. It is OK if you simply use McDonnell's function. If you use a different function, please include an explanation of how it satisfies the requirements.
Please note that simply flooring the two components is NOT a valid answer since it violates Fractionality: when \$z = 3.9 + 2.9i\$,
$$
\lfloor z \rfloor = 3 + 2i \\
z-\lfloor z \rfloor = 0.9 + 0.9i \\
|z-\lfloor z \rfloor| = |0.9 + 0.9i| = 0.9 \sqrt2 > 1
$$
You may represent a complex number as a built-in complex number or a pair of real numbers. You don't need to care too much about boundary conditions, since floating-point imprecision will impact its correctness anyway.
It is known to be implemented in Dyalog APL, J, and NARS2000. You are not allowed to use floor/ceiling/residue/GCD/LCM functions with non-real complex arguments for these languages.
Standard code-golf rules apply. Shortest code in bytes wins.

J, 32 31 26 bytes
j.&<.+((1<:+)*0j1^<)&(1|])

Try it online!
-5 thanks to Razetime for pointing out I could take real and imag parts as left and right args.
Obligatory J answer.
For reference, per the link in the OP, Eugene McDonnell's  algorithm is:

The algorithm for the determination of g , the floor of a complex number z , may be explained informally as follows:

Let b be the point at the lower left corner of the unit square containing z . Let x and y be the fractional parts of the real and imaginary parts of z .
Then:

Let g = b if 1 > (x + y) ,
Let g = (b + 1) if (1 ≤ x + y) and x ≥ y ,
Let g = (b + 0i1) if (1 ≤ x + y) and x < y .

We take the real and imaginary parts as left and right args.
We note that the answer is:
b + (0 or 1 or i)

depending on the case.

j.&<.+ Floors both parts and converts back to complex j.&<./, then adds everything
to the right +.  This gives us the b + part.
(...)&(1|]) Get fractional parts of real/imag pieces, and feed those as
left and right args to everything in parens.  This gives us x and y.
(1<:+) Is x + y greater than or equal to 1?  Returns 0 or 1. Multiply that
by...
0j1^< \$i\$ raised to "is x < y?" -- gives us \$i\$ if true, 1 otherwise.


Generate combinations with replacement List all of the combinations with replacement (or combinations with repetition) of size k from a set of n elements.

A combination with replacement is an unordered multiset that every element in it are also in the set of n elements. Note that:

It is unordered. So a previously printed set with a different order shouldn't be printed again.
It is a multiset. The same element can (but isn't required to) appear more than once. This is the only difference between a combination with replacement and a normal combination.
The set should have exactly k elements.

Alternatively, it is also a size-k subset of the multiset which contains each of the n elements k times.

The input should be either n and k, where the elements are the first n positive or non-negative integers, or the n elements and k, where you can assume the n elements are all different from each other.

The output should be a list of all the combinations with replacement with size k from the given set. You can print them and the elements in each of them in any order.

You may not use builtins generating combinations with replacement. But you can use builtins to generate normal combinations, permutations, tuples, etc.

This is code-golf, shortest code wins.

Example

Input: 4 2
Output: [0 0] [0 1] [0 2] [0 3] [1 1] [1 2] [1 3] [2 2] [2 3] [3 3]

CJam (8 bytes)

{m*:$_&}

Online demo

Dissection

{    e# Declare block (anonymous function); parameters are n k
  m* e# Cartesian product, which implicitly lifts n to [0 1 ... n-1]
  :$ e# Sort each element of the Cartesian product, to give them canonical forms
  _& e# Deduplicate
}


Find the optimal sliding door width Sliding doors have varying prices based on the width of the doors. The different prices are as follows:

60 - 80 cm:   ¤150
81 - 100 cm:  ¤200
101 - 120 cm: ¤220

When buying a closet you would obviously want to minimize the cost, so your task is to find the width of the doors that minimizes the total cost based on the total width of the closet.

Rules:

The total width will be taken as input
All doors will have the same width
Choose the smallest doors if two type of doors cost the same
The widths are in centimeters, integers not decimals

Round up decimals

The price shall be returned as an integer (no need for the currency sign)
The input and output formats are optional, but the order of the output must be: Number of doors, Width, Price.
Input will be in the range [120 1000).

This is code golf. Shortest code in bytes win.

Examples:

Input: 156
Output: 2, 78, 300

Input: 331
Output: 3, 111, 660

Input: 420
Output: 4, 105, 880

Perl, 190 180 154 133 128 117 bytes

includes +1 for -p

use POSIX;$m=1E4;for$q(80,100,120){($m,@z)=($p,$n,ceil$_/$n)if$m>($p=(150,200,220)[$x++]*($n=ceil$_/$q))}$_="@z $m"

Commented:

use POSIX;                                  # for ceil()
$m = 1E4;                                   # init min price to 10k
for $q (80,100,120) {                       # iterate widths
    ($m,@z) = ($p,$n, ceil $_/$n)           # update min, output
    if $m > (                               #
       $p = (150,200,220)[$x++]             # grab price
          * ( $n = ceil $_/$q )             # times nr of doors needed
    )
}
$_="@z $m"

Save 11 bytes by inlining and splitting hash to two arrays
Save 5 bytes by using -p (thanks to @dev-null)
Save 18 bytes by using POSIX::ceil and 3 more by using list syntax for hash (thanks to @msh210)


Quines that print what their index is We all know what a quine is. A quine is a program which prints its own source code. And we also know about the printable ASCII characters. Well... this challenge mixes both.

Your mission, should you accept it, is to create an index quine. An index quine is a non-empty program, composed only of the printable ASCII characters, which prints its own index.

The index of a string is its position within an infinite dictionary where all strings composed of exactly the printable ASCII characters appear, sorted by size then ASCII code.

The index is a non-negative whole number, assigning 0 to the empty string then continuing with the space, !, " onward.

For example, *! precedes ** as the ending ! in the first string has lower ASCII code than the ending * in the second, but both are preceded by {, which has a higher ASCII code than the characters of the last two examples, but is shorter.

The printed index should be in base 10, outputted through STDOUT or closest equivalent, with no other output unless your language requires trailing newlines/other characters. Also, a bit like actual quines, do not access your source code directly (as a file, etc.)

Your program should be non-empty, as a reminder to those reading these rules.

If there are multiple programs of shortest length, the tiebreaker is the program with the lower index.

The shortest program following these very rules wins. Have fun.

Deorst, 1 byte

Try it online!

Commentator, 1 byte

Try it online!

Snails, 1 byte

Try it online!

So far, I have found three one-byte solutions, all of which print 1 with a space in the source code.

The first two languages were created by @cairdcoinheringaahing, and the last one by @feersum.


Typing, but to the left Background

You've been given a task to take notes for a meeting. You start typing on your Google Doc, but you don't have enough time during the meeting to look at your keyboard while you type.

Fortunately for you, you can type without looking at your keyboard. After the meeting, you realize that everything you typed was one key to the left.

The Challenge

For this challenge, you will be using the letters, numbers, and space bar of the QWERTY keyboard layout.

Given an input of text (from any standard input method), output the resulting text, where every character is moved one to the left on the keyboard.

For the majority of letters, just look at the letter and translate it to the letter to the left (c becomes x, t becomes r, etc).
For letter q, translate to a literal tab character (\t).
For letter a, enable caps lock, so the capitalization of the rest of the string is reversed.
For letter z, capitalize the next letter in the string.
No translation is required for the space bar.

Preserve capitalization while translating, and be mindful of caps lock (if caps lock is enabled, make sure the case is the opposite).
All characters in the input string will be letters, numbers, or a space. No punctuation or other characters can be included.

Test Cases

\t is a literal tab character

Hello world    -> Gwkki qieks
Code Golf      -> Xisw Fikd
Queried apples -> \tyweuws OOKWA

Scoring

Lowest score in bytes wins. Have fun!

JavaScript (V8), 271 bytes

f=(s,k='~!@#$%^&*()_+`1234567890-=\tQWERTYUIOP{}|\tqwertyuiop[]\\ASDFGHJKL:"\n\\asdfghjkl;\'ZXCVBNM<>?zxcvbnm,./')=>s.replace(/[^ ]/g,c=>k[k.indexOf(c)-1]).replace(/\\([^\\]*)\\?/g,(m,c)=>c.replace(/[a-zA-z]/g,l=>l>'Z'?l.toUpperCase():l.toLowerCase())).replace(/[?']/,"")

Try it online!
My first JavaScript code golf.
It could definitely be shorter, but I think this is a good start.
It basically finds each character in the k string and replaces it with the previous one, then swaps the case of everything between the A or a, and removes all occurences of Z or z (as shift key does nothing on its own).
This should be a normal QWERTY keyboard layout, but let me know if not.


Incrementing Numbers, Over Multiple Sessions Good Evening Golf Agents,

Your mission is on behalf of notorious entertainment giant Eviltronic Arts. As part of their nefarious plan for world enslavement and entertainment, they must sell as many copies of SimStation V as possible. This means that the software must mysteriously stop working, after starting it a few times.

Your goal is to write a program that counts the amount of times it has been run. The program must do nothing other then write the integer to stdout. The first time it is run, it should return "1". The next "2" and so on. The program must be able to at least reach the number "14", but there is no required upper limit.

However, your program must not write any new files. Accessing itself, or the registry, or even the internet is absolutely OK. But some of our users are suspicious of new files, and will merely overwrite them! The nerve! Defeating the limitations on software they legitimately purchased!

The program can not assume a stable interpreter or shell - the program must still work if the entire interpreter nay shell nay computer is restarted between running.

As it must be as undetectable as possible, the shortest source code will win.

Good luck agents. The entertainment industry is counting on you.

bash script, 39,37,21 18
wc -l<$0;echo>>$0

Short and sweet, my first submission in code golf :)


Rotate a Chinese checkerboard A Chinese checkerboard looks like this (based on this question, but this time it has a fixed size):

            G
           . G
          G G G
         G G . G
B B B B . . Y G . Y . Y Y
 B B B . . G . . . Y Y Y
  B . B . . . . . Y . Y
   B . . . . . . . . Y
    . . . . . . . . .
   . P . . . . . O O .
  P P . . . . . . . O O
 P P P . . . R . . O O .
P P P P . . R . . O O O O
         R . R R
          R R R
           R .
            R

Each non-space character in this example can be replaced by any non-space printable ASCII character in the input, while spaces are never changed. Note that it isn't guaranteed to be a valid arrangement in Chinese checker (such as it may not have exactly 7 different kind of characters).

Your task is to rotate it by a multiple of 60 degrees.

This is the above example rotated by 60 degrees clockwise:

            B
           B B
          B B B
         B . B B
P P P . . . B . . G G . G
 P P P P . . . . . G G G
  P P . . . . . G Y . G
   P . . . . . . . G G
    . . . . . . . . .
   R . . . . . . . . Y
  R . R R . . . . Y Y .
 R R R . . . O . . . Y Y
R . R R . . . O . Y Y Y Y
         O O O .
          O O O
           O .
            O

The input is a non-negative integer and a Chinese checkerboard. Your program (or function) should rotate it by the integer * 60 degrees. You decide whether to rotate clockwise or counterclockwise, as long as it is consistent. Both the input and output shouldn't have extra leading or trailing spaces.

This is code-golf. Shortest code wins.

CJam, 61 59 43 40 38 36 bytes

{{_N/eeSf.*:sW%zsS-\{_' >{;(}&+}/}*}

This is an anonymous function that expects a string and an integer on the stack.

Thanks to @jimmy23013 for golfing off 19 bytes.

Try it online in the CJam interpreter.

Idea

We can assign an order to the printable characters of the checkerboards by reading them eastwards, then southwards.

This way, the original and rotated checkerboard

            G                                  B
           . G                                B B
          G G G                              B B B
         G G . G                            B . B B
B B B B . . Y G . Y . Y Y          P P P . . . B . . G G . G
 B B B . . G . . . Y Y Y            P P P P . . . . . G G G
  B . B . . . . . Y . Y              P P . . . . . G Y . G
   B . . . . . . . . Y                P . . . . . . . G G
    . . . . . . . . .                  . . . . . . . . .
   . P . . . . . O O .                R . . . . . . . . Y
  P P . . . . . . . O O              R . R R . . . . Y Y .
 P P P . . . R . . O O .            R R R . . . O . . . Y Y
P P P P . . R . . O O O O          R . R R . . . O . Y Y Y Y
         R . R R                            O O O .
          R R R                              O O O
           R .                                O .
            R                                  O

become

G.GGGGGG.GBBBB..YG.Y.YYBBB..G...YYYB.B.....Y.YB........Y..........P.....OO.PP.......OOPPP...R..OO.PPPP..R..OOOOR.RRRRRR.R

and

BBBBBBB.BBPPP...B..GG.GPPPP.....GGGPP.....GY.GP.......GG.........R........YR.RR....YY.RRR...O...YYR.RR...O.YYYYOOO.OOOO.O

respectively.

We can find the second sequence in the first checkerboard by reading its characters northeastwards, then southeastwards.

To achieve this in code, we start by prepending n - 1 spaces to the nth row of the checkerboard (shown on the left). Then, we reverse the order of the rows (shown on the right).

            G                                                       R
            . G                                                   R .
            G G G                                               R R R
            G G . G                                           R . R R
    B B B B . . Y G . Y . Y Y                       P P P P . . R . . O O O O
      B B B . . G . . . Y Y Y                       P P P . . . R . . O O .
        B . B . . . . . Y . Y                       P P . . . . . . . O O
          B . . . . . . . . Y                       . P . . . . . O O .
            . . . . . . . . .                       . . . . . . . . .
            . P . . . . . O O .                   B . . . . . . . . Y
            P P . . . . . . . O O               B . B . . . . . Y . Y
            P P P . . . R . . O O .           B B B . . G . . . Y Y Y
            P P P P . . R . . O O O O       B B B B . . Y G . Y . Y Y
                      R . R R                       G G . G
                        R R R                       G G G
                          R .                       . G
                            R                       G

Finally, we transpose rows with columns:

            B

           BB

          BBB

         B.BB

    PPP...B..GG.G

    PPPP.....GGG

    PP.....GY.G

    P.......GG

    .........

   R........Y

  R.RR....YY.

 RRR...O...YY

R.RR...O.YYYY

OOO.

OOO

O.

O

The whitespace is all over the place, but the printable characters are in the correct order if we read them eastwards, then southwards.

All that's left to do is replacing the nth printable character of the original checkerboard by the nth printable character of the last modification.

Code

                                   e# Stack: String B, Integer A
{                               }* e# Repeat A times:
 _N/                               e#   Push a copy of B and split it at linefeeds.
    ee                             e#   Enumerate the lines of B.
      Sf.*:s                       e#   Execute S.*s for each line:
                                   e#     [4 "abc"] -> "    abc"
            W%                     e#   Reverse the order of line lines.
              z                    e#   Zip; transpose rows with columns.
               s                   e#   Flatten the arrays of strings.
                S-                 e#   Remove spaces.
                                   e#   This pushes a string L.
                  \{          }/   e#   For each character C in the unmodified B:
                    _' >           e#     Check if C is bigger than ' '.
                        {  }&      e#     If it is:
                         ;(        e#      Discard C and shift out a char from L.
                             +     e#     Append a char (C or from L) to L.
                                   e#  L is B rotated by 60 degrees. Set L := B.


Construct a Permuter For this challenge you are going to make a function (your function may be a complete program) that takes a list as input and returns a permutation of that list.  Your function must obey the following requirements.

It must be deterministic.
Composing your function with itself a variable number of times should be capable of getting a list to any of its permutations.

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

Further rules

You may take any type of list, ([Integer],[String],[[Integer]]) as long as it

Can be non empty
Can contain distinct objects with at least 16 possible values.  (You can't use a Haskell [()] and claim your function is id)
Can contain duplicate objects (no sets)

You may write a program or a function, but must obey standard IO.

CJam (11 bytes)

{_e!_@a#(=}

Online demo showing the full cycle for a four-element list with one duplicate element.

Dissection

{      e# Define a block
  _e!  e#   Find all permutations of the input. Note that if there are duplicate
       e#   elements in the input then only distinct permutations are produced.
       e#   Note also that the permutations are always generated in lexicographic
       e#   order, so the order is independent of the input.
  _@a# e#   Find the index of the input in the list
  (=   e#   Decrement and get the corresponding element of the list
       e#   Incrementing would also have worked, but indexing by -1 feels less
       e#   wrong than indexing by the length, and makes this more portable to
       e#   GolfScript if it ever adds a "permutations" built-in
}


Find the minimum and maximum integers in an array, without using builtins Challenge

Given an array of integers, received from stdin, function arguments, program arguments, or some other method:

Output only the minimum and maximum numbers in the array, through a return value, stdout, or other fitting methods.

Example session

> minmax( {0, 15, 2, 3, 7, 18, -2, 9, 6, -5, 3, 8, 9, -14} )
-14 18

Reference implementation

// C++14

void minmax(std::vector<int> v) {
    int min = v[0]; int max = v[0];
    for(auto it : v) {
        if (*it < min)
            min = *it;
        if (*it > max)
            max = *it;
    }
    std::cout << min << ' ' << max << std::endl;
}

Rules

You may not use a built-in function to calculate the values.
Standard loopholes disallowed.
Creative implementations encouraged.
This is code-golf, shortest answer wins but will not be selected.

Clarifications

If the array contains 1 element you need to output it twice.
If the minimum and maximum values are the same, you need to output them both.

Jelly, 3 bytes

Ṣ.ị

Try it online!

Sort the array, and then takes the 0.5-th element.

Jelly uses 1-indexing, and floating points indexing means take its floor and its ceil.

So the 0.5-th element would give you the 0th element and the 1st element.

The 0th element is the last element.


Plot a list of numbers Are you feeling jealousy towards Mathematica, Matlab et al. for their intricate plotting capabilities? If you answered yes, this challenge is for you!
Challenge
Given, via parameters or standard input, a list of numbers list and a positive integer h for the height of the plot, write a program/function/snippet that prints a character array of length(list) columns and h rows, where each column contains exactly one special non-whitespace character, e.g. # and h-1 spaces. For the nth column the position of the special character corresponds to the value of the nth element in the list. Lower rows correspond to lower values, so if list[a]≥list[b], then in column a the special character must be at least as high than in column b.
The scaling from the value to the y-position of the special character must essentially be an affine mapping (x ↦ ax+b) plus any necessary rounding so for example integer division is allowed but clipping is not. The scaling must be done so that the full extent of the plot is used, i.e. the first and last row contain at least one special character.
The numbers can be of any numeral type that is at least 8 bits wide. Labels or axes aren't needed. Built-in plotting functions are allowed if the output conforms to the required format. The standard loopholes are disallowed.
Example
Input:
list = [0.0,0.325,0.614,0.837,0.969,0.997,0.916,0.736,0.476,0.165,-0.165,-0.476,-0.736,-0.916,-0.997,-0.969,-0.837,-0.614,-0.325,0.0]
h = 8

One possible output:
    ###
  ##   #
 #      #
#        #         #
          #
           #      #
            #   ##
             ###

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

Python 2, 118 bytes
Saving 2 bytes thanks to Shebang

def f(n,L):
 for i in range(n):print''.join(' #'[i==j]for j in[n-1-int(~-n*(x-min(L))/(max(L)-min(L))+0.5)for x in L])


Многочлены Чебышёва (Chebyshev Polynomials) Chebyshev Polynomials are a family of orthogonal polynomials that pop up in all kinds of places in math, and they have a lot of quite interesting properties. One characterization of them is that they are the unique polynomials that satisfy \$T_n(\cos(x)) = \cos(nx)\$.
Challenge
Given an nonnegative integer \$n\$, you should output the \$n\$-th Chebyshev Polynomial. \$T_n(x)\$.
Definition
The \$n\$-th Chebyshev Polynomial is given by following three term recursion:
$$\begin{align}
T_0(x) & = 1 \\
T_1(x) & = x \\
T_{n+1}(x) & = 2xT_n(x) - T_{n-1}(x)
\end{align}$$

Details
If your language has a native polynomial type, you can use that one as an output, otherwise you should output a list of coefficients in ascending- or descending order, or as a string representing a polynomial.
This is code-golf so the shortest code in bytes wins
Examples
T0(x) = 1
T1(x) = x
T2(x) = 2x^2 - 1
T3(x) = 4x^3 - 3 x
T4(x) = 8x^4 - 8x^2 + 1
T5(x) = 16x^5 - 20x^3 + 5x
T10(x) = 512x^10 - 1280x^8 + 1120x^6 - 400x^4 + 50x^2 - 1

In the descending degree list format we'd get T3(x) = [4,0,-3,0] and in the ascending degree format we'd get T3(x) = [0,-3,0,4]

Mathematica, 15 bytes
#~ChebyshevT~x&

Of course, Mathematica has a builtin.
If an alternative input form is allowed (10 bytes):
ChebyshevT

takes an integer n and a variable.


Generating Euclidean rhythms Did you know that the Euclidean algorithm is capable of generating traditional musical rhythms? We'll see how this works by describing a similar, but slightly different algorithm to that in the paper.

Pick a positive integer n, the total number of beats, and a positive integer k, the number of beats which are sounded (notes). We can think of the rhythm as a sequence of n bits, k of which are 1s. The idea of the algorithm is to distribute the 1s as evenly as possible amongst the 0s.

For example, with n = 8 and k = 5, we start with 5 ones and 3 zeroes, each in its own sequence:

[1] [1] [1] [1] [1] [0] [0] [0]

At any point we will have two types of sequences — the ones at the start are the "core" sequences and the ones at the end are the "remainder" sequences. Here the cores are [1]s and the remainders are [0]s. As long as we have more than one remainder sequence, we distribute them amongst the cores:

[1 0] [1 0] [1 0] [1] [1]

Now the core is [1 0] and the remainder is [1], and we distribute again:

[1 0 1] [1 0 1] [1 0]

Now the core is [1 0 1] and the remainder is [1 0]. Since we only have one remainder sequence, we stop and get the string

10110110

This is what it sounds like, repeated 4 times:

Here's another example, with n = 16 and k = 6:

[1] [1] [1] [1] [1] [1] [0] [0] [0] [0] [0] [0] [0] [0] [0] [0]
[1 0] [1 0] [1 0] [1 0] [1 0] [1 0] [0] [0] [0] [0]
[1 0 0] [1 0 0] [1 0 0] [1 0 0] [1 0] [1 0]
[1 0 0 1 0] [1 0 0 1 0] [1 0 0] [1 0 0]
[1 0 0 1 0 1 0 0] [1 0 0 1 0 1 0 0]
1001010010010100

Note how we terminated on the last step with two core sequences and no remainder sequences. Here it is, repeated twice:

Input

You may write a function or a full program reading from STDIN, command line or similar. Input will be two positive integers n and k <= n, which you may assume is in either order.

Output

Your task is to output the generated rhythm as an n character long string. You may pick any two distinct printable ASCII characters (0x20 to 0x7E) to represent notes and rests.

Test cases

The following test cases use x to represent notes and .s to represent rests. Input is given in the order n, then k.

1 1    ->  x
3 2    ->  xx.
5 5    ->  xxxxx
8 2    ->  x...x...
8 5    ->  x.xx.xx.
8 7    ->  xxxxxxx.
10 1   ->  x.........
11 5   ->  x.x.x.x.x..
12 7   ->  x.xx.x.xx.x.
16 6   ->  x..x.x..x..x.x..
34 21  ->  x.xx.x.xx.xx.x.xx.x.xx.xx.x.xx.x.x
42 13  ->  x...x..x..x..x...x..x..x..x...x..x..x..x..
42 18  ->  x..x.x.x..x.x.x..x.x.x..x.x.x..x.x.x..x.x.

Scoring

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

CJam, 37 34 30 27 24 bytes

3 bytes saved by user23013.

q~,f>{_(a-W<}{e`:a:e~z}w

This takes the input as k first, n second. It uses 1 and 0 to indicate notes and rests, respectively.

Try it here. Alternatively, here is a test harness which runs all of the given test cases (swapping the input order) and also reformats the output to use x and . for easier comparison with the reference solutions. (The results appearing in the input of the test harness are discarded before running the code. They could be safely removed without affecting the program.)

Explanation

q~                       e# Read and eval the input, dumping k and n on the stack.
  ,                      e# Create a range [0 .. n-1]
   f>                    e# For each of them, check if it's less than k.
                         e# This gives k 1s and n-k 0s.
     {      }{        }w e# While the first block yields a truthy result, execute
                         e# the second block.
      _                  e# Duplicate the array.
       (a-               e# Remove all instances of core sequences.
          W<             e# Remove one remainder sequence if there is one. This
                         e# gives an empty array (falsy) whenever there are less
                         e# than two remainder sequences.
              e`         e# Run-length encode. I.e. this turns an array into a list
                         e# of pairs of run-length and element.
                :a:e~    e# Wrap each RLE pair in an array and RLD it. This
                         e# partitions the array into cores and remainders.
                     z   e# Zip the two parts, interleaving cores and remainders.

This process very deeply nested arrays, but the important part is that all cores (and all remainders) always have the same nested structure, so they are still  equal to each other. CJam automatically prints the stack contents at the end of the program and omits array delimiters entirely, hence this structure does not affect the output either.


Permanently self-modifying code Now, we all know most languages have very simple ways to "self-modify" code.
However, what if you were to actually modify the code and edit parts of it...on disk?

Your goal is to make code that prints a number, then edits its own file to replace the number with the next one in the Fibonacci sequence like so:

$ ./program
1
$ ./program
1
$ ./program
2
$ ./program
3
$ ./program
5
[etc...]

Rules

You may not store the number(s) "outside" of the code. No comments, no telling the script to exit, no EOF, etc.
If your code works with any filename, subtract 2 from your byte amount and write $BYTESNOW ($ORIGINALBYTES - 2) in your title. (Filenames are assumed to be within the range of any alphanumeric file path.)
Your code must write the output to the file on it's own, without any external piping assistance.
Your code can start from one or zero. It doesn't matter.

Bash, 52 47 (49-2) bytes
EDITS:

Saved 5 bytes, by starting with 1 instead of 0. Thanks @Leo !

Golfed
A=$[1+0]
echo $A
sed -ri "s/\w+\+(\w+)/\1+$A/" $0

Test
>for i in `seq 10`
> do
> ./fibo
> done
1
1
2
3
5
8
13
21
34
55


Modular multiplicative inverse Your task is to given two integer numbers, a and b calculate the modular multiplicative inverse of a modulo b, if it exists.

The modular inverse of a modulo b is a number c such that ac ≡ 1 (mod b). This number is unique modulo b for any pair of a and b. It exists only if the greatest common divisor of a and b is 1.

The Wikipedia page for modular multiplicative inverse can be consulted if you require more information about the topic.

Input and Output

Input is given as either two integers or a list of two integers. Your program should output either a single number, the modular multiplicative inverse that is in the interval 0 < c < b, or a value indicating there is no inverse. The value can be anything, except a number in the range (0,b), and may also be an exception. The value should however be the same for cases in which there is no inverse.

0 < a < b can be assumed

Rules

The program should finish at some point, and should solve each test case in less than 60 seconds
Standard loopholes apply

Test cases

Test cases below are given in the format, a, b -> output

1, 2 -> 1
3, 6 -> Does not exist
7, 87 -> 25
25, 87 -> 7
2, 91 -> 46
13, 91 -> Does not exist
19, 1212393831 -> 701912218
31, 73714876143 -> 45180085378
3, 73714876143 -> Does not exist

Scoring

This is code golf, so the shortest code for each language wins.

This and this are similar questions, but both ask for specific situations.

Mathematica, 14 bytes

Obligatory Mathematica builtin:

ModularInverse

It's a function that takes two arguments (a and b), and returns the inverse of a mod b if it exists. If not, it returns the error ModularInverse: a is not invertible modulo b..


Polycops and Robbers (Robbers' Thread) This is the robbers' thread, the cops' thread is here

A polyglot is a program, that without modification, can run in multiple languages.

Robbers' Challenge
First, find a vulnerable cop's answer, then try to find languages that the submission works in, if you found any that weren't listed by the cop, then you just cracked their answer. Post an answer linking to the original answer and what languages you found it working on (it must do the same thing on each language). You can then leave a comment on their answer linking back to your answer on this thread.

Winning
Most upvoted answer that actually does crack the cops' code wins

Foo, PotatoLatte's answer

puts "Hello World!"

Try it online!

Ah, the bane of cops and robbers, Foo.


Make all the squares explode You are given a square matrix of width \$\ge2\$, containing square numbers \$\ge1\$.
Your task is to make all square numbers 'explode' until all of them have disappeared. You must print or return the final matrix.
More specifically:

Look for the highest square \$x^2\$ in the matrix.
Look for its smallest adjacent neighbor \$n\$ (either horizontally or vertically and without wrapping around).
Replace \$x^2\$ with \$x\$ and replace \$n\$ with \$n\times x\$.

Repeat the process from step 1 until there's no square anymore in the matrix.
Example
Input matrix:
$$\begin{pmatrix}
625 & 36\\
196 & 324
\end{pmatrix}$$
The highest square \$625\$ explodes into two parts of \$\sqrt{625}=25\$ and merges with its smallest neighbor \$36\$, which becomes \$36\times 25=900\$:
$$\begin{pmatrix}
25 & 900\\
196 & 324
\end{pmatrix}$$
The highest square \$900\$ explodes and merges with its smallest neighbor \$25\$:
$$\begin{pmatrix}
750 & 30\\
196 & 324
\end{pmatrix}$$
The highest square \$324\$ explodes and merges with its smallest neighbor \$30\$:
$$\begin{pmatrix}
750 & 540\\
196 & 18
\end{pmatrix}$$
The only remaining square \$196\$ explodes and merges with its smallest neighbor \$18\$:
$$\begin{pmatrix}
750 & 540\\
14 & 252
\end{pmatrix}$$
There's no square anymore, so we're done.
Rules

The input matrix is guaranteed to have the following properties:

at each step, the highest square will always be unique
at each step, the smallest neighbor of the highest square will always be unique
the sequence will not repeat forever

The initial matrix may contain \$1\$'s, but you do not have to worry about making \$1\$ explode, as it will never be the highest or the only remaining square.
I/O can be processed in any reasonable format
This is code-golf

Test cases
Input : [[16,9],[4,25]]
Output: [[24,6],[20,5]]

Input : [[9,4],[1,25]]
Output: [[3,12],[5,5]]

Input : [[625,36],[196,324]]
Output: [[750,540],[14,252]]

Input : [[1,9,49],[1,4,1],[36,25,1]]
Output: [[3,6,7],[6,2,7],[6,5,5]]

Input : [[81,4,64],[16,361,64],[169,289,400]]
Output: [[3,5472,8],[624,323,1280],[13,17,20]]

Input : [[36,100,1],[49,144,256],[25,49,81]]
Output: [[6,80,2],[42,120,192],[175,21,189]]

Input : [[256,169,9,225],[36,121,144,81],[9,121,9,36],[400,361,100,9]]
Output: [[384,13,135,15],[24,1573,108,54],[180,11,108,6],[380,209,10,90]]

Input : [[9,361,784,144,484],[121,441,625,49,25],[256,100,36,81,529],[49,4,64,324,16],[25,1,841,196,9]]
Output: [[171,19,700,4032,22],[11,210,525,7,550],[176,60,6,63,23],[140,112,1152,162,368],[5,29,29,14,126]]

R, 301 287 277 274 222 217 195 186 178 174 bytes

Nothing particularly creative, including the zero buffering of the peripheral elements of the entry matrix, an earlier version later improved by Robin:

function(x){w=which.max
if(any(s<-!x^.5%%1)){
y=cbind(NA,rbind(NA,x,NA),NA)
z=y[i]=y[i<-w(y*y%in%x[s])]^.5
m=i+c(r<--c(1,nrow(y)),-r)
y[j]=y[j<-m[w(-y[m])]]*z
x=p(y[r,r])}
x}

Try it on-line

Using a sequence of numbers as its entry, and hence removing the call to a function, Nick Kennedy earlier managed a 186 bytes version of the algorithm as follows (with -10 bytes by Robin):

w=which.max;`~`=cbind;x=scan();while(any(s<-!x^.5%%1)){y=NA~t(NA~matrix(x,n<-length(x)^.5)~NA)~NA;i=w(y*y%in%x[s]);=i+c(r<--c(1,n+2),-r);y[j]=y[j<-m[w(-y[m])]]*(y[i]=y[i]^.5);x=y[r,r]};x

avoiding the definition of a (recursive) function, plus other nice gains.

Try it on-line


A-Z in 10's, you see? As a follow up to my previous challenge Count to 20 with Words!, we will once again be using the word list from that challenge to perform another task. This time, you will be exclusively using:
https://github.com/Magic Octopus Urn/wordListsByLength/blob/master/10.txt
To choose 26 different words, each starting with a unique letter, and output them in ascending order from A to Z. Here's a valid example:
aardwolves
babbitting
caravaning
debilitate
evaporator
fantasized
geographer
hawfinches
imbecility
juvenility
kalanchoes
lamaseries
malodorous
nudibranch
oligophagy
pantywaist
quarreling
russetting
scantiness
teetotaler
undercount
voodooisms
wentletrap
xenophobic
yeomanries
zwitterion

This is an aardwolf, this is a hawfinch, this is a kalanchoe, this is a nudibranch and a wentletrap.

Rules

No reading directly from the repository, or any other loopholes.
You may select any 26 of the words provided in the link.

You choose words and these are the words your program should output every time.

One word beginning with each of the following letters must be selected:

[a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z]

This is code-golf, lowest byte-count wins.

Any other suggestions for spin-offs using the word lists?
Also, feel free to steal my word-lists and make challenges.

Bubblegum, 100 99 bytes

00000000: 45ce 4502 0420 0800 c0bb bfb4 3bc1 adcf  E.E.. ......;...
00000010: 6f23 b7a1 910b 63b3 0016 84da 40d4 fd41  o#....c.....@..A
00000020: 344c 2b81 e824 e09f 9e19 e4e9 8d3a 1353  4L+..$.......:.S
00000030: 3f7c c3fc 59b8 b732 5b07 62e7 c383 4fcc  ?|..Y..2[.b...O.
00000040: 4d5f 88c5 bd60 6f44 8c8d b87d 215e 78c3  M_...`oD...}!^x.
00000050: 359e ec4d 360c bd4a 94e2 6e25 e06f ef43  5..M6..J..n%.o.C
00000060: d286 17                                  ...

Try it online!

Output:

artinesses
businesses
cozinesses
dozinesses
easinesses
fastnesses
gastnesses
hazinesses
ickinesses
jokinesses
kindnesses
lazinesses
mazinesses
nosinesses
oozinesses
pastnesses
queasiness
rosinesses
sexinesses
tininesses
uglinesses
vastnesses
wilinesses
xanthomata
yeastiness
zaninesses

The words were again selected with simulated annealing:

from __future__ import print_function
import math
import random
import zopfli.zlib

wordlists = [[] for n in range(26)]
for word in open('wordListsByLength/10.txt', 'rb').read().splitlines():
    wordlists[ord(word[:1]) - ord('a')].append(word)

words = [random.choice(wordlist) for wordlist in wordlists]

temperature = 1.
score = 9999
best = score

while True:
    old_score = score
    n = random.randrange(len(wordlists))
    old_word = words[n]
    words[n] = random.choice(wordlists[n])
    score = len(zopfli.zlib.compress(b'\n'.join(words)) - 6
    if score > old_score and random.random() >= math.exp((old_score - score) / temperature):
        words[n] = old_word
        score = old_score
    else:
        temperature *= .9999
        if score < best:
            best = score
            print(best, repr(b'\n'.join(words)))


Sprunge this! Sprunge that! Your task is to create a program or function that creates a paste on sprunge.us. Your program/function must receive the text to sprunge from your language's usual input mechanism, such as standard in; or in the case of a function, it can be a string or whatever makes the most sense to you. Your program will POST the text from input to http://sprunge.us/ as multipart/form-data with the form field name of sprunge. Finally, your program will output/return the URL sent back in the reply from the POST.

This is a code golf, so shortest answer (in bytes) wins.

Here is an example solution using bash and curl taken directly from the sprunge.us website. Feel free to use it in your own golf:

curl -F 'sprunge=<-' http://sprunge.us

Which returns the URL to the paste, which looks like http://sprunge.us/aXZI, where the aXZI is the ID of the sprunge.

This is my first code golfing challenge, please let me know if this is too easy or not creative enough

Bash, 30 bytes

curl -F'sprunge=<-' sprunge.us

Just removed the unneeded space in -F 'sprunge=<-' and the http:// from the sprunge.us url.  OP gave me explicit permission to golf his reference solution.


05AB1E, 17 16 14 12 11 bytes
∞ʒÒDS{āQиg<

Outputs the infinite sequence.
-2 bytes thanks to @CommandMaster, which also opened up the opportunity to golf 2 more bytes
-1 byte thanks to @ovs.
Try it online.
Explanation:

∞         # Push an infinite list of positive integers: [1,2,3,...]
 ʒ        # Filter this list by:
  Ò       #  Get a list of its prime factors (including duplicates)
   D      #  Duplicate this list
    S     #  Convert the list of integers to a flattened list of digits
     {    #  Sort these digits
      ā   #  Push a list in the range [1,length] (without popping the list itself)
       Q  #  Check that the two lists are equal (1 if truthy; 0 if falsey)
    и     #  Repeat the list if prime factors that many times as list
          #  (so it'll become empty for falsey results; and stays the same for truthy)
     g    #  Pop and push the length of this list
      <   #  And decrease it by 1
          #  (NOTE: only 1 is truthy in 05AB1E, so if the amount of prime factors was
          #  anything other than 2, this will be falsey)
          # (after which the filtered infinite list is output implicitly as result)


Find the number of ways to choose `n` objects from `r` objects with repetition so that every object has a matching neighbour For example, if n is 5 and r is 2, it would mean the number of lists below:

[1,1,1,1,1]
[1,1,1,2,2]
[1,1,2,2,2]
[2,2,1,1,1]
[2,2,2,1,1]
[2,2,2,2,2]

which is 6.

If n is 4 and r is 3:

[1,1,1,1]
[1,1,2,2]
[1,1,3,3]
[2,2,1,1]
...
[3,3,3,3]

which is 9.

where each item has a neighbour whose value is the same.

For example, [1,2,1,1,2] is not counted, because both 2 are alone.

Goal

Your task is to write a program/function which takes two inputs in any order, and which produces the required output.

Detail

You can assume that r≥2.

Scoring

This is code-golf. Shortest solution in bytes wins.

Bonus

Multiply your score by 0.3 if the complexity of your program is below O(e^n).

For example, 10 bytes becomes 3 bytes.

Testcases

Can be generated from this Pyth test suite.

Usage: two lines per testcase, n on top, r below.

n r output
2 5 5
4 4 16
6 3 33
8 2 26

Additional information

When r=2: OEIS A006355.

Pyth, 14 bytes * 0.3 = 4.2 bytes

*Quh*~+ZGtQtE0

Try it online: Demonstration. Input r on the first line and n on the second line.

Complexity is O(n).

Explanation:

Let f(n, r) be the number of ways to create such a list with the last number being 0. Obviously it doesn't matter if we take 0 or any other number.

It's easy to see, that the following recursion holds:

f(n, r) = 0                                  ... if n < 2
f(n, r) = sum(f(i, r), i <= n-2) * (r-1) + 1 ... otherwise

If n == 0, than the list cannot end with the number 0. If n == 1, than the only number in the list has no neighbor. Therefore both cases have the value zero.

If n >= 2, than it could end in 2, 3, ... n zeros. The digit before the last zero can be any of the number 1, 2, ..., r-1. These are r-1 possibilities. Therefore I'll add up all f(i,n) and multiply by r-1. At the end I'll have to add 1 (for the case that all digits are zeros).

The result to the question than is: r * f(n, r), since the list can end in any of the r numbers.

In my code I make use of the predefined variable Z = 0. It will contain the last computed sum so far.

*Quh*~+ZGtQtE0   implicit: Q = first input number (r)
  u        tE0   start with G=0, do the following input-1 (n-1) times:
     ~+ZG           add G to Z
   h*~ Z tQ         and update G to the value Z*(Q-1) + 1
                    (using the old value of Z)
*Q               multiply the result with Q


The Chroma Key to Success The RGB color value #00FF00 is a rather important one: it is used to make movies, TV shows, weather announcements, and more. It is the famous "TV green" or "green screen" color.
The Challenge
Your task is to write a program that takes two input images, both in PNG format (or in your image library's image object type) and of the same dimensions. One image can be any old image. The other one is the image that will have a background of the color #00FF00. The output image will consist of the second image overlaid over the first, with no #00FF00 color present (except in the first image). Input and output may be done with files, a GUI, etc. You are allowed to take an array of RGB values as input, as seen here. You may assume that an image has only pixels of full opacity.
Basically...
Make a program that takes every #00FF00 pixel in one image and replace it with the corresponding pixel in the background image.
Test Cases
Generously provided by @dzaima:
Background:

Foreground:

Output:

Of course, standard loopholes are strictly forbidden. This includes using an online resource to do it for you.
This is code-golf, so may the shortest code win and the best programmer prosper...

x86-64 (and x86-32) machine code, 13 15 13 bytes
changelog:

Bugfix: the first version was only checking G=0xff, not requiring R and B to be 0.  I changed to modifying the background in place so I could use lodsd on the foreground to have fg pixels in eax for the short-form cmp eax, imm32 encoding (5 bytes), instead of cmp dh,0xff (3 bytes).

Save 2 bytes: noticed that modifying the bg in place allowed using a memory operand for cmov, saving a 2-byte mov load (and saving a register, in case that matters).

This is a function following the x86-64 System V calling convention, callable directly from C or C++ (on x86-64 non-Windows systems) with this signature:
void chromakey_blend_RGB32(uint32_t *background /*rdi*/,
                     const uint32_t *foreground /*rsi*/,
                  int dummy, size_t pixel_count /*rcx*/);

The image format is RGB0 32bpp, with the green component at the 2nd lowest memory address within each pixel.  The foreground background image is modified in-place.  pixel_count is rows*columns.  It doesn't care about rows/columns; it just chromekey blends however many dwords of memory you specify.
RGBA (with A required to be 0xFF) would require using a different constant, but no change in function size.  Foreground DWORDs are compared for exact equality against an arbitrary 32-bit constant stored in 4 bytes, so any pixel-order or chroma-key colour can be easily supported.
The same machine code also works in 32-bit mode.  To assemble as 32-bit, change rdi to edi in the source.  All other registers that become 64-bit are implicit (lodsd/stosd, and loop), and the other explicit regs stay 32-bit.  But note that you'll need a wrapper to call from 32-bit C, because none of the standard x86-32 calling conventions use the same regs as x86-64 SysV.
NASM listing (machine-code + source), commented for asm beginners with descriptions of what the more complex instructions do.  (Duplicating the instruction reference manual is bad style in normal usage.)
 1                       ;; inputs:
 2                       ;; Background image pointed to by RDI, RGB0 format  (32bpp)
 3                       ;; Foreground image pointed to by RSI, RGBA or RGBx (32bpp)
 4          machine      ;; Pixel count in RCX
 5          code         global chromakey_blend_RGB32
 6          bytes        chromakey_blend_RGB32:
 7 address               .loop:                      ;do {
 8 00000000 AD               lodsd                   ; eax=[rsi], esi+=4. load fg++
 9 00000001 3D00FF0000       cmp    eax, 0x0000ff00  ; check for chromakey
10 00000006 0F4407           cmove  eax, [rdi]       ; eax = (fg==key) ? bg : fg
11 00000009 AB               stosd                   ; [rdi]=eax, edi+=4. store into bg++
12 0000000A E2F4             loop .loop              ;} while(--rcx)
13
14 0000000C C3               ret

##  next byte starts at 0x0D, function length is 0xD = 13 bytes

To get the original NASM source out of this listing, strip the leading 26 characters of each line with <chromakey.lst cut -b 26- > chromakey.asm.  I generated this with
nasm -felf64 chromakey-blend.asm -l /dev/stdout | cut -b -28,$((28+12))-
NASM listings leave more blank columns than I want between the machine-code and source.  To build an object file you can link with C or C++, use nasm -felf64 chromakey.asm.  (Or yasm -felf64 chromakey.asm).
untested, but I'm pretty confident that the basic idea of load / load / cmov / store is sound, because it's so simple.
I could save 3 bytes if I could require the caller to pass the chroma-key constant (0x00ff00) as an extra arg, instead of hard-coding the constant into the function.  I don't think the usual rules allow writing a more generic function that has the caller set up constants for it.  But if it did, the 3rd arg (currently dummy) is passed in edx in the x86-64 SysV ABI.  Just change cmp eax, 0x0000ff00 (5B) to cmp eax, edx (2B).

With SSE4 or AVX, you might do this faster (but larger code size) with pcmpeqd and blendvps to do a 32-bit element size variable-blend controlled by the compare mask.  (With pand, you could ignore the high byte).  For packed RGB24, you might use pcmpeqb and then 2x pshufb+pand to get TRUE in bytes where all 3 components of that pixel match, then pblendvb.
(I know this is code-golf, but I did consider trying MMX before going with scalar integer.)


Build a nine-level word guessing game The basics:
You'll need to provide a nine-level word guessing game in the fewest characters possible (in your language of choice).
The metrics:

Provide a word-list
(one word per line, seperated by a
newline) (e.g.
/usr/share/dict/words or similar could do). It's fine to
pipe a filename or the wordlist
itself into your solution.
Provide 9 levels with incrementing word length (words with 4 characters -> 12 characters):

Level 1:  a random word from the wordlist containing 4 characters
Level 2:  a random word from the wordlist containing 5 characters
...                                                  ...
Level 8:  a random word from the wordlist containing 11 characters
Level 9:  a random word from the wordlist containing 12 characters

In every level, obfuscate a randomly chosen word from the list (with a specific word length of course) and replace a certain number of characters by the asterisk (*). The number of characters to replace: current_word_length / 3 (round down). Randomize which characters to replace.
Let the player 'guess' the word (only one try per level), give feedback (correct or wrong) and give points accordingly. When correct, the player gains number_of_obfuscated_characters * 10 points.
Print the current score at the end of each level.

The format (& sample I/O):
Make sure you follow the following formatting scheme:

Level 1     # level header
=======     #
g*ek        # obfuscated word
geek        # user input
correct     # guess validation
score: 10   # print score
            #
Level 2
=======
l*nux
linux
correct
score: 20

Level 3
=======
ran**m
random
correct
score: 40

...

Level 9
=======
sem***act*ve
semiinactive
wrong
score: 90

Winner:
Shortest solution (by code character count). Have fun golfing!

Ruby (188)

takes the filename to read words from as argument.

q=*$<
s=0
4.upto(12){|n|o=''+w=q.grep(/^#{?.*n}$/).sample
[*0..n-1].sample(c=n/3).map{|i|o[i]=?*}
puts"Level #{n-3}",?=*7,o
puts STDIN.gets==w ?(s+=c;"correct"):"wrong","score: #{s}0",""}


Cropping an image succintly I am constantly frustrated by how complicated it is to write graphical programs that would have been only a few lines of code 20+ years ago.  Since the invention of the mouse this has become even worse it seems.  I was hoping someone could put me out of my misery and show the shortest code to do the following really basic "modern" operations.

The code will read in an image in any sensible format of your choosing (png, jpg, etc.), display it on the screen, allow you to choose a rectangular region with your mouse and then just save the selected region as an image file.

You are free to use any programming language and any library which hasn't been written especially for this competition.  Both should be freely (in both senses) online.  The code should be runnable in linux.

To start things off.... here is a very lightly golfed solution in python modified from code to Andrew Cox from https://stackoverflow.com/questions/601874/digital-image-cropping-in-python which takes 1294 1101 characters.

import pygame, sys
from PIL import Image
pygame.init()

def displayImage( s, px, t):
    s.blit(px, px.get_rect())
    if t:
        pygame.draw.rect( s, (128,128,128), pygame.Rect(t[0], t[1], pygame.mouse.get_pos()[0] - t[0], pygame.mouse.get_pos()[1] - t[1]))
    pygame.display.flip()

def setup(path):
    px = pygame.image.load(path)
    s = pygame.display.set_mode( px.get_rect()[2:] )
    s.blit(px, px.get_rect())
    pygame.display.flip()
    return s, px

def mainLoop(s, px):
    t = None
    b = None
    runProgram = True
    while runProgram:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                runProgram = False
            elif event.type == pygame.MOUSEBUTTONUP:
                if not t:
                    t = event.pos
                else:
                    b = event.pos
                    runProgram = False
        displayImage(s, px, t)
    return ( t + b )

s, px = setup(sys.argv[1])
left, upper, right, lower = mainLoop(s, px)
im = Image.open(sys.argv[1])
im = im.crop(( left, upper, right, lower))
im.save(sys.argv[2])

I believe it is traditional to give a time limit, so I will accept the best answer in exactly one week's time.

Current count

Octave - 44 + 15 = 59 characters
R - 305 characters
Python - 343 characters
Java - 560 characters

Octave - 59 chars

pkg load image;imwrite(imcrop(imread(input(''))),input(''))

MATLAB - 44 chars (not free, out of the contest)

imwrite(imcrop(imread(input(''))),input(''))

MATLAB seemed spot-on for this. Requires the Image Processing Toolbox (or package image 2.0.0 from Octave Forge). Usage:

Write at prompt 'input-filename' (single quotes included)
MATLAB: Drag from top-left to bottom-right corner and double click the rectangle.
Octave: Click top-left and bottom-right corner
Write 'output-filename' (between single quotes too)


Golf an InterpretMe interpreter This is a very simple challenge.

The joke language InterpretMe consists of one command; *, which causes the program to take input of an InterpretMe program and execute it.

An InterpretMe  program will interpret as many InterpretMe programs as there are * in input.

Your goal is to create a program that interprets InterpretMe in as few bytes as possible.

Input

Input will consist of one line ASCII strings, unicode utf-8 strings if you really want, or any character encoding that your language uses, if you want it that much. These strings can either be inputted at the start, or at the start of every run of InterpretMe interpreter. If they are all inputted at the start, the program must output every program line as it begins it.

Output

In this challenge, there will be no output unless the option of one input is chosen, otherwise only termination and non-termination

Test cases consist not of input and output, but input and termination. A newline denotes a new input to be interpreted as InterpretMe.

If using one input at the start, this could be considered what is outputted when these programs are inputted, followed by inactive (do nothing) lines.

1. *   (executes input as an interpret me program, finishes)
2. *   (^same)
3. **  (executes input as an interpret me program, then does this again after the first program is done, finishes)
4. hi  (nothing, first star of previous line finishes)
5. **  (same as the other two star line)
6. hi  (nothing, first star of previous line finishes)
7. hi  (nothing, second star of line 5 finishes, so second star of line 3 finishes, so line 2 finishes, so line one finishes)
[termination] (not outputted)

hi  (does nothing and finishes)
[termination]

*hi  (executes inputted program, finishes)
*yo  (executes inputted program, finishes)
hey  (nothing)
[termination]

Again, this is code-golf, so fewer bytes is better

Python 3, 35 bytes

i=1
while i:i+=input().count('*')-1

sets i to one, adds the amount of '*' -1 to i

I think I can reduce this with ~ trickery I couldn't


Print a string with vertical words Your task is to take an input string of ascii characters and output the string as a series of vertical words separated by spaces. An example is shown below:

Given the string:

Hello, World! My name is Foo.

the output should be:

H W M n i F
e o y a s o
l r   m   o
l l   e   .
o d
, !

10 bonus points will be awarded if your program correctly handles strings which need to wrap-around the terminal, which we'll set at 80 characters.

50 points if your program can also do the reverse!

J, 15

|:>'\S+| 'rxall

Usage:

   |:>'\S+| 'rxall 'Hello, World! My name is Foo.'
H W M n i F
e o y a s o
l r   m   o
l l   e   .
o d
, !


Is this number triangular? Challenge
Given a positive integer, determine whether it is a triangular number, and accordingly output one of any two constant, distinct values.
Definition
A triangular number is a number that can be expressed as the sum of consecutive positive integers, starting at 1. They can also be expressed with the formula \$\frac {n(n + 1)}  2\$, where \$n\$ is some positive integer.
Test cases
Truthy:
1
3
6
10
15
21
55
276
1540
2701
5050
7626
18915
71253
173166
222111
303031
307720
500500
998991

Falsy:
2
4
5
7
8
9
11
16
32
50
290
555
4576
31988
187394
501500
999999

Rules

Your entry may be a function or a program.
You may assume that the input is a positive integer under \$10^6\$.
You must pick two constant, distinct outputs to distinguish the two categories.

This is code-golf, so the shortest code in bytes in each language wins.

Haskell, 23 bytes

EDIT:

-1 byte: @xnor got rid of parentheses with a $.

An anonymous function taking an Int and returning a Char.

Output is '1' for triangular numbers and '0' for others.

(!!)$show.(10^)=<<[0..]

Try it online!

Use as ((!!)$show.(10^)=<<[0..]) 998991.
Generates the numbers 1, 10, 100, 1000, ..., converts those to strings, and concatenates them. Then indexes into the resulting infinite string

"1101001000100001000001000000...


Indent a string using given parentheses Given the following input to the program:

List of block start characters
List of block end characters
A string to format

format the string with the blocks delimited by the two character sets indented.

Formatting is done with two spaces per level and the parentheses are placed as shown in the example below. You may assume the sets of opening and closing characters to be disjoint.

E.g. for {[(< and }])> as the opening and closing character sets and the following string:

abc{xyz{text[note{comment(t{ex}t)abc}]}}

the following output would be expected:

abc
{
  xyz
  {
    text
    [
      note
      {
        comment
        (
          t
          {
            ex
          }
          t
        )
        abc
      }
    ]
  }
}

You may not hard-code the list of “parentheses” characters. How input is given is not specified, though; this could be either command-line arguments or via standard input, as you wish.

Perl - 131 96 94 chars

$i="";for$_(split/([\Q$ARGV[0]$ARGV[1]\E])/,$ARGV[2]){$i=~s/..// if/[\Q$ARGV[1]\E]/;print "$i$_\n"if$_;$i.='  'if/[\Q$ARGV[0]\E]/;}

Seems like there should be room for eliminating common expressions, at least, but it's a quick take that handles the example, as well as Joey Adams's hypothetical about arbitrary brackets.

There was, indeed, plenty of room for improvement:

$_=pop;($s,$e)=map"[\Q$_\E]",@ARGV;for(split/($s|$e)/){print"  "x($i-=/$e/),"$_\n"if$_;$i+=/$s/}

...and still a little more:

$_=pop;($s,$e)=map"[\Q$_\E]",@ARGV;map{print"  "x($i-=/$e/),"$_\n"if$_;$i+=/$s/}split/($s|$e)/


Tips for Golfing in Symja Symja is a "computer algebra language & Java symbolic math library for Android NCalc calculator". It's a fun little language, so I'm wondering if y'all have any tips for golfing in Symja.

As per usual, "remove comments", etc, isn't really an answer. It turns out that there is no comment system in Symja, so "remove comments" isn't an answer. :P

Don't Use Print...Use the Formatted Output

Here's an example fizzbuzz:

For(i=1,i<101,i++,s="";If(Mod(i,5)==0,s=s<>"Fizz");If(Mod(i,3)==0,s=s<>"Buzz");If(Mod(i,5)*Mod(i,3)!=0,s=s<>ToString(i));Print(s))

Now, this is alright, but it can be improved:

For(i=1,i<101,i++,If(Mod(i,5)==0,s=s<>"Fizz");If(Mod(i,3)==0,s=s<>"Buzz");If(Mod(i,5)*Mod(i,3)!=0,s=s<>ToString(i));s=s<>"\n");s

Sure, it's only two bytes shorter, but hey, it's two bytes shorter.

Just put all the output into a string and tack a ;<variable_name> onto the end and you'll have a shorter program (usually).