(Almost) Solve Fermat's Last Theorem It's a well-known fact that Fermat's Last Theorem is true. More specifically, that for any integer \$n \gt 2\$, there are no three integers \$a, b, c\$ such that
$$a^n + b^n = c^n$$
However, there are a number of near misses. For example,
$$6^3 + 8^3 = 9^3 - 1$$
We'll call a triple of integers \$(a, b, c)\$ a "Fermat near-miss" if they satisfy
$$a^n + b^n = c^n \pm 1$$
for some integer \$n > 2\$. Note that this includes negative values for \$a, b, c\$, so \$(-1, 0, 0)\$ is an example of such a triple for any \$n\$.

Your task is to take an integer \$n > 2\$ as input, in any convenient method. You may then choose which of the following to do:

Take a positive integer \$m\$ and output the \$m\$-th Fermat near-miss for that specific \$n\$
Take a positive integer \$m\$ and output the first \$m\$ Fermat near-misses for that specific \$n\$

For either of these two, you may choose any ordering to define the "\$m\$th" or "first \$m\$" terms, so long as the ordering eventually includes all possible triples. For example, the test case generator program below orders them lexographically.

Output all Fermat near-misses for that specific \$n\$

The output may be in any order, so long as it can be shown that all such triples will eventually be included. The output does not have to be unique, so repeated triples are allowed.
You may output in any format that allows for infinite output, such as an infinite list or just infinite output. You may choose the delimiters both in each triple and between each triple, so long as they are distinct and non-digital.

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

This program was helpfully provided by Razetime which outputs all solutions with \$|a|, |b|, |c| \le 50\$ for a given input \$n\$*.
This is a question asked over on MathOverflow about the existence of non-trivial solutions to
$$a^n + b^n = c^n \pm 1$$
Unfortunately, it appears (although is not proven, so you may not rely on this fact) that no non-trivial solutions exist for \$n \ge 4\$, so for most \$n\$, your output should be the same.
*Currently, this also returns exact matches, which your program shouldn’t do.

R, 119 110 108 105 100 bytes
Edit: -2 bytes thanks to Giuseppe

n=scan();repeat for(b in -(F=-F+!(F>0)):F)for(i in (d=-(c=F^n+b^n):c)[abs(d^n-c)==1])cat(F,b,i,'\n')

Try it online!
Prints the infinite list of near-misses, without duplicates (this includes duplicates by re-ordering a and b, so the triples (a,b,c) and (b,a,c) are considered duplicates: add an extra ,b,F,i,'\n' (11 bytes) to print the list with duplicates).
Wastes a few bytes avoiding taking nth-roots, to prevent floating-point errors.
How?
function(n){
                            # note: F (false), which represents variable a, is initialized to zero;
repeat{                     # repeat for ever:
 for(b in -F:F){            # try all possible values of b from -a to a,
  c=F^n+b^n                 # calculate c as a^n+b^n,
  c=(-c:c)                  # now find value in the range -c to c
  [(-c:c)^n%in%(c+c(1,-1))] # that gives either c+1 or c-1 when raised to the n-th power
                            # replace c with this value (if there is one),
  for(i in c)               # now, if there were any:
   print(c(F,b,i))}         # print out the a,b,c combination
 F=-F+!(F>0)}}              # update F to the next value of variable a, in the sequence:
                            # 0, 1, -1, 2, -2, 3, -3 ... and so on


7-segment differences I think most people around here know what a 7-segment display for digits is:

 _         _   _         _    _    _    _    _
| |    |   _|  _|  |_|  |_   |_     |  |_|  |_|
|_|    |  |_   _|    |   _|  |_|    |  |_|   _|

We can define the 7-segment difference (7SD) between two digits to be the number of segments that need to be toggled to switch from one to the other. E.g. the 7SD between 1 and 2 is 5 (the three horizontal segments and the lower two vertical segments need to be toggled), and the 7SD between 6 and 8 is 1.

Furthermore, we can define the 7SD between two numbers to be the sum of 7SDs between their corresponding digits. If one number is longer than the other, we assume they are right-aligned and add the number of segments needed to display the additional most-significant digits of the larger number. As an example, consider the 7SD between 12345 and 549:

  x:  1 2 3 4 5
  y:      5 4 9
7SD:  2+5+2+0+1 = 10

Your task is to compute 7SD between n and n+1, given n.

For convenience, here is the full table of 7SDs between individual digits. The row _ represents an empty position.

   _ 0 1 2 3 4 5 6 7 8 9

_  0 6 2 5 5 4 5 6 3 7 6
0  6 0 4 3 3 4 3 2 3 1 2
1  2 4 0 5 3 2 5 6 1 5 4
2  5 3 5 0 2 5 4 3 4 2 3
3  5 3 3 2 0 3 2 3 2 2 1
4  4 4 2 5 3 0 3 4 3 3 2
5  5 3 5 4 2 3 0 1 4 2 1
6  6 2 6 3 3 4 1 0 5 1 2
7  3 3 1 4 2 3 4 5 0 4 3
8  7 1 5 2 2 3 2 1 4 0 1
9  6 2 4 3 1 2 1 2 3 1 0

Input

Input is a single positive integer n.
You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument.
You may assume that the input is at most one less than the largest number which can be represented by your language's standard integer type, as long as that type supports at least values up to and including 127.

Output

You should print a single integer, the 7SD between n and n+1.
You may output via STDOUT (or closest alternative), function return value or function (out) argument.

Scoring

Standard code-golf rules apply, shortest code (in bytes) wins.

Test Cases

For some obscure reason, this sequence isn't in OEIS yet, although there is the closely related sequence A123587. Here are the first 100 numbers (starting with n = 1, 2, 3, ...):

5, 2, 3, 3, 1, 5, 4, 1, 4, 4, 5, 2, 3, 3, 1, 5, 4, 1, 7, 4, 5, 2, 3, 3, 1,
5, 4, 1, 4, 4, 5, 2, 3, 3, 1, 5, 4, 1, 5, 4, 5, 2, 3, 3, 1, 5, 4, 1, 5, 4,
5, 2, 3, 3, 1, 5, 4, 1, 3, 4, 5, 2, 3, 3, 1, 5, 4, 1, 7, 4, 5, 2, 3, 3, 1,
5, 4, 1, 6, 4, 5, 2, 3, 3, 1, 5, 4, 1, 3, 4, 5, 2, 3, 3, 1, 5, 4, 1, 6, 4

The first input for which the 7SD is greater than 9 is 1999 which should yield 11. Here are some other larger examples:

n          7SD
1999        11
12345        1
999999      14
5699999     15
8765210248   1

JavaScript (ES6), 46 40 bytes

f=n=>n?+"452331541"[n%10]||f(n/10|0)+2:2

Alternative formulation, also 46 40 bytes:

f=n=>n?26523308>>n%10*3&7||f(n/10|0)+2:2

Edit: Saved 6 bytes thanks to @xsot.


Swap capitalization of two strings your shift key is broken. wheNever you type two lines, the cApitaL
LetteRs in them get swappeD. you must write a program to fiX THIS!

Description

The input is two strings, s1 and s2, equal in length. They will each contain only printable ASCII and be at least one character in length. You may input these as two strings, an array of two strings, or a single string with s1 and s2 separated by either a tab or newline.

The output is the following:

For each character c in s1:

If the character is not a letter, output it unchanged.
Otherwise, if c is a letter:

Find the matching character (the one at the same index) in s2.

If it is a capital letter, output c capitalized.
If it is a lowercase letter, output c in lowercase.
Otherwise, output c unchanged.

Then do the same thing, except with s1 and s2 switched.

Essentially, all letters in s1 for which the matching character in s2 is capital should be capitalized, and all letters in s1 with a lowercase letter at the same index in s2 should become lowercase (and vice versa).

Test cases

Input:

ABCDEfghijKlMnOpqrstuvwxyz
aaaaaaaaaaaaaaaa----------

Output:

abcdefghijklmnopqrstuvwxyz
AAAAAaaaaaAaAaAa----------

Input:

PRogrammiNG puzZLes & CODe golf
SdlkhkfaladlKsdlalksdg7ldklDgsl

Output:

Programming Puzzles & Code Golf
SDlkhkfalADlksdLAlksdg7LDkldgsl

Input:

AAAbbb111
Cc2Dd3Ee4

Output:

AaABbb111
CC2dd3Ee4

CJam, 25 bytes

{z{_el_eu&\__:^32&f^?}%z}

This is an anonymous function that pops an array of strings from the stack and leaves one in return.

In supported browsers, you can verify all test cases at once in the CJam interpreter.

Test cases

Code

qN/2/                     e# Read input and split into arrays of two strings.

{z{_el_eu&\__:^32&f^?}%z}

%                         e# Map the block over all string arrays.
:+N*                      e# Separate the strings by linefeeds.

Input

ABCDEfghijKlMnOpqrstuvwxyz
aaaaaaaaaaaaaaaa----------
PRogrammiNG puzZLes & CODe golf
SdlkhkfaladlKsdlalksdg7ldklDgsl
AAAbbb111
Cc2Dd3Ee4

Output

abcdefghijklmnopqrstuvwxyz
AAAAAaaaaaAaAaAa----------
Programming Puzzles & Code Golf
SDlkhkfalADlksdLAlksdg7LDkldgsl
AaABbb111
CC2dd3Ee4

How it works

z                       e# Zip to transform the array of strings into an array
                        e# of character pairs.
 {                  }%  e# For each character pair:
  _el                   e#   Push a copy and convert to lowercase.
     _eu                e#   Push a copy and convert to uppercase.
        &               e#   Intersect. The result will be an empty string if
                        e#   and only if both characters are letters.
         \              e#   Swap the character pair on top of the stack.
          __            e#   Push two copies.
            :^          e#   XOR both characters.
              32&       e#   Logical AND with 32. This pushes 32 for letters of
                        e#   different cases and 0 for letters of the same case.
                 f^     e#   XOR each character with the result.
                   ?    e#   Select the original copy for non-empty intersection
                        e#   and the modified one otherwise.
                      z e# Zip to turn the characters pairs back into two strings.


Lever Simulator 2015 Why a Simulator?
Kids these days don't have the time nor the ambition to actually go and stack boxes on the see-saw or play around with balancing physical objects. This leaves lots of room in the software market for a Lever Simulator which will, according to my models, sell like mad!
Programming Help Wanted
I've filed the patent for such a game (pending), but need an expert programmer to write the game-logic for me. From my understanding, it is standard practice to compensate programmers based on the size in bytes of the final program. As such I will be awarding this lucrative contract to the lowest bidder.
Specification
A lever is a series of boxes or empty spaces that is balanced by a fulcrum. Each box has a particular weight one through nine and spaces have no weight. As you know, a box's weight on the lever is directly proportional to how far that box is from the fulcrum. A box of weight 4 that is on the third space from the fulcrum will contribute 12 effective units of force to that side of the lever.
I need a program that, given an input lever, will output whether the lever will skew toward the left, the right, or be perfectly balanced.
I/O Guidelines

You will write for me a program.
The input will contain one line of text.
The input will come from stdin or as one command-line string.
Boxes will represented by the characters '1' through '9'. These characters represent their respective weights.  An empty space will be represented by a space ' '. The fulcrum will be represented by a caret '^'.

A sample input lever could look like: 8  2^ 941
This lever is perfectly balanced: (4*8) + 0 + 0 + (1*2) == 0 + (2*9) + (3*4) + (4*1) == 34

There will be no leading nor trailing spaces. There will be no trailing newline.
No need to handle malformed input, input will always have exactly one fulcrum, and only numbers and spaces.
The output will indicate whether the lever is left-heavy, right-heavy, or balanced.
Your program must have exactly 3 possible outputs that could result from a well-formed input. You can choose what these are.
The output must either be print to stdout or be the return code of the program.

Test cases
Here I use L,R,B to mean left-heavy, right-heavy, balanced:

Input: 11   ^9 Output: B

Input: 321^  12 Output: L

Input: 9^         1 Output: R

(If anyone has some "trickier" test cases, feel free to edit them in).
Bibliography
Not-necessarily-inspired-by, but related to Balance a set of weights on a seesaw

Javascript ES6, 62 Bytes

s=>Math.sign([...s].reduce((p,c,i)=>p+~~c*(i-s.indexOf`^`),0))

-1 if left is heavier
0 if balanced
1 if right is heavier

Ungolfed:

s=>
  Math.sign(                     // output sign of weight of lever
    [...s].reduce((p,c,i)=>      // split and reduce input
      p+~~c*(i-s.indexOf`^`),0)) // add weights of all elements
                                 //   (elements left of pivot are negatively weighted)

Test runs (assigning anonymous function to f):

>> f("11   ^9")
<< 0

>> f("321^  12")
<< -1

>> f("9^         1")
<< 1

-11 bytes: changed output from R B L to -1 0 1
-3 bytes: changed e.split`` to [...e] (thanks @Vɪʜᴀɴ)
-33 bytes: changed algorithm to use negative weights rather than splitting at pivot
-9 bytes: removed pivot check (apparently, ~~'^' evaluates to 0...)
-2 bytes: made function anonymous (thanks @cᴏɴᴏʀ-obʀɪᴇɴ)


Write a short story using only valid code What I'd like to see is your attempts at writing a kind of "story" that has a fairly easy to read meaning, but also creating a valid code fragment. For example, this (BBC) BASIC code:

LET customer = "sober"
REPEAT
  INPUT "more beer"
UNTIL customer = "drunk"

(based on http://img.rakuten.com/PIC/12184048/0/1/300/12184048.jpg for the idea)

Rules/guidelines:

The code must be valid in the language you specified - Anybody must be able to run it without needing to create any fancy
Strings, comments, or anything that allows free text to be added to the code, may be used, but for at most 3 words per string (and you can't put multiple strings or comments in  a row)
Your code does not have to result in any sensible output when it's executed. It can even be an infinite loop, as long as the code is valid and it represents something sensible(*) when read in English.
Any interpunction in your code will be ignored in the story.
Variables do not need to be defined. The code you make here is just a code fragment. You will lose 5 points for calling an undefined variable/keyword/label/etc. though.
for every individual built-in keyword/statement/function/etc you use, you receive 15 points. These include for and if, but also built-in functions such as replace(). Libraries do not count as built-in functions, but you're free to use them.
for every letter, number, or underscore in your code, you receive 1 point.
for every line/block of code that is unrelated() to the story, or uses keywords/statements/etc with no meaning() in English, you lose 20 points, and the involved characters will not count towards the 1 point per letter/number. To keep it fair to the languages that need data types like int when defining variables, data types are ignored completely. This means they don't receive 10 points for being a keyword, they won't receive points for the involved characters, but they also don't cause point loss.
It is not allowed to just make something valid English by inserting a comment to "fill in the blanks".
Since this is a popularity-contest, for every upvote to your answer you will receive 25 points.
Make sure to specify which language your code is in, and the formula you used to count the amount of points your answer gets.
The answer with the most points, using this system above, wins.
Using this system, the above example code would get 4*15 + 53*1 = 113 initial points.

(*) over-analysation / objectification part: to keep this as objective as possible, "sensible" or "unrelated" means the following: If the piece of code uses words that are not English, it's not valid (for example, const or int are not English words, but foreach or typeof is 2 English words merged, so that is okay). Also, even if you use valid English words such as print or echo, these will have to fit in with the story with their original meaning (so 'putting ink on paper' and 'reflecting sound', not 'showing on a screen'). And with 'fit in', I mean that the subject of the story must be related to it.

I hope this last "disclaimer" meets the requirement of defining objective criteria.

css (114)
I'm new to the golf scene. Not sure if CSS counts as 'code'. But here's a stab at it.
The year is still young...
body {width: 110%}
.pants {overflow: visible}
.newYear {transform: scale(.8)}

If I understand the scoring:

every individual built-in keyword = 4 * 15

every letter/number = 1 * 54

every unrelated line = 0
= initial score: 114


Decompose a number into a sum of repdigits Repdigits are numbers of the form a * (10^n - 1)/9 with  a in [-9,9]\{0} (in other words 111, -3333, 66, numbers which are made by repeating only one digit)

Goal: Write a program or function which takes a single positive integer N and prints N = s_1 + s_2 + ... + s_k. There should be one number per line and the numbers need to be right-aligned. No two summands should have the same number of digits and adding zeros is not allowed. The output should be ordered in ascending or descending order (by number of digits)

Examples:

in:
24192
out:
24192 =
22222 +
 2222 -
  222 -
   33 +
    3

in:
24192
out:
    -7
   -22
  +888
 +1111
+22222
=24192

in:
113
out:
113=    NOT  111+  no empty lines  111+
111+          00+
  2            2                     2

As you can see there can be multiple solutions and some artistic freedom is allowed. Leading and trailing whitespace in each line is allowed

Shortest byte count wins


Fastest Gun in the West You are the roughest, toughest, coolest cowboy west of the Mississippi. However, some weird guy on a wacky nerd website decided that it would be cool to plop you into random unfinished landscapes and fight. No matter, you'll still win. However, to help you win those grueling gunfights you'll write home about, it's helpful to know how many bullets the coward lurking in the landscape has.
How about you help this poor guy out. Given an ASCII landscape, find the gun inside it and tell him how many bullets are loaded into it. This is the gun:
  (X)
(X\ /X)
 (XVX)
  \X/

Each X in the above picture is a potential slot for a bullet. The slot will either contain a space or one of 0,O,o (may not be consistent - the cowboy may have loaded different types of bullets in his gun).
There will always be exactly one gun, matching the above description, in the landscape. However, please note that the spaces around and inside the gun can contain anything.
Input
You will be given a string containing printable ASCII (so not tabs) and newlines to separate lines. You may also take a list of strings, if you wish. Strings will all be padded with spaces, so they will all be the same length. The input will be at least 4 rows high and 7 columns wide.
There will always be exactly one gun in the landscape.
Output
You will output how many bullets (0, O, o) there are in the gun, so your output will always between 0 and 6.
Test Cases
  (0)   ( )
(o\ /o( \ / )
 (oVo) ( V )
  \o/   \ /

0

----------------------------
////////////////////////////
////////////////////////////
/////////////(o)////////////
///////////(0\// )//////////
////////////( Vo)///////////
/////////////\ /////////////
////////////////////////////
----------------------------

3

()()()()()()()()()()()()()()()()\)/)()()()()()()()()()()()()
()()()()()()()()()()()()()()()()(V)()()()()()()()()()()()()(
()()()()()()()(\0/)()()()()()()()()()()()()()()()()()()()()(
()()()()()()()()()()()()()()()()()()()()()()()( )()()()()()(
()()()()()()(o)()()()()()()()(00)()()()()()(( \(/0)()()()()(
()()()()()()()()()()()()()()()()()()()()()()(( V )()()()()()
()()()()()()()()()()()()()()()()()()()()()()()\O/()()()()()(

2

------(0)---
||||(0\|/0)
-----(0V0)--
||||||\0/
-------_------
|||||||-|
------|-|
|||||||-|
------|-|

6

00ooOO(0)/\\/V

  ( )
( \\/ )
 ( V )
 \\ /

00OOoo()()()())))

0

  (\)     (0)
(0\\/0) ( \0/ )
 (0V0)   ( V )
 \\0/     \ /

1 (left gun is invalid because of the `\` in the bullet slot)

-00(0)00\0
-(O\0/o)\
- (OVo)o\0
-o \ /oo/

5

This is code-golf, so shortest answer in bytes wins.


String Concatenation The Challenge

  Given two strings containing only lowercase letters and no spaces, the result should be the shorter string, followed by an underscore, followed by the longer string with the first instance of a character removed for each character it contains that is in the shorter string.

  You can assume the strings will always be different lengths.

Test Cases:

sale
salinewater
Result: sale_inwater (only the first 'a' in salinewater is removed)

jostling
juggle
Result: juggle_ostin (juggle is the shorter string)

juggle
juggler
Result: juggle_r (a 'g' is removed for every 'g' in the shorter string)

Rules

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

Pyth, 13 bytes
++hAlDQ\_.-HG

Try it online.


Play the sound of Pi Yup, you read the title right. play the sound of pi.

More specifically, for every digit of pi in the first 1000, map it to a musical note and output the resulting melody to a file.

Basically, each digit turns to a note on the C Major scale (basically the normal scale). so 1 turns to Middle C, 2 turns to D4, 3 turns to E4, 9 turns to D5 and so on.

Rules

Each note should be exactly 0.5 seconds long.
The melody should contain the first 1000 digits of pi, including the starting 3.
1 to 7 represent Middle C to B4, 8 is C5, 9 is D5 and 0 is E5
All well supported file formats are allowed, as long as they were created before this challenge.
There may be no pauses anywhere in the file, including the start and end.
The instrument played does not matter. It could be a piano, sine wave, anything really, as long as the correct sound is easily hearable.
It must take no input and produce no output except for the file. Reading from other files is disallowed.
Standard loopholes are forbidden.

Example mathematica code:

(*please forgive me for this horrible, horrible mess of code*)
digits = RealDigits[Pi, 10, 1000][[1]] /. {0 -> 10};
weights = {0, 2, 4, 5, 7, 9, 11, 12, 14, 16};
melody = {};
For[i = 1, i < 1001, i++, melody = {melody , Sound[SoundNote[weights[[digits[[i]]]], 0.5]]}]
final = Sound[Flatten[melody]];
Export["C:\\Mathematica Shenanigans\\pi.wav", final];

Example melody showing first 100 digits: http://vocaroo.com/i/s0cfEILwYb8M

For your sanity, A table of pitches for each note and what note does each digit represent:

Digit 1: C: 261.63 Hz
Digit 2: D: 293.66 Hz
Digit 3: E: 329.63 Hz
Digit 4: F: 349.23 Hz
Digit 5: G: 392.00 Hz
Digit 6: A: 440.00 Hz
Digit 7: B: 493.88 Hz
Digit 8: C5: 523.25 Hz
Digit 9: D5: 587.33 Hz
Digit 0: E5: 659.25 Hz

Python 2, 182 bytes

x=p=6637
while~-p:x=p/2*x/p+2*10**999;p-=2
s="MThd\0\0\0\6\0\1\0\1\342\4MTrk\0\0\13\301\0\220"
for i in`x`:s+="JHGECA@><L\260"[~ord(i)%29]+'{<'
open('p.mid','w').write(s+"\0\377/\0")

`x` will produce 31415926...20198L. The trailing L is used to produce the final channel message byte, via the mapping ~ord(i)%29.
Outputs a single track Type 1 Midi file, named p.mid to the current working directory.
0000: 4d 54 68 64 00 00 00 06  MThd....  # Midi header, 6 bytes to follow
0008: 00 01 00 01              ....      # Type 1, 1 track
000c: e2 04                    â.        # (-)30 ticks per beat, 4 beats per second

000e: 4d 54 72 6b 00 00 0b c1  MTrk...Á  # Track header, 3009 bytes to follow
0016: 00 90 40 7b              ..@{      # Wait  0 ticks, play E4 (3), 97% volume
001a: 3c 3c 7b                 <<{       # Wait 60 ticks, play C4 (1), 97% volume
001d: 3c 41 7b                 <A{       # Wait 60 ticks, play F4 (4), 97% volume
0020: 3c 3c 7b                 <<{       # Wait 60 ticks, play C4 (1), 97% volume
0023: 3c 43 7b                 <C{       # Wait 60 ticks, play G4 (5), 97% volume
...
0bcf: 3c b0 7b 3c              <°{<      # Wait 60 ticks, all notes off
0bd3: 00 ff 2f 00              .ÿ/.      # End of track marker


Can you barcode code in a bar? Welcome to the piNapple bar, Melbourne. All of the finest code golfers are here, with their laptops, sampling cocktails and programming increasingly badly.

I feel a special need to reemphasise the last point. Increasingly badly. Alcohol can do funny things to programming logic.

So - a few of the Golfers were attempting some nested quines in increasingly exotic languages. Somebody had hit the forth order in INTERCAL. Then the flow of alcohol stopped. He drunkedly, accidentally deleted the barcode reading algorithms from a completely different computer... that wasn't even connected to any network! (Kids - don't INTERCAL. For the sake of you. For the sake of your family.)

Normally, this wouldn't be a big issue. But, some golfer had designed the system years ago, and none of the barcodes were standard. Assuming 1's are lines, and 0's are space, they all start with 101 and finish with 1001. Everything in the middle is 7-bit ASCII encoded.

The barkeep does have a big fancy barcode reader that will return a string of arbitrary length (though less then 300 bits) of 1's and 0's, via STDIN, argument or file depending on your program. And it might come forward, or backwards depending on which way the bottle is being held. Your program must return the string from the middle of the barcode, via STOUT or file.

Unfortunately, he didn't spend as much on his storage, so the program with the shortest source will be chosen, and win free drinks and drunken programming tutorials from the other golfers.

Good luck!


Count to 100 in Danish Print all the numbers from 0-100 in the right order using the Danish way of counting

How they count

Like English, they have dedicated words for 0-20, 30, 40 and 100
Instead of saying twenty-one and twenty-two, they say one and twenty and two and twenty
Starting with fifty they say multiples of 10 as n*20

50 = half third times twenty = half way to the 3rd multiple of 20
60 = three times twenty
70 = half fourth times twenty
80 = four times twenty
90 = half fifth times twenty

So for instance, 55 would be five and half third times twenty.

Expected output

zero
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
one and twenty
two and twenty
three and twenty
four and twenty
five and twenty
six and twenty
seven and twenty
eight and twenty
nine and twenty
thirty
one and thirty
two and thirty
three and thirty
four and thirty
five and thirty
six and thirty
seven and thirty
eight and thirty
nine and thirty
forty
one and forty
two and forty
three and forty
four and forty
five and forty
six and forty
seven and forty
eight and forty
nine and forty
half third times twenty
one and half third times twenty
two and half third times twenty
three and half third times twenty
four and half third times twenty
five and half third times twenty
six and half third times twenty
seven and half third times twenty
eight and half third times twenty
nine and half third times twenty
three times twenty
one and three times twenty
two and three times twenty
three and three times twenty
four and three times twenty
five and three times twenty
six and three times twenty
seven and three times twenty
eight and three times twenty
nine and three times twenty
half fourth times twenty
one and half fourth times twenty
two and half fourth times twenty
three and half fourth times twenty
four and half fourth times twenty
five and half fourth times twenty
six and half fourth times twenty
seven and half fourth times twenty
eight and half fourth times twenty
nine and half fourth times twenty
four times twenty
one and four times twenty
two and four times twenty
three and four times twenty
four and four times twenty
five and four times twenty
six and four times twenty
seven and four times twenty
eight and four times twenty
nine and four times twenty
half fifth times twenty
one and half fifth times twenty
two and half fifth times twenty
three and half fifth times twenty
four and half fifth times twenty
five and half fifth times twenty
six and half fifth times twenty
seven and half fifth times twenty
eight and half fifth times twenty
nine and half fifth times twenty
one hundred

Rules

You may use any separator to separate the numbers
Due to a typo in the original specification, you may use forth instead of fourth.
You may write a function or write to std-out
Standard loopholes apply
This is codegolf; shortest code in bytes win!

JavaScript (ES6), 347 336 326 325 308 bytes

for(a=btoa`...`.split(i=0);i<101;i++)alert(i<13?a[i]:i<20?(a[i]||a[i-10])+"teen":i>99?"one hundred":(i%10?a[i%10]+" and ":"")+(i<30?"twenty":i<40?"thirty":i<50?"forty":(i%20>9?"half "+["third","forth","fifth"][i/20-2|0]:a[i/20|0])+" times twenty"))

Before running, replace the ... with the result of running this code:

atob("zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh")

Or you could just use the uncompressed version:

for(a="zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh".split(i=0);i<101;i++)alert(i<13?a[i]:i<20?(a[i]||a[i-10])+"teen":i>99?"one hundred":(i%10?a[i%10]+" and ":"")+(i<30?"twenty":i<40?"thirty":i<50?"forty":(i%20>9?"half "+["third","forth","fifth"][i/20-2|0]:a[i/20|0])+" times twenty"))

Still probably not optimal. 11 bytes saved in part by @Titus.


Laver table computations and an algorithm that is not known to terminate in ZFC The Laver tables provide examples of programs which have not been shown to terminate in the standard axiomatic system of mathematics ZFC but which do terminate when one assumes very large cardinal axioms.

Introduction

The classical Laver tables An are the unique finite algebras with underlying set {1,...,2n} and an operation * that satisfies the identity x * (y * z)=(x * y) * (x * z) and where x*1=x+1 for x<2n and where 2n*1=1.

More information about the classical Laver tables can be found in the book Braids and Self-Distributivity by Patrick Dehornoy.

Challenge

What is the shortest code (in bytes) that calculates 1*32 in the classical Laver tables and terminates precisely when it finds an n with 1*32<2n? In other words, the program terminates if and only if it finds an n with 1*32<2n but otherwise it runs forever.

Motivation

A rank-into-rank cardinal (also called an I3-cardinal) is an extremely large level of infinity and if one assumes the existence of a rank-into-rank cardinal, then one is able to prove more theorems than if one does not assume the existence of a rank-into-rank cardinal. If there exists a rank-into-rank cardinal, then there is some classical Laver table An where 1*32<2n. However, there is no known proof that 1*32<2n in ZFC. Furthermore, it is known that the least n where 1*32<2n is greater than Ack(9,Ack(8,Ack(8,254)))(which is an extremely large number since the Ackermann function Ack is a fast growing function). Therefore, any such program will last for an extremely long amount of time.

I want to see how short of a program can be written so that we do not know if the program terminates using the standard axiomatic system ZFC but where we do know that the program eventually terminates in a much stronger axiomatic system, namely ZFC+I3. This question was inspired by Scott Aaronson's recent post in which Aaronson and Adam Yedidia have constructed a Turing machine with under 8000 states such that ZFC cannot prove that the Turing machine does not terminate but is known not to terminate when one assumes large cardinal hypotheses.

How the classical Laver tables are computed

When computing Laver tables it is usually convenient to use the fact that in the algebra An, we have 2n * x=x for all x in An.

The following code calculates the classical Laver table An

# table(n,x,y) returns x*y in An
table:=function(n,x,y)
if x=2^n then return y;
elif y=1 then return x+1;
else return table(n,table(n,x,y-1),x+1); fi; end;

For example, the input table(4,1,2) will return 12.

The code for table(n,x,y) is rather inefficient and it can only compute in the Laver table A4 in a reasonable amount of time. Fortunately, there are much faster algorithms for computing the classical Laver tables than the ones given above.


Generalized Quine Generator The Challenge

In this challenge, you specify a source language S and a target language T. Your task is to write the following program P in the language S. If a valid program Q in the language T is given as input to P, it will output a valid program R in the language T which takes no input and outputs Q(R), that is, the program Q applied to the source code of R. In addition, you should present in your answer a nontrivial example program Q (the more interesting, the better, although you score no points for this), the resulting program R, and the output of R. This is code-golf, so the shortest code for P wins.

In other words, this is a challenge about writing a "universal quine constructor" that can create arbitrary types of generalized quines.

Clarifications

Your source and target languages may be identical.
The program P should take one string as input (from STDIN or equivalent), and output one string (to STDOUT or equivalent), as should every output program R.
The input programs Q should also transform a string to another string, but their form is more flexible: they can be string-to-string functions, code snippets that modify a variable with a certain name, snippets that modify the data stack if your target language has one, etc. You can also further restrict the form of the Q's by stating that, for example, they may not contain any comments. However, you must be able to implement any computable string-to-string function as an input program Q, and you must explicitly state how they function and what further constraints you place on them.
The output program R should really be a (generalized) quine, so it must not read any input (user input, files etc.) unless Q does so.
Standard loopholes are disallowed.

An Example

Suppose I choose Python as my source language, and Haskell as my target language, and I further require that the input program should be a one-line definition of a String -> String function named f. If I give the string-reversing program

f x = reverse x

as input to my Python program P, it will output the source code of another Haskell program R. This program prints to STDOUT the source code of R, but reversed. If P is given the identity function

f x = x

as input, the output program R is a quine.

Source = Target = CJam, 19 17 16 bytes

{`"_~"+}`)q\"_~"

This assumes that the input program Q (given on STDIN) is some CJam snippet which expects a string on the top of the stack and leaves another string on top of the stack.

Test it here.

Examples

The identity would just be an empty snippet, so leaving STDIN empty prints

{`"_~"+}_~

Which is the standard quine, with an additional +.
To reverse a string in CJam, you can use W%, so putting that on STDIN, this yields:

{`"_~"+W%}_~

which we can run to obtain

~_}%W+"~_"`{

As a third example, say we use a snippet which intersperses a string with spaces: ' *. Running P with that as input, we get

{`"_~"+' *}_~

which in turn prints

{ ` " _ ~ " + '   * } _ ~

It now also works if Q contains line breaks (although that's never necessary in CJam). Here is a program with a line break, which removes all line breaks from a string (in an unnecessarily convoluted way - split into lines, then join):

N/
""
*

This results in the following R:

{`"_~"+N/
""
*}_~

which in turn prints

{`"_~"+N/""*}_~

Explanation

Let's look at the produced output first:

The standard CJam quine is

{`"_~"}_~

It works as follows:

Push the block {`"_~"}.
Duplicate it with _.
Execute the copy with ~.
Now inside the block, ` turns the first block into its string representation.
"_~" pushes the two characters of the source that are not part of the block (and hence missing from the string representation).
The two strings are printed back to back at the end of the program.

In the basic quine the ` is unnecessary, because if you just leave the block as it is, it's printed all the same at the end of the program.

The output of my program P is a modified version of this snippet. First, I've added a + to the block, which concatenates the two strings into one string containing the entire source. Note that this will be true no matter what I do inside the block, because that will all get added to the string representation obtained with `. Now I can simply put the program/snippet Q inside the block after the +, so that it can modify the source string before it is printed. Again, since Q goes inside the block, it will be part of said source string.

In summary, P prints

{`"_~"+Q}_~

Now, for how I go about constructing this output in P:

{`"_~"+}         "Push the block without Q.";
        `        "Turn it into a string. This is shorter than writing a string right away,
                  because I'd have to escape the quotes, and I'd need two quotes instead of
                  one backtick.";
         )       "Pop off the last character (the brace) and push it on the stack.";
          q      "Read input Q.";
           \     "Swap Q with the brace.";
            "_~" "Push the final two characters.";

The four strings are printed automatically (back-to-back) at the end of the program.


Determine the type of an input The challenge is simple: Determine the type of an input, and output an identifier telling what type it is.

"UI", Unsigned integer: 0, 1,34, 111111111111111111111111111111111111111111
"SI", Signed integer: +0, +1, +42, -1, -3, -111111111111111111111111111111111111111111
"UD", Unsigned decimal: 0.0, 1.23, 1234.1234
"SD", Signed decimal: -0.0, +0.0, -1.235
"LE", Letter: a-z and A-Z
"SY", Symbol: ASCII code points: [32-47, 58-64, 91-96, 123-126] (i.e. all characters except numbers and letters)
"ST", String: Two or more character that can't be parsed as any of the above number formats

Rules:

The input will be 1-99 characters long
The input will only contain printable ASCII characters, code points: 32-126.
The output should be the two identifier letters as defined above (UI, SI ...)
Standard I/O rules apply

Examples:

UI:
0
01
34
12938219383278319086135768712319838871631827319218923

SI:
-0
+01
+1
-123
+123

UD:
0.0
3.1415
2.718281828459045235360287471352662497757

SD:
+0.0
-3.1415
+2.718281828459045235360287471352662497757

LE:
a
k
L
Z

SY:
@
"
+
-

ST:
Hello, World!
f2!"
+23df
1234A
'"!
.012
1.
UI
+-1
5+3


Approximated (unsorted) square from a set of values So a colleaque came with this problem lately and I want to challange you to solve the problem in the code-golf style, shortest solution in any language wins.

The Problem:

Given is a random set of values, where the values themselfs are
not the concern, but the amount (which is random as well)of values.

To keep the posts readable, let's limit the amount of values to 200, but the program must be able to handly any amount of values, which the language supports.

Input:
No Input needet, due the programm should set an random amount of values (limited to 200).

Output:
Can be text or graphic(px)
I recommend to use single digits as values if you use text based output, to keep the output clear.

Example:

{1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7}   -- Amount : 16

Now you should sort these values in a approcimated square matrix like:

1 2 3 4
5 6 7 8
9 1 2 3
4 5 6 7
(4 x 4)

Pretty simple so far, if not boring.

But now the challange:

The number of fields in the matrix must be equivalent to the amount of values given.
No empty fields or ignored values are allowed.

As an example, with 12 values, an square matrix is not possible, so you have to find the next aproximitation to it, which is 3x4 or 4x3 but NOT 4x4.

For any prime, the matrix would be 1 x prime

Examples:

For 12 Values:

1 2 3 4
5 6 7 8
9 1 2 3
X X X X   <- NOT ALLOWED, it makes the matrix square, but inserts non existing values.

or

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

For 35 Values:

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

Mathematica, 91 bytes

n=RandomInteger@199+1
TableForm@Partition[Range@9~RandomChoice~n,Divisors@n~Nearest~Sqrt@n]

I hope I got this right:

Generate a random length between 1 and 200 (inclusive).
Generate a list of that length with numbers from 1 to 9 (inclusive).
Find one of the two divisors closest to the square root, with Divisors@n~Nearest~Sqrt@n.
Break the list into rows of that length.
Display the grid with TableForm.

Example run:


Number of ways to sum [1..n] with [n+1..2n] such that each sum is prime Let \$n > 0\$. Let \$X = 1, 2,...,n\$ and \$Y = n+1, n+2, ..., 2n\$. Define \$a(n)\$ as the number of permutations \$p\$ of \$Y\$ such that every element of \$X + p(Y)\$ is prime. For example:
n = 2
X = [1,2]
Y = [3,4]
p_0(Y) = [3,4] => X + p0(Y) = [4,6] => No
p_1(Y) = [4,3] => X + p1(Y) = [5,5] => Yes
a(2) = 1

In as few bytes as possible, write a program or function which produces this sequence (A070897), either as an infinite list on STDOUT, or in your interpreter of choice.
The output should start at \$n=1\$, and each entry should be on a newline and undecorated, i.e.:
1
1
1
1
2
...

Examples
\$a(1)=1\$ because each list [1], [2] has only 1 element
\$a(5)=2\$ because there are two permutations: [(1,10),(2,9),(3,8),(4,7),(5,6)] and [(1,6),(2,9),(3,10),(4,7),(5,8)]
Rules
No built-in primality tests. No lookup table ;). No standard loopholes.

CJam, 38 35 32 bytes

0{)_e!{ee{1b1$+)_m!)\)%},!},,p}h

This is an infinite list version. If you run it using the Java compiler, you will keep on getting result for increasing n on each line until the program crashes (if it does. Did not test).

For sanity, run the finite version using this link. You can change the number in the input to see a longer list.

How it works:

0{                            }h  e# This acts as an infinite do-while loop here
  )_                              e# Starting from 0, increment the number and copy it
                                  e# Lets call this number at each iteration as N
    e!                            e# Get all possible permutations of the array 0..N-1
      {                   },      e# Filter the list of permutations based on this code block
       ee                         e# Convert the permutation array into an [index value]
                                  e# pair array. For ex. [5 2]ee gives [[0 5] [1 2]]
         {             },         e# Pass each index value pair through this filter
          1b1$+)                  e# Sum the index and value and add current N + 1 to it
                                  e# At this point, we have something equivalent to
                                  e# pairwise addition of [1 .. n] and [n .. 2n - 1]
                _m!)\)%           e# Now we do ((N - 1)! + 1)%N to see if N is prime
                                  e# This is Wilson's theorem and will give 0 for primes
                         !        e# Now we have a filtered index-value pairs which all
                                  e# correspond to non-prime numbers. If the list is empty,
                                  e# Then all numbers are prime. Thus we do a ! on empty list
                                  e# to get truthy.
                            ,p    e# Take the total permutations where X + pN(Y) are all
                                  e# primes and print the number to STDOUT immediately
                                  e# We are left with the initial incremented N on stack
                                  e# which is always non-zero, so the loop continues
                                  e# infinitely

UPDATE: 2 bytes saved, thanks to Martin!


Output the Hebrew alphabet Your task is to print this exact text:

אבגדהוזחטיכךלמםנןסעפףצץקרשת

(You are allowed to print a trailing newline)

SHA256 hash of the UTF-8 encoding of the text:

0ab6f1e0bf216a0db52a4a5a247f95cba6f51496de7a24dfd01f3985dfcf6085

Base64 encoding:

15DXkdeS15PXlNeV15bXl9eY15nXm9ea15zXnted16DXn9eh16LXpNej16bXpden16jXqdeq

Rules

You can't use a builtin outputting this text.
Standard loopholes are disallowed.
This is code-golf, so the shortest answer wins.

Good luck!

MATLAB, 52 51 bytes

[cumsum([1488 'CCCCCCCCCDADDAEADCDAEADCCC'-66]) '']

Example use:

>> [cumsum([1488 'CCCCCCCCCDADDAEADCDAEADCCC'-66]) '']
ans =
אבגדהוזחטיכךלמםנןסעפףצץקרשת

Explanation

'CCCCCCCCCDADDAEADCDAEADCCC'-66 produces the array [1 1 ... -1 2 1 1 1], which contains the consecutive differences between the codepoints of the desired characters.

[1488 ...] prepends 1488, so the array is now [1488 1 1 ... -1 2 1 1 1].

cumsum(...) computes the cumulative sum: [1488 1489 ... 1514].

[... ''] concatenates with the empty string. This has the effect of converting to char (and is one byte shorter than char(...))


Reversencode the given string Given a string, if it is even, break the string into 2 even parts, then reverse the parts to get the "reversencoded" string.
Example:
onomatopoeia -> tamonoaieopo
If the string is not of even length, then do not change the position of the middle character, and reverse the letters before and after the middle character.
Example:
pizza -> ipzaz
discord -> sidcdro
Limitations:
The input will not contain any other characters other than AlphaNumeric characters. i.e. No newlines/whitespaces.
General contest, shortest code in each language will be winning.
Good luck!
btw: i made up the word reversencoded, i'm fairly sure such a form of "encryption" doesnt exist

Jelly, 6 bytes
ṚŒHZUZ

Try it online!
Explanation
Consider the string ABCDEFGHI:
ṚŒHZUZ
Ṛ      reverse -> IHGFEDCBA
 ŒH    split into halves -> IHGFE
                            DCBA
   Z   transpose -> ID
                    HC
                    GB
                    FA
                    E
    U  reverse each row -> DI
                           CH
                           BG
                           AF
                           E
     Z transpose -> DCBAE
                    IHGF
       implicitly concatenate -> DCBAEIHGF

I never thought the time would come when I'd outgolf Jonathan Allan in Jelly…


Simple Task Solved Thrice You should write 3 programs and/or functions in one language.

All of these programs should solve the same task but they all should give different (but valid) outputs. (I.e. for every pair of programs their should be some input which generates different (but valid) sets of output numbers.)

The task

You are given an integer n, greater than 1
You should return or output n distinct positive integers, and none of them should be divisible by n.
The order of the numbers doesn't matter and a permutation of numbers doesn't count as different outputs.

A valid triplet of programs with some input => output pairs:

program A:
    2 => 5 9
    4 => 5 6 9 10
    5 => 2 4 8 7 1

program B:
    2 => 1 11
    4 => 6 9 1 2
    5 => 4 44 444 4444 44444

program C (differs only in one number from program B):
    2 => 1 13
    4 => 6 9 1 2
    5 => 4 44 444 4444 44444

Scoring

Your score is the sum of the lengths of the 3 programs or functions.
Lower score is better.
If your programs/functions share code, the shared code should be counted into the length of every program that uses the code.

J, 16 bytes

Function 1, 5 bytes

p:^i.

Function 2, 6 bytes

+p:^i.

Function 3, 5 bytes

>:^i.

How it works

Function 1

p:^i.     Right argument: y

   i.     Compute (0 ... y-1).
p:        Compute P, the prime at index y (zero-indexed).
  ^       Return all powers P^e, where e belongs to (0 ... y-1).

Since P is prime and P > y, y cannot divide Pe.

Function 2

+p:^i.    Right argument: y

 p:^i.    As before.
+         Add y to all results.

If y divided Pe + y, it would also divide Pe + y - y = Pe.

Function 3

>:^i.     Right argument: y

   i.     Compute (0 ... y-1).
>:        Compute y+1.
  ^       Return all powers (y+1)^e, where e belongs to (0 ... y-1).

If y divided (y+1)e some prime factor Q of y would have to divide (y+1)e.

But then, Q would divide both y and y+1 and, therefore, y + 1 - y = 1.


Javascript tips: 2 to the power of x multiplied by n I'm new to ES6 and code-golfing. Here's the original function:

function puzzle(n, x) {
  return n * Math.pow(2, x);
}

And here's what I have so far:

let puzzle=(n,x)=>n*2<<(x-1)

But the solution requires lesser characters. I went through the 'Code Golfing with ES6' thread, but couldn't find a better way.
Any help/links would be appreciated.

17 bytes:

puzzle=n=>x=>n<<x

This uses the fact that 2 * 2^n = 2^(n + 1). Also, by our rules, using currying instead of taking multiple arguments the usual way is allowed. Also, I don't think the let is needed.


Escape control characters in a C string C/C++ use double quotes "" for making string literals. If I want the double-quote itself, or certain other characters, to appear in the string, I have to escape them, like so:

char *s2 = "This is not \"good\".\nThis is awesome!\n";

Here, I used \" to represent a double-quote, and \n to represent the newline character. So, if my program prints the string, I see

This is not "good".
This is awesome!

However, if I examine the string in a debugger (Visual Studio or gdb), it shows me the escaped form - the one that would appear in the source code. This is good because it allows to unambiguously identify whether the string contained that \ backslash character verbatim or as part of an escape-sequence.

The goal of this challenge is to do the same job the debuggers do, but better - the escaped string must contain as few escaping characters as possible! The input to your program (or subroutine) is a string of arbitrary 8-bit bytes, and the output must be suitable for putting into the following boilerplate C code:

#include <stdio.h>
int main() {char str[] =
"### the escaped string goes here ###";
puts(""); // put a breakpoint here to examine the string
puts(str); return 0;}

For example:

Input (hexdump, 3-byte string): 64 0a 06

Output: d\n\6

Here, \006 or \x6 have the same meaning as \6, but longer and are therefore unacceptable. Likewise, \012 and \xa have the same meaning as \n, but only \n is an acceptable encoding for the byte with the value 10.

Another example:

Input (hexdump, 5-byte string): 61 0e 38 02 37

Output: a\168\0027

Here, code 0x0e is escaped as \16, and parsed successfully by the C compiler because 8 is not a valid octal digit. However, the code 0x02 is escaped as \002, not \2, to avoid confusion with the byte \27.

Output: a\168\2\67 - another possible form

See Wikipedia for the exact definition of escaping in C.

Additional (reasonable) rules for this challenge:

Output must be printable ASCII (no tab characters; no characters with codes above 126)
The input can be in the form of a string or an array of 8-bit elements. If your language doesn't support it, use the closest alternative. In any case, there should be no UTF encoding for input.
No trigraphs, so no need to escape the ? character
No need to handle the null character (code 0) in input - let it be an end-of-string marker, or a regular byte like others - whatever is more convenient
Code golf: shortest code is the best
You are not allowed to vandalize the Wikipedia article to bend the rules :)

P.S. Summary of the Wikipedia article:

Input byte | Output | Note
0x01       | \1     | octal escape
0x02       | \2     | octal escape
0x03       | \3     | octal escape
0x04       | \4     | octal escape
0x05       | \5     | octal escape
0x06       | \6     | octal escape
0x07       | \a     | alarm
0x08       | \b     | backspace
0x09       | \t     | tabulation
0x0a       | \n     | newline
0x0b       | \v     | vertical tabulation
0x0c       | \f     | form feed
0x0d       | \r     | return
0x0e       | \16    | octal escape
0x0f       | \17    | octal escape
...        |        | octal escape
0x1f       | \37    | octal escape
0x22       | \"     | escape with a backslash
0x5c       | \\     | escape with a backslash
0x7f       | \177   | octal escape
0x80       | \200   | octal escape
...        |        | octal escape
0xff       | \377   | octal escape
other      |        | no escape

JavaScript (ES6) 152
First time ever that .reduceRight seems useful. (But probably the good old .map can do better). The point is, I need to see the next character before deciding whether to output a short or long octal escape.
f=s=>[...s].reduceRight((a,c)=>
((x=c.charCodeAt())==34|c==(q='\\')?q+c:x>31&x<127?c:q+('abtnvvr'[x-7]||(a>='0'&a<'8'?512+x:x).toString(8).slice(-3)))+a
)


Volts, Amps, Watts and Ohms: given two, calculate the other two Ohm's law tells us that the current (I) in amps flowing through a resistance (R) in Ohms when a voltage (V) is applied across it is given as follows:

V = I / R

Similarly the power (P) in watts dissipated by that resistance is given by:

P = V * I

By rearrangement and substitution, formulae may be derived for calculating two of these quantities when any of the other two is given.  These formulae are summarised as follows (note this image uses E instead of V for volts):

Given an input of any two of these quantities in a string, output the other two.

Input numbers will be decimals in whatever format is appropriate for your language.  Precision should be to at least 3 decimal places.  (IEEE 754-2008 binary32 floats are sufficient.)
Each input number will be suffixed with a unit.  This will be one of V A W R for Voltage, Amperage, Power and Resistance (or the equivalent lowercase).  Additionally, you may use Ω instead of R.  The units will not have any decimal prefixes (Kilo-, milli-, etc).
The two input quantities will be given in any order in one string, separated by a single space.
Input quantities will always be real numbers greater than 0.
Output will be in the same format as input.
Equation-solving builtins are disallowed.

Example Inputs

1W 1A
12V 120R
10A 10V
8R 1800W
230V 13A
1.1W 2.333V

Corresponding Outputs

1V 1R
0.1A 1.2W
1R 100W
120V 15A
2990W 17.692R
0.471A 4.948R

It should be noted that solutions to this challenge will effectively be self-inverses.  In other words if you apply a solution to input A B and get output C D, then apply a solution to input C D, then the output should be A B again, though possibly out of order and perturbed due to FP rounding.  So test inputs and outputs may be used interchangeably.

Ruby 171 bytes
Input as function argument. Output to stdout with trailing space (can be revised if necessary.)
->s{a,b,c,d=s.split.map{|z|[z[-1],z.to_f]}.sort.flatten
%w{EA9.EAAVAA.WVA GS;.A?#WWV.RRR}.map{|w|m=w[n=(a+c+?!).sum%10].ord;print (b**(m%9-4)*d**(m/9-5))**0.5,w[n+7],' '}}

Explanation
All formulas can be expressed in the form b**x*d**y where b & d are the two input values and x & y are powers. For golfing reasons the expression (b**x*d**y)**0.5 was finally preferred as it means x and y become integers in the range -4 to 4.
The following table shows the required expressions (inputs are assumed sorted alphabetically) and the encoded values for the powers. Where x and y are the doubled powers, they are encoded as (x+4)+(y+4)*9+9 or equivalently (x+4)+(y+5)*9. This puts all encodings in the printable ASCII range. Power operators are omitted from the formulas for brevity.
n is a kind of checksum made from the input unit symbols; it can take the values 0,1,2,4,5,6 (3 is not used.)
n     formula 1 formula 2      formula 1                formula 2
value                      powers x+4 y+4 encoding   powers x+4 y+4 encoding

0      A*R=V    A2*R=W       1 1    6 6   69 E        2 1     8 6   71 G
1    R-1*V=A  R-1*V2=W      -1 1    2 6   65 A       -1 2     2 8   83 S
2 R-.5*W.5=A R.5*W.5=V     -.5 .5   3 5   57 9       .5 .5    5 5   59 ;
3          .         .                       .                         .
4      A*V=W   A-1*V=R       1 1    6 6   69 E       -1 1     2 6   65 A
5    A-1*W=V   A-2*W=R      -1 1    2 6   65 A       -2 1     0 6   63 ?
6    V-1*W=A  V2*W-1=R      -1 1    2 6   65 A        2 -1    8 2   35 #

Ungolfed in test program
f=->s{
  a,b,c,d=s.split.map{|z|[z[-1],z.to_f]}.        #split the input into an array [[symbol1,value1],[symbol2,value2]]
  sort.flatten                                   #sort alphabetically by symbol and flatten to assign the 4 objects to different variables
  n=(a+c+?!).sum%10                              #sum the ascii codes of the symbols (plus that of ! for good value distribution) and take mod 10. gives a number 0..6 (3 is not used)
  %w{EA9.EAAVAA.WVA GS;.A?#WWV.RRR}.             #for each of the outputs, there is a 14 character string. 1st 7 characters encode powers, 2nd 7 characters are output symbol
  map{|w|                                        #iterate through the 2 outputs
    m=w[n].ord                                   #select one character according to value of n and convert to a number encoding the powers to raise the two inputs to
    print (b**(m%9-4)*d**(m/9-5))**0.5,w[n+7],' '#decode the powers, evaluate the expression and output, append the unit symbol and a space
  }
}

f["6W 3A"]
puts
f["12V 120R"]
puts
f["10A 10V"]
puts
f["8R 1800W"]
puts
f["6W 2V"]
puts
f["2A 3R"]
puts

Output
2.0V 0.6666666666666666R
0.1A 1.2W
100.0W 1.0R
15.0A 120.0V
3.0A 0.6666666666666666R
6.0V 12.0W


Read an analog clock You are given the positions of the minute and hour hands of an analog clock as an angle of clockwise rotation from the top (12). So a hand pointing at 9 is at an angle if 270, and a hand pointing exactly in between 12 and 1 is at an angle of 15.

Input will be two integer angles (in any order of your choice) between 0 and 359. Minute hand will be a multiple of 60, hour hand will be a multiple of 5. Output will be the time, given as two integers separated by a colon (and nothing more).

Sample data

(Hour hand first)

195 180 - 6:30
355 300 - 11:50
280 120 - 9:20
0 0 - 12:00
10 120 - 12:20

JavaScript ES6, 22 bytes

a=>b=>(0|a/30)+":"+b/6

Try it online (all browsers work)


Meta Obfuscate a String There are numerous reasons for trying to obfuscate input. These include preventing decompiling, and being a nuiscance.

With this in mind your challenge should your choose to accept it is to write a meta-obfuscator. Your code must in some Language X receive input as a String, and output a program in language X that outputs the input String.

Rules

Standard loopholes disallowed
It should be hard to tell whether the output prints anything (I.E the code should be heavily obfuscated)
Your program should be testable
Cryptographic approaches are permitted, but it should not be obvious.
Try to submit an interesting solution as this is a popularity contest

Winning Criterion

Although it is up to you to decide which question deserves your upvote. Here are the guidelines.

Hardest to reverse engineer output based on the source code (i.e most encrypted/obfuscated)
Effort and quality of answer

tl;dr
Output a program which prints the input, but make it hard to understand what is going on. Although many people have discussed this (especially for javascript) and even python. I have seen no formal repository of such programs in any arbitrary languages.

Java

Just out of curiosity I decided to write a simple block of code that outputs code that does not look obfuscated.
Here is the generator code

package metaobfuscate;

import java.util.Random;
import java.util.Scanner;

/**
 *
 * @author rohan
 */
public class MetaObfuscate {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        String s = (new Scanner(System.in)).nextLine().toLowerCase();
        int i = 0;
        int numChar = s.length();

        String randomlyGenerated;
        String alphabet = " abcdefghijklmnopqrstuvwxyz!?.";
        do {
            Random rand = new Random(i);
            randomlyGenerated = "";
            i++;
            for (int j = 0; j < numChar; j++) {
                randomlyGenerated += alphabet.charAt((int) (rand.nextDouble() * alphabet.length()));
            }
        } while (!s.equals(randomlyGenerated));
        i--;
        System.out.println("import java.util.Random;\n//Simple demonstration of generating random characters");
        System.out.println("public class RandomNessTest {");
        System.out.println("\t//args are the command line arguments");
        System.out.println("\tpublic static void main(String[] args){");
        System.out.println("\tRandom rand = new Random(" + i + ");//replace the seed with whatever seed you want");
        System.out.println("\t//the seed was generated by random keyboard mashing");
        System.out.println("\tString alphabet = \" abcdefghijklmnopqrstuvwxyz!?.\";");
        System.out.println("\tfor(int i = 0;i<" + numChar + ";i++)");
        System.out.println("\t\tSystem.out.print(alphabet.charAt((int)(rand.nextDouble()*alphabet.length())));");
        System.out.println("\t//print out a few random characters");
        System.out.println("\t}\n}");
    }

}

It takes in whatever string you wish to obfuscate and outputs a program that looks reliable as output. It takes exponential runtime with larger strings, but it works great for strings of length 1-5. The outputted program claims to be a tutorial, and is even formatted nicely!

import java.util.Random;
//Simple demonstration of generating random characters
public class RandomNessTest {
    //args are the command line arguments
    public static void main(String[] args){
    Random rand = new Random(2727915);//replace the seed with whatever seed you want
    //the seed was generated by random keyboard mashing
    String alphabet = " abcdefghijklmnopqrstuvwxyz!?.";
    for(int i = 0;i<5;i++)
        System.out.print(alphabet.charAt((int)(rand.nextDouble()*alphabet.length())));
    //print out a few random characters
    }
}


Print "N NE E SE S SW W NW" This seems almost trivial, but since after some effort I was not able to beat the literal solution in J, I thought it might make a decent challenge (though, to be clear, this is not a J-specific challenge).

Title says it all.  You simply need to write a program, or function (taking no arguments) that returns or prints:

N NE E SE S SW W NW

You may use newlines in place of spaces.

A no-argument function returning an array of strings such as

['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW']

is also acceptable.

The letters may be upper or lower case, but may not be mixed.

bash (24 bytes)
using brace expansion
echo N {N,,S}E S {S,,N}W

is the same length as hard coding
echo N NE E SE S SW W NW

however it becomes more interesting when outputing more points of the compass
echo N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW

brace expansion
echo N {{N,,E}N,,{E,,S}S}E S {{S,,W}S,,{W,,N}N}W

otherwise if order could be changed, (17 bytes), the trick is that without quotes the empy string parameter disappears
echo {N,,S}{W,,E}


Busy Brain Beaver reboot Introduction
I found a really interesting puzzle it was called Busy Brain Beaver. But it has been 3 years since the latest activity and there are some things I didn't like about it. So I decided to make a new one.
The Rules
I want this one to be more brainfuck focused:

Your goal is to make a brainfuck program that outputs the biggest number.
It has to output that number in finite time so you can't say +[+]. outputs infinity (it doesn't have to terminate ex: +.[+] is OK)
Your program can only be 500 useful characters(non-brainfuck characters don't count)
You can assume . outputs your number (in decimal notation).
Only the first output counts (so you can't say +[+.] outputs infinity)
You can't ask for input so , is ignored
This takes place in a special brainfuck environment:

There are an infinite amount of cell to the left and to the right.
All cells start at 0
All cells can hold any integer (so - at 0 becomes -1)

Give an approximation (lower bound) for which number your program would output (given an arbitrarily finite time) (if you are using a special notation please say which one or provide a link)
An explanation of your algorithm would be appreciated. (posting the formatted and commented version will be appreciated too)

Not a duplicate
It was marked as a possible duplicate of Largest Number Printable I think this is different because:

This question is brainfuck focused. And in largest number printable brainfuck isn't even allowed. Yes they are both a busy beaver. But if you think these two are duplicates then any two busy beavers are duplicates. The difference between a brainfuck contest and a non-brainfuck contest is really big. And before it got closed people seemed to have a lot of interest in this one.
The goal here is to output a long number not a lot of bytes

Leader Board (top 10)

Gabriel Benamy            2↑↑↑411
Mike Bufardeci            4277772 = 163*(162*162)
fejfo                     60762 = 246*247

22222222... (65536 twos) = 2↑↑↑4
Before I begin, this is not the largest number expressible using 500 bytes of New Brainfuck.  It's simply where I gave up trying to wrap my head around how big the numbers were getting.  This answer only uses 93 bytes and is therefore not the largest number, but it's proof of concept that mind-bogglingly large numbers are possible.
+++[->++[->+>+<<]>>[-<<+>>]+<[->[-<<[->>>+>+<<<<]>>>>[-<<<<+>>>>]<<]>[-<+>]<<]>[-<+>]<<<]>>.

This is a modification of the exponentiation algorithm in Brainfuck.
This number is so large, it's almost impossible to describe in human terms.  It isn't sufficient to say "the number has this many digits" because it has more digits than particles in the universe.  In fact, the number of digits this number contains has more digits than the number of particles in the universe.
Let this number be x, and let f(0) = x.  Recursively define f(n) = floor[log10[f(n-1)]].  The first n which is smaller than 1 googol is over 10,000.
This answer is 93 bytes.
If we removed removed a single leading +, the result would be 65536 = 2222.  Removing another + gives us 4.  This means that if we add another +, we would get a number tower with 2↑↑↑4 twos, which would be 2↑↑↑5.  That answer would be 94 bytes.  If I were to add another 406 plus signs to this, we would get 2↑↑↑411, which is mind-bogglingly big.  Instead, if  I were to add yet another outer loop, I could probably get something close to 2↑↑↑↑380.  For the record, 2↑↑↑↑3 = 2↑↑↑4, and 2↑↑↑↑4 dwarfs 2↑↑↑4 much the same way that 2↑↑↑4 dwarfs 65536.  In fact, it may just be possible to actually get close to Graham's Number using 500 bytes of brainfuck.


Area of diagonal-folded regular polygon I have a piece of paper whose shape is a regular n-gon with side length 1. Then I fold it through some of its diagonals. What is the area of the shape formed by the (former) edges of the regular polygon?

Illustration

Suppose n = 8, i.e. an octagon-shaped paper. Let's name the vertices from A to H (left picture). Then I fold the paper along the two diagonals BE and FH (right picture). Mathematically, folding BE means to reflect the vertices C and D with respect to the line BE to obtain C' and D'. Your task is to calculate the area of the shaded octagon on the right picture.

Input

The number of sides n and a list representation of the folds l. Each element of l represents either a fold or an intact side of the polygon. If it is a fold, its value is the number of sides moved by the fold (e.g. 3 for the BE fold above, 2 for FH). Otherwise, the value is 1 (e.g. for the sides AB, EF, AH).

For the example above, the input will be 8, [1, 3, 1, 2, 1] if we count from the vertex A, counter-clockwise. If we count clockwise from E instead, the input will be 8, [3, 1, 1, 2, 1]; the expected answer is the same.

Note that sum(l) == n. Also, l == [1] * n (1 repeated n times) case is just the regular polygon untouched, which is a valid input.

The resulting polygon is guaranteed to be simple (it does not intersect or touch itself). For n=3 or n=4, this means that the only valid input is the polygon folded zero times. For n=6, l=[1, 2, 2, 1] or l=[1, 2, 1, 2] is invalid because the two folds will cause two folded vertices to meet at the center of the hexagon.

Output

The area of the n-sided polygon created by the given folds. The result must be within 1e-6 absolute/relative error from the expected result.

Scoring & winning criterion

Standard code-golf rules apply. Shortest code in bytes wins.

Test cases

n l => answer
---------------
4 [1, 1, 1, 1]    => 1.000000
5 [1, 1, 1, 1, 1] => 1.720477
5 [2, 1, 1, 1]    => 0.769421
6 [1, 2, 1, 1, 1] => 1.732051
7 [1, 2, 1, 2, 1] => 2.070249
8 [1, 3, 1, 2, 1] => 1.707107

The picture below shows the first five test cases.

A reference implementation in Python.

Wolfram Language (Mathematica), 37 36 bytes

Tr[Csc[i=Pi/#2]^2Sin[2i#]-Cot@i#]/4&

Try it online!

Takes input in the order l, n.

Uses the same approach as in the reference and many other implementations.

Mathematica's trigonometric and arithmetic functions will automatically vectorize, and Tr returns the sum of the elements of a one-dimensional list.

\$\csc\$ and \$\cot\$ are relatively uncommon; \$\csc x=\frac1{\sin x}\$, and \$\cot x=\frac1{\tan x}\$.


Too Fast, Too Fourier: FFT Code Golf Implement the Fast Fourier Transform in the fewest possible characters.
Rules:

Shortest solution wins

It can be assumed that the input is a 1D array whose length is a power of two.

You may use the algorithm of your choice, but the solution must actually be a Fast Fourier Transform, not just a naive Discrete Fourier Transform (that is, it must have asymptotic computation cost of \$O(N \log N)\$)

the code should implement the standard forward Fast Fourier Transform, the form of which can be seen in equation (3) of this Wolfram article,

$$F_n = \sum_{k=0}^{N-1}f_ke^{-2\pi ink/N}$$

Using an FFT function from a pre-existing standard library or statistics package is not allowed.  The challenge here is to succinctly implement the FFT algorithm itself.

Mathematica, 95 bytes

Another implementation of the Cooley–Tukey FFT with help from @chyaong.

{n=Length@#}~With~If[n>1,Join[+##,#-#2]&[#0@#[[;;;;2]],#0@#[[2;;;;2]]I^Array[-4#/n&,n/2,0]],#]&

Ungolfed

FFT[x_] := With[{N = Length[x]},
  If[N > 1,
    With[{a = FFT[ x[[1 ;; N ;; 2]] ],
          b = FFT[ x[[2 ;; N ;; 2]] ] * Table[E^(-2*I*Pi*k/N), {k, 0, N/2 - 1}]},
      Join[a + b, a - b]],
    x]]


Is the Matrix Positive-Definite? Introduction
Today we're gonna take care of the bane of first-year linear algebra students: matrix definiteness! Apparently this doesn't yet have a challenge so here we go:
Input

A \$n\times n\$ symmetric Matrix \$A\$ in any convenient format (you may also of course only take the upper or the lower part of the matrix)
Optionally: the size of the matrix \$n\$

What to do?
The challenge is simple: Given a real-valued matrix \$n\times n\$ Matrix decide whether it is positive definite by outputting a truthy value if so and a falsey value if not.
You may assume your built-ins to actually work precisely and thus don't have to account for numerical issues which could lead to the wrong behaviour if the strategy / code "provably" should yield the correct result.
Who wins?
This is code-golf, so the shortest code in bytes (per-language) wins!

What is a positive-definite Matrix anyways?
There are apparently 6 equivalent formulations of when a symmetric matrix is positive-definite. I shall reproduce the three easier ones and reference you to Wikipedia for the more complex ones.

If \$\forall v\in\mathbb R^n\setminus \{0\}: v^T Av>0\$ then \$A\$ is positive-definite. This can be re-formulated as: If for every non-zero vector \$v\$ the (standard) dot product of \$v\$ and \$Av\$ is positive then \$A\$ is positive-definite.
Let \$\lambda_i\quad i\in\{1,\ldots,n\}\$ be the eigenvalues of \$A\$, if now \$\forall i\in\{1,\ldots,n\}:\lambda_i>0\$ (that is all eigenvalues are positive) then \$A\$ is positive-definite. If you don't know what eigenvalues are I suggest you use your favourite search engine to find out, because the explanation (and the needed computation strategies) is too long to be contained in this post.
If the Cholesky-Decomposition of \$A\$ exists, i.e. there exists a lower-triangular matrix \$L\$ such that \$LL^T=A\$ then \$A\$ is positive-definite. Note that this is equivalent to early-returning "false" if at any point the computation of the root during the algorithm fails due to a negative argument.

Examples
For truthy output
\begin{pmatrix}1&0&0\\0&1&0\\0&0&1\end{pmatrix}
\begin{pmatrix}1&0&0&0\\0&2&0&0\\0&0&3&0\\0&0&0&4\end{pmatrix}
\begin{pmatrix}5&2&-1\\2&1&-1\\-1&-1&3\end{pmatrix}
\begin{pmatrix}1&-2&2\\-2&5&0\\2&0&30\end{pmatrix}
\begin{pmatrix}7.15&2.45\\2.45&9.37\end{pmatrix}
For falsey output
(at least one eigenvalue is 0 / positive semi-definite)
\begin{pmatrix}3&-2&2\\-2&4&0\\2&0&2\end{pmatrix}
(eigenvalues have different signs / indefinite)
\begin{pmatrix}1&0&0\\0&-1&0\\0&0&1\end{pmatrix}
(all eigenvalues smaller than 0 / negative definite)
\begin{pmatrix}-1&0&0\\0&-1&0\\0&0&-1\end{pmatrix}
(all eigenvalues smaller than 0 / negative definite)
\begin{pmatrix}-2&3&0\\3&-5&0\\0&0&-1\end{pmatrix}
(all eigenvalues smaller than 0 / negative definite)
\begin{pmatrix}-7.15&-2.45\\-2.45&-9.37\end{pmatrix}
(three positive, one negative eigenvalue / indefinite)
\begin{pmatrix}7.15&2.45&1.23&3.5\\2.45&9.37&2.71&3.14\\1.23&2.71&0&6.2\\3.5&3.14&6.2&0.56\end{pmatrix}

C, 108 bytes

-1 byte thanks to Logern
-3 bytes thanks to ceilingcat

f(M,n,i)double**M;{for(i=n*n;i--;)M[i/n][i%n]-=M[n][i%n]*M[i/n][n]/M[n][n];return M[n][n]>0&(!n||f(M,n-1));}

Try it online!

Performs Gaussian elimination and checks whether all diagonal elements are positive (Sylvester's criterion). Argument n is the size of the matrix minus one.


Shortest python3 code for: Find the difference between a number and a power of two not exceeding a given number So, this is a task from one very popular educational site in Russia:
https://acmp.ru/index.asp?main=task&id_task=786&ins=1
Mathematically, you need to find the power of two not exceeding the given number, read from the standard input stream, and output their difference in the standard output stream.
My python3 solution takes 41 characters, but the leader’s solution is only 40 characters.
Who can shorten the code?
Newlines, spaces and tabs are not included while counting code length.
x = int(input())
print(x - 2 ** (len(bin(x)) - 3))

Python 3, 39 bytes

print(int('0'+bin(int(input()))[3:],2))

Try it online!
Subtracting the largest power of two less than a number is the same as removing the first 1 from its binary representation.
Unfortunately python rather mysteriously errors on trying to convert the empty binary string to an int so we need '0'+ if we want it to work on zero or one.  If we relax the requirements to only require two or more then we can remove 4 bytes.
Python 3, 35 bytes

print(int(bin(int(input()))[3:],2))

Try it online!


Make a "Ceeeeeeee" program Once I wrote a JavaScript program that would take as input a string and a character and would remove all characters except for the first one and the character given as input, one by one.

For example, computing this with inputs codegolf.stackexchange.com and e for the character yields:

codegolf.stackexchange.com
cdegolf.stackexchange.com
cegolf.stackexchange.com
ceolf.stackexchange.com
celf.stackexchange.com
cef.stackexchange.com
ce.stackexchange.com
cestackexchange.com
cetackexchange.com
ceackexchange.com
ceckexchange.com
cekexchange.com
ceexchange.com
ceechange.com
ceehange.com
ceeange.com
ceenge.com
ceege.com
ceee.com
ceeecom
ceeeom
ceeem
ceee

It keeps the first character and all es. All other characters are removed one by one.

Your task is to write a program (or function) that takes two inputs and outputs (or returns) a string that accomplishes this effect.

Specifications

You can assume that the string will not contain any newlines.
The second input will always be one character.
If the answer is in the form of a function, you may return an array of strings containing each line in the output.
The output can contain a trailing newline.

Test Cases

Test Cases, s:

Test Cases
Tst Cases
Ts Cases
TsCases
Tsases
Tsses
Tsss

Make a "Ceeeeeeee" program, e:

Make a "Ceeeeeeee" program
Mke a "Ceeeeeeee" program
Me a "Ceeeeeeee" program
Mea "Ceeeeeeee" program
Me "Ceeeeeeee" program
Me"Ceeeeeeee" program
MeCeeeeeeee" program
Meeeeeeeee" program
Meeeeeeeee program
Meeeeeeeeeprogram
Meeeeeeeeerogram
Meeeeeeeeeogram
Meeeeeeeeegram
Meeeeeeeeeram
Meeeeeeeeeam
Meeeeeeeeem
Meeeeeeeee

Hello World!, !:

Hello World!
Hllo World!
Hlo World!
Ho World!
H World!
HWorld!
Horld!
Hrld!
Hld!
Hd!
H!

Hello World!, z:

Hello World!
Hllo World!
Hlo World!
Ho World!
H World!
HWorld!
Horld!
Hrld!
Hld!
Hd!
H!
H

alphabet, a:

alphabet
aphabet
ahabet
aabet
aaet
aat
aa

upperCASE, e:

upperCASE
uperCASE
uerCASE
ueCASE
ueASE
ueSE
ueE
ue

This is code-golf, so the shortest code (in bytes) wins.

Vim, 27, 26, 25 bytes
DJqqYp:s/.\zs[^<C-r>-]<CR>@qq@qD

Try it online!
Input comes in this format:
e
codegolf.stackexchange.com

My naive first approach is three bytes longer:
i:s/.\zs[^<Right>]<Esc>"addqqYp@a@qq@qdd

I'm also happy with this answer because it starts with my name.
DJqq:t$|s/.\zs[^<C-r>"]<CR>@qq@qD
DJMcMayhem

See the similarity? Eh?
Less successful approaches:
i:s/.\zs[^<Right>]<Esc>"addqqYp@a@qq@qdd
i:s/.\zs[^<Right>]<CR>@q<Esc>"adkqqYp@aq@qdd
DJ:s/.\zs[^<C-r>"]<CR>uqqYp@:@qq@qdd
DJqq:t.|$s/.\zs[^<C-r>"]<CR>@qq@qdd

Explanation:
D                                   " Delete everything on this first line
 J                                  " Remove this empty line
  qq                                " Start recording into register 'q'
    Y                               " Yank this line
     p                              " And paste it
      :s/                           " Run a substitute command on the last line in the buffer. Remove:
         .                          "   Any character
          \zs                       "   Move the selection forward (so we don't delete the first one)
             [^<C-r>-]              "   Followed by anything *except* for the character we deleted
                      <CR>          " Run the command
                          @q        " Call register 'q'
                            q       " Stop recording
                             @q     " Run the recursive macro
                               D    " Delete our extra line


Generate triangular signal Task:

Given sample index, x, calculate sample value f(x) of triangular wave, with period of 4 samples and amplitude 1. Offset can be negative and sample value could be either {0, 1, -1}.

Test cases:

   -5 -> -1
   -4 -> 0
   -3 -> 1
   -2 -> 0
   -1 -> -1
    0 -> 0
    1 -> 1
    2 -> 0
    3 -> -1
    4 -> 0
    5 -> 1

Personally I know two approaches in C - the first is using lookup table, the second is using conditional instructions. For brownie points, could you impress me with a pure "math" approach? (I mean a pure functional approach, e.g. not using conditional instructions or using memory for LUT.) But this is not an restriction. If you can't, or your language does not support it - just post any solution

Mathematica, 8 bytes

Im[I^#]&

Explanation

Im[I^#]&
   I^#    (* Raise the imaginary unit to the input power *)
Im[   ]   (* Take the imaginary part *)


Convert text to key presses I am a robot. I bought this keyboard because of its easy rectangular layout:

~`   !1   @2   #3   $4   %5   ^6   &7   *8   (9   )0   _-   +=
tab  Qq   Ww   Ee   Rr   Tt   Yy   Uu   Ii   Oo   Pp   {[   }]    \|
     Aa   Ss   Dd   Ff   Gg   Hh   Jj   Kk   Ll   :;   "'   [-enter-]
          Zz   Xx   Cc   Vv   Bb   Nn   Mm   <,   >.   ?/
                         [========= space =========]

To print human text, I need to convert it to commands that my manipulators can interpret. My left manipulator hovers over the Shift key. My right manipulator, at the beginning, hovers over the ~ key. The commands that my manipulators understand are:

S      : press the shift key
s      : release the shift key
L      : move the right manipulator left by 1
R      : move the right manipulator right by 1
U      : move the right manipulator up by 1
D      : move the right manipulator down by 1
P      : press the key under the right manipulator
p      : release the key by the right manipulator

Write code to convert any ASCII message to a list of commands. The input can contain any number of the 95 printable ASCII characters; possibly also TAB and newline characters. The output should be the list of the commands to the manipulators.

So, for example, to type Hello World!, the commands are

SRRRRRRDDPp
sLLLUPp
RRRRRRDPp
Pp
UPp
LLLLDDDPp
SLLLUUUPp
sRRRRRRRPp
LLLLLPp
RRRRRDPp
LLLLLLPp
SLLUUPp

I reset the manipulators to initial state before printing each message.

There are some mechanical hazards that should be avoided by proper programming:

No moving (LRUD) allowed when printing (P) is engaged
No jamming of manipulators: when a manipulator is engaged (S or P), the next command for this manipulator should be disengaging (s or p), and vice-versa
No unnecessary shifting: between each two shift (s, S) commands, there should be a P command

So, to print ~~, commands SPpPp are valid, while SPpsSPp are not
No moving out of bounds: no movement command should try to move the right manipulator more than 13 spaces to the right or 4 to the bottom of the initial position (or any spot to the top or left)

Additional notes:

Pressing a disabled key (command sequence like DDPp) results in no keys pressed and is allowed.
Pressing Shift+Tab has no effect, but Shift+Space and Shift+Enter have the same effect as without Shift.
Pressing on any spot on the space bar and the Enter key has the same effect.
Whitespace keys in output have no meaning, but can be used to format it in a beautiful way.

Python 2, 338 337 335 331 325 bytes

x=y=s=0
for c in input():p='`1234567890-=`	qwertyuiop[]|`asdfghjkl;\'\n```zxcvbnm,./``````` ~!@#$%^&*()_+~~QWERTYUIOP{}\\~ASDFGHJKL:"\n~~~ZXCVBNM<>?~~~~~~~ '.find(c);S=[p>61,s][c in' \n'];p%=62;Y=p/14;X=[max(x,12),min(max(x,5),10),p%14]['\n '.find(c)];print'sS'[S]*(s^S)+'LR'[X>x]*abs(X-x)+'UD'[Y>y]*abs(Y-y)+'Pp';x,y,s=X,Y,S

Try it online!

Moves directly from each character to the next.

Explanation:

S=[c in K,s][c in' \n'], checks if the next character should be Upper- or lowercase. If c is a space or newline, the case remains the same.
X=[max(x,12),min(max(x,5),10),p%15]['\n '.find(c)]. If c is a space or newline, the closest x-coordinate to the current is chosen(as the keys span multiple columns)
print'sS'[S]*(s!=S)+'LR'[X>x]*abs(X-x)+'UD'[Y>y]*abs(Y-y)+'Pp', prints the case switch, the number of x-coordinate moves, the number of y-coordinate moves, and finally Pp, for each character

Shorter version, if the shortest path is not required:

Python 2, 294 293 291 287 281 bytes

x=y=s=0
for c in input():p='`1234567890-=`	qwertyuiop[]|`asdfghjkl;\'\n```zxcvbnm,./``````` ~!@#$%^&*()_+~~QWERTYUIOP{}\\~ASDFGHJKL:"\n~~~ZXCVBNM<>?~~~~~~~ '.find(c);S=[p>61,s][c in' \n'];p%=62;X,Y=p%14,p/14;print'sS'[S]*(s^S)+'LR'[X>x]*abs(X-x)+'UD'[Y>y]*abs(Y-y)+'Pp';x,y,s=X,Y,S

Try it online!


Find all Belphegor primes A Belphegor number is a number of the form \$(10^{n+3}+666)*10^{n+1}+1\$ (1{n zeroes}666{n zeroes}1) where \$n\$ is an non-negative integer. A Belphegor prime is a Belphegor number that is also prime.

The \$n\$ values of the first few Belphegor primes are 0, 13, 42, 506 (A232448)

Task

Write a program that either:

takes no input and outputs all Belphegor primes.
takes a input \$k\$ and outputs the first \$k\$ Belphegor primes.

A reference python implementation can be found here.

Rules

You may output the \$n\$ value for the Belphegor prime instead of the prime itself
You may use probabilistic primality tests as long as there is no known counter case.

Scoring

This is code-golf so shortest bytes wins.

Inspired by The Most Evil Number - Numberphile

Wolfram Language (Mathematica), 51 bytes

outputs the n value
"...program that does not stop and will eventually output all..."

PrimeQ[10^c*666+1+100^++c]~If~Print[c-2]~Do~{c,∞}

Try it online!

thanks to @DanTheMan for saving 4 bytes
and also to @mypronoun -7 bytes


m3ph1st0s's programming puzzle 2 (C++): "Call hard!" I am back with a brand new puzzle for C/C++ addicts. Following the feedback received on the 1st puzzle, this time I will try to make the requirements crystal clear and to provide a perfectly valid code.
Here is the problem.
Given the following code:
#include <iostream>

char message[6]="hello";

void print_hello_message() {
   std::cout << message;
}

int main() {
   char* q = &message[0];

   // insert your code here
}

You are required to insert two more lines where the comment specifies in order to make the program print "hello" and nothing more, with the following restrictions:

the first line will NOT call any function, including cout

the second line will contain AT MOST 5 letters (and as many other symbols as you want)

the first line may contain new variable declarations but may not initialize them

the symbols # and / will not be used at all.

no logical operators will be used
The shortest code wins!

In thinking about it some more, the problem states "insert two more lines where the comment specifies" not "statements". Taking that into consideration, here is another shorter answer (though it depends on how you define "the first line will NOT call any function, including cout"):

std::
cout<<q;

The first line qualifies which cout will be used, and the second line includes the actual operator that results in calling operator<< for the std::ostream & const char* operands.


LARGEST program to reverse a single line from stdin with no redundant code The biggest program that reads a single line (terminated by your choice from NULL/CR/LF/CRLF) from stdin, reverses it, then prints it to stdout.

No redundant code [code which could safely be deleted] such as

return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

or redundant data that's used to stop code being redundant:

char* data = <kernel source code>;
if (md5sum(data) != <hash>) {
    return 1; //Fail for no good reason because it lets us add 1000000 lines of data
}

Basically, the largest implementation of a string reverse, with no obvious attempt to game the question.

[edit]

I am tempted to say that the code must be finite for unbounded input length, but there have been some clever and interesting O(>1) length solutions.  I instead ask that people avoid posting simple brute-force lookup-list solutions as separate answers (comments are fine!).

C# – Something about 90 KB, but actually, ~90×n for any n

See https://gist.github.com/mormegil-cz/8581459 for the full source code. A short preview version to taste:

var c1 = Console.Read();
if (c1 > 0 && c1 != 13)
{
    var c2 = Console.Read();
    if (c2 > 0 && c2 != 13)
    {
        var c3 = Console.Read();
        if (c3 > 0 && c3 != 13)
        {
            // ...
            Console.Write((char)c3);
        }
        Console.Write((char)c2);
    }
    Console.Write((char)c1);
}
Console.WriteLine();

And because writing the source code seems a bit repetitive, let’s use a simple tool:

void Main()
{
    const int MAX_DEPTH = 1000;
    Console.WriteLine("using System;");
    Console.WriteLine("using System.Text;");
    Console.WriteLine();
    Console.WriteLine("class C");
    Console.WriteLine("{");
    Console.WriteLine("\tstatic void Main()");
    Console.WriteLine("\t{");
    for (int i = 0; i < MAX_DEPTH; ++i)
    {
        var indent = new string('\t', i + 2);
        Console.WriteLine("{0}var c{1} = Console.Read();", indent, i);
        Console.WriteLine("{0}if (c{1} > 0 && c{1} != 13)", indent, i);
        Console.WriteLine("{0}{{", indent);
    }
    var restIndent = new string('\t', MAX_DEPTH + 2);
    Console.WriteLine("{0}var rest = new StringBuilder();", restIndent);
    Console.WriteLine("{0}for (var c = Console.Read(); c > 0 && c != 13; c = Console.Read())", restIndent);
    Console.WriteLine("{0}{{", restIndent);
    Console.WriteLine("{0}\trest.Append((char)c);", restIndent);
    Console.WriteLine("{0}}}", restIndent);
    Console.WriteLine("{0}var restArray = rest.ToString().ToCharArray();", restIndent);
    Console.WriteLine("{0}Array.Reverse(restArray);", restIndent);
    Console.WriteLine("{0}Console.Write(new string(restArray));", restIndent);
    for (int i = MAX_DEPTH - 1; i >= 0; --i)
    {
        var indent = new string('\t', i + 2);
        Console.WriteLine("{0}\tConsole.Write((char)c{1});", indent, i);
        Console.WriteLine("{0}}}", indent);
    }
    Console.WriteLine("\t\tConsole.WriteLine();");
    Console.WriteLine("\t}");
    Console.WriteLine("}");
}

Change MAX_DEPTH to get a larger score (or possibly an internal C# compiler error?).


Is it an Ordered Word? (inspired by this post over on Puzzling. CAUTION: SPOILERS FOR THAT PUZZLE ARE BELOW.)

The standard telephone keypad correlates letters to numbers as follows:

1 ->
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -> WXYZ
0 ->

A given input word is defined to be an Ordered Word if, when translated to keypad presses using the above, the resulting number is either non-decreasing or non-increasing. In other words, the resultant number cannot both increase and decrease.

For example, the word CAT translates to 228, which is non-decreasing, and thus an Ordered Word. However, the word DOG is 364, which both increases and decreases, and thus is not an Ordered Word.

The challenge

Given a word, output whether or not it's Ordered.

Input

A word (not necessarily a dictionary word) consisting of ASCII alphabet ([A-Z] or [a-z]) letters only, in any suitable format.
Your choice if the input is all uppercase or all lowercase, but it must be consistent.
The word will be at least 3 characters in length.

Output

A consistent truthy/falsey value for whether the input word is Ordered (truthy) or not Ordered (falsey).

Rules

Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
If possible, please include a link to an online testing environment so other people can try out your code!
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Examples

Here are some Ordered Words (i.e., truthy), and there are more on the linked Puzzling puzzle.

CAT
TAC
AAA
DEMONS
SKID
LKJONMSRQP
ABCDEFGHIJKLMNOPQRSTUVWXYZ

Here are some non-Ordered Words (i.e., falsey)

DOG
GOD
ROSE
COFFEE
JKLMNOGHI


Is it a Mersenne Prime? A number is a Mersenne Prime if it is both prime and can be written in the form 2n-1, where n is a positive integer.

Your task is to, given any positive integer, determine whether or not it is a Mersenne prime. You may submit either a function which returns a truthy/falsy value, or a full program which performs IO.

Rules:

As this is code-golf, you should aim to do this in the shortest byte count possible. Builtins are allowed.
Standard golfing loopholes apply - you cannot read the Mersenne primes from external files, or hardcode them into your program.
Your program should work for values within your language's standard integer size.

Test Cases

For reference, a list of (known) Mersenne Primes can be found here. Some handy test cases are:

2  -> False
1  -> False
20 -> False
51 -> False
63 -> False

3    -> True
31   -> True
8191 -> True

Merry Christmas, everybody! Have a great holiday, whatever you celebrate :)

05AB1E, 5 bytes

A positive number in the form 2n - 1 in binary only consists of 1's.

Code:

b`¹pP

Explanation:

b`      # Push each digit of the binary representation of the number onto the stack
  ¹p    # Check if the input is prime
    P   # Take the product of all these digits

Uses the CP-1252 encoding. Try it online! or Verify all test cases.


Magic popcount numbers There’s a famous tricky algorithm for counting the number of set bits in a 32-bit unsigned integer:

int popcount(unsigned x) {
   x = (x & 0x55555555) + ((x >> 1) & 0x55555555);
   x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
   x = (x & 0x0F0F0F0F) + ((x >> 4) & 0x0F0F0F0F);
   x = (x & 0x00FF00FF) + ((x >> 8) & 0x00FF00FF);
   x = (x & 0x0000FFFF) + ((x >>16) & 0x0000FFFF);
   return x;
}

I won’t explain it here. But imagine similar code for 512-bit integers! The hexadecimal constants would be huge, and form a pretty pattern. Your task is simply to print this exact output:

0x55555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555
0x33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f
0x00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff
0x0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff
0x00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff
0x0000000000000000ffffffffffffffff0000000000000000ffffffffffffffff0000000000000000ffffffffffffffff0000000000000000ffffffffffffffff
0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000ffffffffffffffffffffffffffffffff
0x0000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

No trailing spaces, please — though a single trailing newline is optional.

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

Python 2, 52 49 46 bytes

The kth number is given by 2**512/(2**2**k + 1). This is for a 512 bit number, so it's trivial to extend the pattern to different widths.

l=2;exec"print'0x%0128x'%(2**512/-~l);l*=l;"*9

3 bytes saved thanks to Dennis.
3 bytes saved thanks to xnor.


Build a digital clock in Conway's Game of Life Your task is to build a Game of Life simulation representing a digital clock, which satisfies the following properties:

The clock displays the hours and minutes in decimal (e.g. 12:00, 3:59, 7:24) with a different state for each of the 1,440 minutes of the day — either the hours will go from 0 to 23 or from 1 to 12 with a PM indicator.
The pattern is periodic, and the state loops around without any outside interaction.
The minutes update at regular intervals — from one change of minute to the next takes the same number of generations.
An anonymous bystander is able to tell at a glance that the display is supposed to be a digital clock. In particular, this entails:

The digits are visible and clearly distinguishable. You must be able to tell with certainty at a glance what time is being displayed.
The digits update in place. Each new number appears in the same place as the previous number, and there is little to no movement of the bounding boxes of the digits. (In particular, a digit does not contain 10 different digits in different places that get uncovered every time the digits change.)
The digits appear next to each other, without an excessive amount of space between them.

Your program will be scored on the following things, in order (with lower criteria acting as tiebreakers for higher criteria):

Bounding box size — the rectangular box with the smallest area that completely contains the given solution wins.
Fastest execution — the fewest generations to advance one minute wins.
Initial live cell count — smaller count wins.
First to post — earlier post wins.

11,520 generations per clock count / 10,016 x 6,796 box / 244,596 pop count

There you go... Was fun.

Well, the design is certainly not optimal. Neither from the bounding box standpoint (those 7-segment digits are huge), nor from the initial population count (there are some useless stuff, and some stuff that could certainly be made simpler), and the execution speed - well... I'm not sure.

But, hey, it's beautiful. Look:

Run it!

Get the design from this gist. Copy the whole file text to the clipboard.

New: here is a version with both AM and PM indicators for the demanding.

Go to the online JavaScript Conway life simulator. Click import, paste the design text. You should see the design. Then, go to settings and set the generation step to 512, or something around those lines, or you'll have to wait forever to see the clock display updating.

Click run, wait a bit and be amazed!

Direct link to in-browser version.

Note that the only algorithm that makes this huge design useable is hashlife. But with this, you can achieve the whole clock wraparound in seconds. With other algorithms, it is impractical to even see the hour changing.

How it works

It uses p30 technology. Just basic things, gliders and lightweight spaceships. Basically, the design goes top-down:

At the very top, there's the clock. It is a 11520 period clock. Note that you need about 10.000 generations to ensure the display is updated appropriately, but the design should still be stable with a clock of smaller period (about 5.000 or so - the clock needs to be multiple of 60).
Then, there is the clock distribution stage. The clock glider is copied in a balanced tree, so at the end, there are 32 gliders arriving at the exact same moment to the counters stage.
The counter stage is made using a RS latch for each state, and for each digit (we're counting in decimal). So there is 10 states for the right digit of the minutes, 6 states for the left digit of the minuts, and 12 states for the hours (both digits of the hours are merged here). For each of these groups, the counter behaves like a shift register.
After the counting stage, there are the lookup tables. They convert the state pulses to display segments ON/OFF actions.
Then, the display itself. The segments are simply made with multiple strings of LWSS. Each segment has it own latch to maintain its state. I could have made a simple logical-OR of the digit states to know wether a segment must be ON or OFF, and get rid of these latches, but there would be glitches for non-changing segments, when the digits are changing (because of signal delays). And there would be long streams of gliders coming from the lookup table to the digit segments. So it wouldn't be as nice-looking. And it needed to be. Yes.

Anyway, there is actually nothing extraordinary in this design. There are no amazing reactions that have been discovered in this process, and no really clever combinations that nobody thought of before. Just bits taken here and there and put together (and I'm not even sure I did it the "right" way - I was actually completely new to this). It required a lot of patience, however. Making all those gliders coming up at the right time in the right position was head-scratching.

Possible optimizations:

Instead of copying and distributing the same root clock to the n counter cells, I could have just put the same clock block n times (once for each counter cell). This would actually be much simpler. But then I wouldn't be able to adjust it as easily by changing the clock at a single point... And I have an electronics background, and in a real circuit, that would be horribly wrong.
Each segment has it own RS latch. This requires the lookup tables to output both R and S pulses. If we had a latch that would just toggle its state from a common input pulse, we could make the lookup tables half as big. There is such a latch for the PM dot, but it is huge, and I'm unable to come up with something more practical.
Make the display smaller. But that wouldn't be as nice-looking. And it needed to be. Yes.