Form a list using prime numbers You have been given N piles of coins. You have decided to divide each of those B1, B2, ..., BN piles among separate groups of people. The amount of people receiving coins has to be a prime number and the amount of money given to each person must be different in each pile.

Input: N, B1, B2, ..., BN (The amount of coins in each individual pile).

Output: NP1, NP2, ..., NPN with NP being the number of people(prime number) receiving the coins. If this is impossible then yield some unachievable result (like 0, -1, None, [], or "impossible") or raise an error.

Example:

3
7 8 9

Output: 7 2 3

Because 7 is the only prime number that can divide 7 evenly, the same for 8 and 2 and 9 and 3. Also, notice that (7 / 7 = 1) ≠ (8 / 2 = 4) ≠ (9 / 3 = 3).

05AB1E, 13 bytes

Ò.»â€˜ʒ÷DÙQ}θ

Try it online!

A port of my Pyth answer.

Ò gets the prime factÒrs of each.
.» folds a dyadic command, â (cârtesiân product) between each two elements in the list from right to left with opposite right/left operands.
€˜ flattens €ach.
ʒ...} filtʒrs those which satisfy the following condition:

÷ pairwise integer division with the input.
D Duplicate (pushes two copies of the item to the stack).
Ù removes duplicate elements, keeping a ÙniqÙe occurrence of each element.
Q checks for eQuality.

θ gets the last element.


Properties of Binary Functions Many important topics in abstract algebra involve a binary function acting on a set. A number of properties of such functions have been defined in the investigation of such topics.
Your challenge will be to determine whether a given binary function on a given domain possesses five of these properties.
Properties
Closure
A binary function is closed if every possible output is in the domain.
Associativity
A binary function is associative if the order in which the function is applied to a series of inputs doesn't affect the result. That is, $ is associative if (a $ b) $ c always equals a $ (b $ c). Note that since the value (a $ b) is used as an input, associative functions must be closed.
Commutativity
A binary function is commutative if swapping the order of the inputs doesn't change the result. In other words, if a $ b always equals b $ a.
Identity
A binary function has an identity element if there exists some element e in the domain such that a $ e = a = e $ a for all a in the domain.
Idempotence
A binary function is idempotent if applying it to two identical inputs gives that number as the output. In other words, if a $ a = a for all a in the domain.
Input
You will be given a function in the form of a matrix, and the domain of the function will be the numbers 0 ... n-1, where n is the side length of the matrix.
The value (a $ b) is encoded in the matrix as the ath row's bth element. If the input matrix is Q, then a $ b = Q[a][b]
For example, the exponentiation function (** in Python) on the domain [0, 1, 2] is encoded as:
[[1, 0, 0]
 [1, 1, 1]
 [1, 2, 4]]

The left and right domains are the same, so the matrix will always be square.
You may use any convenient matrix format as input, such as a list of lists, a single list in row- or column- major order, your language's native matrix object, etc. However, you may not take a function directly as input.
For simplicity, the matrix entries will all be integers. You may assume that they fit in your language's native integer type.
Output
You may indicate which of the above properties hold in any format you choose, including a list of booleans, a string with a different character for each property, etc. However, there must be a distinct, unique output for each of the 24 possible subsets of the properties. This output must be easily human-readable.
Examples
The maximum function on domain n=4:
[[0, 1, 2, 3]
 [1, 1, 2, 3]
 [2, 2, 2, 3]
 [3, 3, 3, 3]]

This function has the properties of closure, associativity, commutativity, identity and idempotence.
The exponentiation function on domain n=3:
[[1, 0, 0]
 [1, 1, 1]
 [1, 2, 4]]

This function has none of the above properties.
The addition function on domain n=3:
[[0, 1, 2]
 [1, 2, 3]
 [2, 3, 4]]

This function has the properties of commutativity and identity.
The K combinator on domain n=3:
[[0, 0, 0]
 [1, 1, 1]
 [2, 2, 2]]

This function has the properties of closure, associativity and idempotence.
The absolute difference function on domain n=3:
[[0, 1, 2]
 [1, 0, 1]
 [2, 1, 0]]

This function has the properties of closure, commutativity and identity.
The average function, rounding towards even, on domain n=3:
[[0, 0, 1]
 [0, 1, 2]
 [1, 2, 2]]

This function has the properties of closure, commutativity, identity and idempotence.
The equality function on domain n=3:
[[1, 0, 0]
 [0, 1, 0]
 [0, 0, 1]]

This function has the properties of closure and commutativity.
Challenge
This is code golf. Standard loopholes apply. Least bytes wins.

Haskell, 178 171 bytes

import Data.List
f x=[c,c&&and[(m%n)%o==m%(n%o)|m<-b,n<-b,o<-b],x==t,all(elem b)[x,t],b==[i%i|i<-b]]where c=all(l>)(id=<<x);b=[0..l-1];a%b=x!!a!!b;l=length x;t=transpose x

Returns a list with five booleans, which are in order closure, associativity, commutativity, identity and idempotence.

Usage example: f [[1, 0, 0],[0, 1, 0],[0, 0, 1]] -> [True,False,True,False,False].

How it works:

f x=[
  c,                         -- closure (see below)
  c&&and[(m%n)%o==m%(n%o)|   -- assoc: make sure it's closed, then check the
          m<-b,n<-b,o<-b],   --        assoc rule for all possible combinations
  x==t,                      -- comm: x must equal it's transposition
  all(elem b)[x,t],          -- identity: b must be a row and a column
  b==[i%i|i<-b]              -- idemp: element at (i,i) must equal i
  ]
  where                      -- some helper functions
  c=all(l>)(id=<<x);         -- closure: all elements of the input must be < l
  b=[0..l-1];                -- a list with the numbers from 0 to l-1
  a%b=x!!a!!b;               -- % is an access function for index (a,b)
  l=length x;                -- l is the number of rows of the input matrix
  t=transpose x

Edit @xnor found some bytes to save. Thanks!


Tips for golfing in Element Since my use of Element has increased recently, I am interested in tips for golfing programs written in it.

What general tips do you have for golfing in Element? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Element.

Please post one tip per answer.

Ways to put extra 0s on the stack

A lot of times, you will be faced with the following 4-character piece of code:

0 2@

Element's stack-item-movement operator @ is very general-purpose, sometimes too much so for golfing, since it always takes two arguments, which may need to be separated by a space.  So, it can take several characters to perform a single movement.

Usually, there is a better way to do this.

You can often produce empty values from the hash.  The code  2:0 2@ can almost always be shortened to 3:~2@ to save one character because chances are that nothing is stored in the hash for that particular key.

If the top thing on the stack is the input, you can sacrifice the newline at the end of it like so:

_0 2@
_)2@

In a limited number of cases, usually with 0 1@, you don't need the @ at all.  This works with input or when putting a constant on the stack.

_0 1@
'_"

text 0 1@
'text"


Hurricane Matthew and the Lightning Bolts Challenge

Inspired by this challenge and the nasty Hurricane Matthew, we will be generating some lightning bolts dynamically.

n = 15:

   \
   /\
  /  \
 /   /
/\  /\
 /  \ \
/   / /\
   /\ \
  / /  \
 /\ \  /\
  /  \ \
 /\  /
   \
    \
    /\

Input

Positive Integer n determines the depth of the lightning round.

Rules and Constraints

/ and \ should be used
The probability guiding the lightning's direction is as follow:

  25% Splits into 2 paths
  25% Path reaches dead end
  25% Goes Left
  25% Goes Right
  There are a few exceptions regarding overlapping and dead end below:

The code should not be deterministic, a new lightning bolt should be generated randomly every time
The bolts should not overlap: e.g. if there is already a bolt to the left of the current bolt, the current bolt should either end or go right, but not go left or split (probability still applies, in this case it become 50%end/50%right)
If there does not exist another available split path, the path should not end: e.g. in the beginning when there is only 1 path, the path should not end until it splits, also applies when there are multiple paths but all except one path are dead, (probability becomes 33%split/33%left/33%right) your goal is to reach the bottom
Whitespaces can be added on the left (all you would need should only be height-1)
However you want to generate the bolt is up to you, you can go from bottom up, left to right, etc. As long as all the rules above are satisfied

Another example

n = 10

 \
 /
 \
 /\
  /\
 / /
/\ \
 / /\
 \   \
 /

Stay safe and have fun golfing!
Please golf responsibly only when you are in a safe area!!

Perl, 92 90 89 84 bytes

Includes +1 for -n

Give height on STDIN:

perl -M5.010 bolt.pl <<< 15

bolt.pl:

#!/usr/bin/perl -n
map{$_=$;until$;=$_,s/.6|3.?/53|16*rand/eg,/3|6/>/36/;say y|3615|\\/ |r}(1x$_.6)x$_

Explanation

If you call the offset of the starting point 0 (a point is at the corner of a character box), then on the next row you can have gone left or right (or not) and can end up with points on offsets -1,1. The next row gives -2,0,2 as possible offsets etc. They all differ by 2. If you then call the character to the lower left of a point even and the character to the lower right odd you can extend that to assigning even or odd to each character position on a row such that even and odd alternate (in fact the whole plane is tiled in a checkerboard pattern). An even position can have a / or , an odd position can have \ or .

The character just before a / is in an odd position so it could be either \ or , but \/ is forbidden so only  is possible. Similarly the character after a \ must be a  (assuming the row is padded with enough spaces to the left and the right so the row boundaries are no issue). So a lightning bolt continues on the next row always directly below a \ or below a /. In either case the lower point is in the middle and the next row can have one of , /, \ or /\ directly below the top 2 characters. So to generate the next row I can simply replace any \ or / by any of these 4 expansions with equal probability (you could also independently replace the first character by  or / and the second character by  or \). In perl you could do this with something like:

s#\\ | /#("  "," \\","/ ","/\\")[rand 4]#eg

If the resulting row however contains \/ (forbidden join) or no / or \ at all (bolt dies and does not reach the bottom) the result is invalid. In that case I throw away the whole row and simply try again. A valid continuation always exists and if you try often enough one will be found (e.g everything dies except for 1 flow). This is a slightly different probability distribution from the suggested anti-overlap algorithm, but I think this is in fact better since it has no directional bias. Validity can be testing in a golfish way using

m#\\|/#>m#\\/#

The problem here is that the random substitution is so looooong and all these \ escapes also eat bytes. So I decided to build my rows using strings of digits and replace the appropriate digits by , / and \ just before printing. The basic random replacement is

53|16*rand

which gives one of 53, 55, 61 or 63 with equal probability. I then interpret 5 and 1 as , 3 as \ and 6 as /. That explains the row print:

say y|3615|\\/ |r

In a serious golf competition I would now start to systematically explore alternative magic formulas, but this should be pretty good (within 3 bytes of optimal)

The rest of the components of the program:

1x$_.6

This initializes $_ (see the next map) to height spaces followed by a /. This is an invisible row above the first one being printed and makes sure the field is wide enough so the bolt can never run out of space at the left

map{ ... ; say ...}(1x$_.6)x$_

I will process this same initial string height times printing a new row each time

$_=$;until$;=$_,...

Save the current row in $;. If the replacement turns out to be invalid restore $_ from $;

s/.6|3.?/53|16*rand/eg

Do the actual substitution. I don't have to check what is before / or after \ since it must be a space. This is convenient since space can be represented by either 1 or 5. Since I only padded the string to the left the space after the \ can still be absent, so make that character optional

/3|6/>/36/

Check if the new row is valid


Fill in the lakes, 2D The one-dimensional version of this problem was pretty easy, so here's a harder 2D version.

You are given a 2D array of land heights on standard input, and you have to figure out where the lakes will form when it rains.  The height map is just a rectangular array of the numbers 0-9, inclusive.

8888888888
5664303498
6485322898
5675373666
7875555787

You must output the same array, replacing all locations that would be underwater with *.

8888888888
566*****98
6*85***898
5675*7*666
7875555787

Water can escape diagonally, so there would be no lake in this configuration:

888
838
388

shortest code wins.  Your code must handle sizes up to 80 wide and 24 high.

Three more examples:

77777    77777
75657    7*6*7
75757 => 7*7*7
77677    77677
77477    77477

599999    599999
933339    9****9
936639 => 9*66*9
935539    9*55*9
932109    9****9
999999    999999

88888888    88888888
84482288    8**8**88
84452233 => 8**5**33
84482288    8**8**88
88888888    88888888

Haskell, 258 characters

a§b|a<b='*'|1<3=a
z=[-1..1]
l m=zipWith(§)m$(iterate(b.q)$b(\_ _->'9'))!!(w*h)where
 w=length m`div`h
 h=length$lines m
 q d i=max$minimum[d!!(i+x+w*y)|x<-z,y<-z]
 b f=zipWith(\n->n`divMod`w¶f n)[0..]m
 (j,i)¶g|0<i&&i<w-2&&0<j&&j<h-1=g|1<3=id
main=interact l

Example run:

$> runhaskell 2638-Lakes2D.hs <<TEST
> 8888888888
> 5664303498
> 6485322898
> 5675373666
> 7875555787
> TEST
8888888888
566*****98
6*85***898
5675*7*666
7875555787

Passes all unit tests. No arbitrary limits on size.

Edit (281 → 258): don't test for stability, just iterate to the upper bound; stop passing constant argument m


Make a simplified Tamagotchi/Giga Pet! Tamagotchi and Giga Pets were small electronic devices which simulated a little virtual pet. This pet had several stats, like health, hunger,  etc.
I recently wrote this example:

import msvcrt,os,sys;d=m=100;h=s=t=p=0;f=10
while 1:
 os.system('cls'if os.name=='nt'else'clear');print("health:",d,"\nhunger:",h,"\nsleep:",s,"\nfood:",f,"\npotions:",p,"\nmoney:",m);t+=1
 if msvcrt.kbhit():
  k=ord(msvcrt.getch())
  if k==102 and h>8 and f:f-=1;h-=9
  if k==115:s=0
  if k==112 and p:p-=1;d+=9
  if k==98 and m>8:m-=9;p+=1
  if k==116 and m>8:m-=9;f+=1
 if t>99:
  t=0;h+=1;s+=1
  if s>80:s=0;h+=9
  if h>80:d-=1
  if d<1:sys.exit(0)
  if d>79:m+=1

This is a bare-bones virtual pet in 467 bytes! I then wondered how well the code golf pros could do, so now, the challenge.

The Challenge

Make a program that tracks 6 stats of a virtual pet, and updates them over time and in response to user input. The stats are: health and money (starting at 100), food (starting at 10), and hunger, sleep, and potions (starting at 0).

The program should update the values in response to the following events:

While the program is receiving no input, it should perform updates at regular intervals (the interval between updates should not be shorter than half a second nor longer than one second). Each update does the following:

Hunger and Sleep each increase by 1.
If Hunger is 80 or above, Health decreases by 1.
If Sleep is 80 or above, it is reset to 0, and Hunger increases by an additional 9.
If Health is 80 or above, Money increases by 1.
If Health is 0, the program exits.

The program must also respond immediately upon the following keypresses by the user (this means that you will need to use a language feature or library that can detect a key being pressed and respond to it immediately, rather than just reading from standard input), performing the following actions:

f: If Hunger is greater than 8 and Food is nonzero, then Food is decreased by 1 and Hunger is decreased by 9.
s: Sleep is reset to 0.
p: If Potions is greater than zero, Potions is decreased by 1 and Health is increased by 9.
b: If Money is greater than 8, then Money is decreased by 9 and Potions are increased by 1.
t: If Money is greater than 8, then Money is decreased by 9, and Food is increased by by 1.

Whenever the values of the stats change, they must be displayed on screen in the form Stat: value. All six stats must be displayed whenever any of them changes; and the stats within a display must be separated either by commas or by newlines.

This challenge follows normal code-golf rules: the shortest program complying with the specification above wins. (Note that as usual, if the language is newer than the competition, the submission must be marked as non-competing.)

C, 424 406 386 357 bytes

#define x(a,b,c)if(*#a==C){if(b>8){c-=9;}Z=0;}
L,M=100,H,S=-1,F=10,P,Z,C;t(){H++;S++;L-=H>79;if(S>79)S=0,H+=9;Z=1/L/2;alarm(1);}main(){nodelay(initscr(),L=M);signal(14,t);for(t(H=S);C=getch();Z=Z||printf("\rhealth: %d,hunger: %d,sleep: %d,food: %d,potions: %d,money: %d\n",L,H,S,F,P,M)){x(s,9,S=9;S)x(p,P+8,P--;L+=18;L)x(f,H,F--;H)x(b,M,P++;M)x(t,M,F++;M)}}

I appreciate the need for raw input and asynchronous updates in the problem spec.  Even though that required some overhead from the ncurses setup and signal handlers, it's nice to have the occasional challenge that (hopefully) won't be automatically won by one of the dedicated golfing languages.

You didn't specify exactly how game over is indicated, so this one perishes with the traditional Tamagotchi death cry of "Floating point exception (core dumped)".

Ungolfed

/* Playing a bit fast and loose with the prototyping rules by omitting these;
 * none of the functions I'm using from them *exactly* match the default
 * prototype of `int f();`
 */
//#include <curses.h>
//#include <stdio.h>
//#include <signal.h>
//#include <unistd.h>

#define x(a,b,c)if(*#a==C){if(b>8){c-=9;}Z=0;}
L,M=100,H,S=-1,F=10,P,Z,C;

t() {
    H++;
    S++;
    L-=H>79;
    if(S>79)S=0,H+=9;
    Z=1/L/2;//0 if L>0. otherwise the pet dies of a floating point error
    alarm(1);
}

main(){
    nodelay(initscr(),L=M);
    signal(14,t);
    for(t(H=S); C=getch(); Z=Z||printf("\rhealth: %d,hunger: %d,sleep: %d,food: %d,potions: %d,money: %d\n",L,H,S,F,P,M)){
        x(s,9,S=9;S)
        x(p,P+8,P--;L+=18;L)
        x(f,H,F--;H)
        x(b,M,P++;M)
        x(t,M,F++;M)
    }
}


Convert ASCII art numbers to integers Inspired by this game

Challenge:

Given an ASCII art string representing a number, output that number.
Example:

Input:

  &&&&      #####    .====..    .&&&
 $$$$$.    %%   %%   %    % .   +. .
   @@@  .      @@ .  = .  =   . ????
   +++.    &&   &&.  %    %     =   =
   $$$    . @@@@@    #    #  .  ===.
 .$$$$$              .????.

Output: 1306

Input:

  ====     .$$..      &&&&&&.    .@@@@    ?????
 +++++     &. &           $$    %%   %%  &&   &&
   $$$     .==.          @@ .   @@   @@ .    ??
.  ### .   @  @  .      ==     $$$$$$$$  ??. .??
. .@@@.    .%%.        ==           .$$   &&&&&  .
  $$$$$. .            .%        .    @@ .

Output: 18743

Periods are interference, you can ignore them

The complete list of numbers:

 &&&&
%    %
=    =
%    %
#    #
 ????

 &&&&
$$$$$
  @@@
  +++
  $$$
 $$$$$

 #####
++   ++
 #  ##
   @@
  @@
???????

 #####
%%   %%
    @@
&&   &&
 @@@@@

   @@@@
 %%   %%
 @@   @@
$$$$$$$$
      $$
      @@

######
$
####
    +
    ?
$$$$$

 &&&
+
????
=   =
===

&&&&&&
    $$
   @@
  ==
 ==
 %

 $$
&  &
 ==
@  @
 %%

 &&&&
@    @
 &&&&
    $
    &
  +

Rules:

Your input is a string unless your language doesn't have a string type.
The input is guaranteed to be exactly 6 characters "high." Numbers such as 8 and 3 have a whitespace buffer UNDER the number.
If you write a function, it MUST return a numerical type.
The ASCII art can be composed of ANY printable characters in no particular order (remember, you can ignore periods).
No standard loopholes.
Your program must handle any arbitrary ASCII number of reasonable length (as long as the result fits within a 32-bit signed integer).
Input is guaranteed valid, undefined behavior is allowed with bad input.
This is code-golf, shortest program wins.

More tests:

  $$$$     ######     @@@@  . .  .%%%%    #####
 #####     $ .       =====..  . ##   ##  ++   ++
   +++     ####.       +++.     ==   ==   #  ##
   ===     .   +       ###  .  ========.    @@
  .&&&    .  . ?   . . @@@           ##    @@    .
  %%%%%    $$$$$      #####          @@  ???????

> 15142

 .&&&&.    ??????     @@@@@      .++++
 @    @    + .       ==   ==    %%   %%
 .&&&&.    ####..     =  == .   ++   ++
  .. $         &        $$     $$$$$$$$.
 .   &.      . #       && .          ##
   +.   .  #####     $$$$$$$        .==

> 9524

Jelly, 35 33 34 bytes

Ỵe€€⁾ .¬ZḄṣ0§ḟ0%29“h½sØ?X’ḃ26¤iⱮ’Ḍ

Try it online!

When I started writing this, The question didn’t specify that the width of digits was fixed, so my answer doesn’t make that assumption.

Input is now a string (which costs a byte over having a list of strings). Output is an integer.

Explanation:

Ỵ                         | split at new lines
e€€⁾ .                    | For each character check whether it is a
                          | full stop/space or something else
      ¬                   | invert this
       Z                  | transpose
        Ḅ                 | convert from binary to decimal (one number per column of input)
         ṣ0               | split at zeroes (blank columns)
§                         | take the sum of each digit
 ḟ0                       | filter out remaining blank columns
   %29                    | take this number mod 29
      “h½sØ?X’ḃ26¤iⱮ      | look each digit up in a compressed list
                          | [18, 23, 6, 5, 1, 19, 13, 21, 8, 25]
                    ’     | subtract one
                     Ḍ    | convert to decimal


Shortest 2-Player Game of Halma In Chess, it's possible for the game to end after 4 moves (2 each) with a Fool's Mate.

Your goal is to find the Fool's Mate of Halma: the 2-player game of Halma that minimises the number of turns played.

There are over 1056 board states, and I've seen the branching factor surpass 1000, so chances are no one will find the optimal solution.  Instead, you're trying to find the best solution you can.

You should submit a list of moves, and any code you used to generate those moves.

Explanation of the Game

Halma is similar to Chinese Checkers, but played on a 16*16 square board.

Initially, the board looks like this:

The goal of the game is to move all your pieces to the starting positions of your opponent's pieces.

On a player's turn, he/she may:

Pass the turn
Move one of his/her pieces to an adjacent empty space.  Adjacent spaces include diagonals.
Take one of his/her pieces and do the following any number of times: Jump the piece over an adjacent piece, landing it on the space opposite the piece jumped over.

Here's an example to illustrate the 2nd type of move.

Rules

Submit a list of legal moves which result in the game ending.

Submit any code you used to generate the list.

If you obtain a better result from someone else's code, post the result in a comment or edit their post with the new results.

Each move must be either None to pass the turn, or (x1,y1,x2,y2) to move a piece, where (x1,y1) are the coordinates of the piece to move and (x2,y2) are the destination of that piece (for jump moves, ignore intermediate coordinates).  The coordinates start at (0,0) at the top left corner.  x-coordinates increase to the right, y-coordinates increase downward.  Moves should be separated by newlines.

You can use this python script to verify your moves.  Use python halma_verify.py < file to verify moves in file.

Shortest list wins.

The shortest game of halma is 49 moves

49 move solution

Proof there is no 48-move solution

Code used for this solution

The code now supports pass

Notice that the 47 move solution in the paper is for the army transfer problem, not for the shortest game of halma

I'll hopefully get to doing a proper writeup this weekend


Obfuscation Challenge You are to write a program that does one of the following.

Only displays "Hello World" does nothing else
Quits and nothing else (no output, no errors.)
Takes one line of input, parses it as an integer, displays the first that many primes (or gives a nice error if it is given input that can't be parsed as an integer, or is less than 0.)
Given one line of input, it parses it has a stock symbol, and checks online for the current stock value and its change.

The catch, it should not be apparent which function it performs. Namely, for someone looking at your code, it should not be apparent which function it will do. Also, it may only perform and be able to perform one function (it can not pick and choose.) How good a program is is determined by how uncertain someone is that looks at it as to what its function is, and also how familiar that person is with that language.

BONUS:
If you in a clever way make it so although for any one compiler/intrpreter and platform, the program will also perform the same function, different compilers/interpreters or platforms, it will perform a different function. This bonus may only be collected if done cleverly.

BONUS:
If your program only contains code that is capable of one function (save nothing, as empty code is capable of that), and it is not possible to make a simple modification unrelated to the function to allow it to perform a different function.
For example: if you did

obfuscatedBool = 1g8uhad'l8fygrcetdu8y4fd/,.oe87fy4d --Magic
if obfuscatedBool: print "Hello World"

Would not count as obfuscatedBool could be made True or False to make it print "Hello World" or do nothing respectively.

INFINITY BONUS: If you realize both bonuses simultaneously, you are magic.

NEGATIVE BONUS: Using libraries with specific abilities to do the functions.

Voters, take the bonuses in to consideration, because the program with the most votes wins!

Note: If you say what your program does, make sure to use spoiler syntax!

Whitespace/Brainfuck/Python

'''begin''''''''''''
main(args){
	parseArgs=args.Find('^++++++++^[<++++[<++<+++<+++<+>>>>a-z]<+<+<A-Z[>]>0-9]<<.<---.*$');
    for(int i=0;	Range(GetLength(parseArgs));	i++){validateArg(parseArgs(i));}
	//name
    string stockName="";
	//loop
    for(int i=0;Range(GetLength(parseArgs));i++){
	//validate
     	if(matchFound=Find('a+z+A+.Z.0+9+_+.<<*$'){
	//found
     	parseArgs(i).Split('>-.>.+');}

     	for(int j=0;Range(GetLength(parseArgs(i)));j++){
	//download
    data=ConvertTo.String(eval("curl -get	http://some-stock-ticker-source-url-here.com"));
	print;
    print data;

    //line separator

    print "--------.";
	}}
}

''finish'''''''''''''''

Wikipedia: Whitespace (programming language)
Online Whitespace Interpreter to Test Answer
Online Brainfuck Interpreter to Test Answer

   Output (Whitespace/Brainfuck):
 Hello World

 Ouput (Python):
 Nothing, but runs successfully.


Block-diagonal matrix from columns Inspired by Copied from this question at Stack Overflow.

Given a matrix A, create a matrix B such that the columns of A are arranged in a block-diagonal fashion. For example, given

1 2 3
4 5 6

the output would be

1 0 0
4 0 0
0 2 0
0 5 0
0 0 3
0 0 6

Rules

Input and output may be in the form of 2D arrays, nested arrays, or strings with different separators for rows and columns.

Numbers in the input (matrix A) will be positive integers.

Unary format is allowed, as long as zeros in the output are displayed in some reasonable way. For example, the above result could be displayed using quotation marks to enclose each number:

'1' '' ''
'1111' '' ''
'' '11' ''
'' '11111' ''
'' '' '111'
'' '' '111111'

Test cases

Input, output:

1 2 3
4 5 6

1 0 0
4 0 0
0 2 0
0 5 0
0 0 3
0 0 6

10 20

10  0
 0 20

10
20

10
20

  1   2   3
 10  20  30
100 200 300

  1   0   0
 10   0   0
100   0   0
  0   2   0
  0  20   0
  0 200   0
  0   0   3
  0   0  30
  0   0 300

 2  4
 6  8
10 12

 2  0
 6  0
10  0
 0  4
 0  8
 0 12

MATL, 6 bytes
"@N$Yd

Works in current version (13.0.0) of the language/compiler.
Input has the following form, with semicolon as row separator, and commas or spaces as column separators within each row:
[1, 2, 3; 4, 5, 6]

Try it online!
Explanation
"         % implicitly input 2D array and loop over its columns
  @       %   push column
  N$Yd    %   build block-diagonal matrix from all stack contents. Stack contents are
          %   a single column in the first iteration, or a partially built 2D array
          %   and a new column in all other iterations
          % end loop
          % implicit display

Worked example
Consider the input [1 2 3; 4 5 6]. The for loop beginning with " takes each column of the input. Within each iteration, @ pushes the current column onto the stack. So in the first iteration it pushes [1; 4]. N$ specifies that all the stack contents will be used as inputs of the following function, Yd.
This function (corresponding to MATLAB's blkdiag) "diagonally concatenates" its inputs to produce a block diagonal matrix (2D array). So in the first iteration Yd it takes one input and produces an output equal to that input, [1; 4], which is left on the stack.
In the second iteration the second column of the input, [2; 5], is pushed. Now Yd takes two 2×1 inputs, namely [1; 4] and [2; 5], and produces the 4×2 array [1 0; 4 0; 0 2; 0 5].
In the third iteration Yd takes the latter 4×2 array and the third column of the input, [3; 6], and produces the final result [1 0 0; 4 0 0; 0 2 0; 0 5 0; 0 0 3; 0 0 6].


The answer to life, the universe, and everything Introduction: Deep Thought calculated The answer to life the universe and everything in a period of 7.5 million years, the solution was 42.

Write a program in any programming language that takes approx 75 seconds to calculate, starting from whatever you want, and output the number 42.

N.B. The number 42 must be calculated somehow (random numbers, whatever you prefer), not just hard-coded in your script.

As suggested, you can't use sleep or equivalent functions. Be inventive.

This takes about 75s on a raspberry pi overclocked to 1GHz

#!/usr/bin/env python
from itertools import product, count

for n in count(1):
    i = 0
    for a, b, c, d in product(range(n), repeat=4):
        if a > b > c > d > 0 == (a*b-c*d)%n == (a*c-b*d)%n == (a*d-b*c)%n:
            i += 1
    if i == n:
        break
print i

It works because:

  42 is the only known value that is the number of sets of four
  distinct positive integers a,b,c,d, each less than the value itself,
  such that ab-cd, ac-bd, and ad-bc are each multiples of the value.
  Whether there are other values remains an open question

http://www.mathpages.com/home/kmath255.htm


I won't not use no double negatives The goal is to simplify sentences containing multiple negatives.
Like with multiplying negative numbers, two negative words annihilate each other until at most one is left (doesn't matter which one). While some words disappear without a trace, other leave behind a positive part

The affected words are:

no
not
couldn't    could
wouldn't    would
shouldn't   should
don't       do
doesn't     does
didn't      did
isn't       is
aren't      are
weren't     were

You will notice that I conveniently forgot to include some rules like shan't/shall, won't/will, nothing/something, impossible/possible.
Hunting down all the exceptions is a nightmare and would make it yet another string compression challenge.
But if including some additional rules that are not listed, yet are in the spirit of the challenge would make your code shorter (looking at you, Mathematica built-ins), by all means, go for it.

Examples

Input

Move along
Nothing to see here
This sentence will stay the same
You dont put Nosferatu's donut knot in the cantaloupe cannon without an apostrophe.

Don't change this sentence.
This one will also not change
So far no inputs were changed

We don't need no education!
No, don't say that!
Wouldn't it be nice if people weren't fighting?

I don't not use no double negatives.
This isn't not the usual way to not express yourself not
We don't not have no time to not don't solve this
I don't not even know if this isn't not making no sense anymore, it wouldn't be so bad if it weren't for not all these not words which not shouldn't be not there in the first place

Output (either of the elements is valid)

["Move along"]
["Nothing to see here"]
["This sentence will stay the same"]
["You dont put Nosferatu's donut knot in the cantaloupe cannon without an apostrophe."]

["Don't change this sentence."]
["This one will also not change"]
["So far no inputs were changed"]

["We do need education!"]
[", do say that!", "do say that!", "Do say that!"]
["Would it be nice if people were fighting?"]

["I don't use double negatives.", "I do not use double negatives.", "I do use no double negatives."]
["This is the usual way to express yourself"]
["We don't have time to do solve this", "We do not have time to do solve this", "We do have no time to do solve this", "We do have time to not do solve this", "We do have time to don't solve this"]
["I do even know if this is making sense anymore, it would be so bad if it were for all these words which should be there in the first place"]

Retina 0.8.2, 44 bytes

i`(\bnot?\W+|n't\b)(.*?)(\bnot?\W+|n't\b)
$2

Try it online! Link includes test cases.


Find all the Anagrams! Despite having 17 questions tagged anagrams, we still don't have this question, so here it is.
Your Task
You must write a program or function that, when receiving a string, prints out all possible anagrams of it.  For the purposes of this question, an anagram is a string that contains the same character as the original string, but is not an exact copy of the original string.  An anagram does not have to be or contain actual words.
Input
You may accept the string, which may be of any length > 0, by any standard input method.  It may contain any ASCII characters.
Output
You may output all of the possible anagrams of the inputted string in any standard way. You must not output the same string twice, or output a string equal to the input.
Other Rules
Standard Loopholes are disallowed
Scoring
This is code-golf, least bytes wins.

05AB1E, 3 bytes

œÙ¦

A function that leaves the stack with a list of the anagrams on top (and as its only item). As a full program prints a representation of that list.

Try it online!

How?

    - push input
œ   - pop and push a list of all permutations (input appears at the head)
 Ù  - pop and push a list of unique items (sorted by first appearance)
  ¦ - pop and push a dequeued list (removes the occurrence of the input)
    - As a full program: implicit print of the top of the stack


ASCII art compression The following challenge is basically a simpler version of the one proposed by Dennis (Lossy ASCII art compression). I found the idea super interesting but a bit too convulted, and seeing as it didn't seem to be getting much attention I decided to modify it a little bit.

You'll be downloading 5 ASCII art text files, each of them composed only of the following characters:

@#+';:,.`

Each char represents a different brightness level (1-10 from @ to the whitespace).

Given a quality ratio q, which varies from 0.5 to 0.9 in 0.1 increments, your job is to output a compressed version of each ASCII file, while making those files able to decompress themselves.

That is to say, ImageX.txt is compressed by Program.py into CompImageX-xx.cpp (xx being the quality of the compressed image). Once CompImageX-xx.c is executed, a final decompressed image ImageX-xx.txt is created.

The .py and .c extensions are just an example, you can write the compressor and compressed images in any language that you want (doesn't have to be the same language for both, but you can't use different languages for different images).

The quality changes the image output in a relatively simple way. We'll call the array of usable chars Arr. Each char of ImageX becomes Arr[RoundHalfDown((Arr.Index(char)*q))], with the exception of the whitespace which remains the same no matter the quality.

RoundHalfDown(0.6) = RoundHalfDown(0.7) = RoundHalfDown(1) = 1

RoundHalfDown(0.5) = RoundHalfDown(0.4) = RoundHalfDown(0) = 0

For a short example:

 '#;@

at q=0.5 would become

 #@+@`

You have to implement your own compressor, can't use any libraries that handle it for you.

You can view the images here and download them from here.

Your score is the square root of the size of your compressor, multiplied by the sum of the size of all the compressed files --> sqrt(c)*sum(f). Lowest score wins.

USER                    LANGUAGE                    SCORE
Dennis                  CJam                        1046877

CJam → CJam, score 1046877.4413

I'm not going to participate in my own challenge, but since this one doesn't contain its core part (figuring out the optimal transformation to make the original image more compressible), here I go:

q"@#+';:,.` ":P9,easdf*.4f+:iPf=S+er_N/z,:L;N-__&W%:Pf#2f+e`{(2b1>}%
e_P,2+b256b:c`P`":P,2+\256b\b{_2,#)_(@a?)+}%{(2-a\2b)*}%e_Pf="L"/N*"

The linefeed is for "readability" only.

It should be possible to improve the score by improving or simplifying the compression.

Summary

e# Read the input and modify the palette according to the quality.

q"@#+';:,.` ":P9,easdf*.4f+:iPf=S+er

e# Compute the line length and the unique characters of the palette.

_N/z,:L;N-__&W%:P

e# Replace each character by its index in the palette, plus two.

f#2f+

e# Perform run-length ecnoding, saving the runs using bijective base-2 numeration.
e# All related code has been adapted from this answer:
e# http://codegolf.stackexchange.com/a/53065

e`{(2b1>}%

e# Convert from base length(palette)+2 to byte array (string).

e_P,2+b256b:c`

e# Push the palette and the code for the decoder.

P`":P,2+\256b\b{_2,#)_(@a?)+}%{(2-a\2b)*}%e_Pf="L"/N*"

Score

$ LANG=en_US
$ for i in {1..5}; do for q in 0.{5..9}; do
> cjam comp.cjam $q < image$i.txt > image-$i-$q.cjam
> done; done
$ wc -c comp.cjam
136 comp.cjam
$ wc -c image*.cjam
 2131 image-1-0.5.cjam
 2248 image-1-0.6.cjam
 2346 image-1-0.7.cjam
 2350 image-1-0.8.cjam
 2446 image-1-0.9.cjam
 3006 image-2-0.5.cjam
 3718 image-2-0.6.cjam
 3894 image-2-0.7.cjam
 3356 image-2-0.8.cjam
 4064 image-2-0.9.cjam
 2949 image-3-0.5.cjam
 2947 image-3-0.6.cjam
 3582 image-3-0.7.cjam
 3784 image-3-0.8.cjam
 3745 image-3-0.9.cjam
 2879 image-4-0.5.cjam
 2887 image-4-0.6.cjam
 3379 image-4-0.7.cjam
 3615 image-4-0.8.cjam
 3537 image-4-0.9.cjam
 4427 image-5-0.5.cjam
 4802 image-5-0.6.cjam
 5536 image-5-0.7.cjam
 6030 image-5-0.8.cjam
 6111 image-5-0.9.cjam
89769 total


All the numbers that fit in a string Write a program or function that takes in a positive integer N. Output a list of all the distinct decimal numbers that can be written in exactly N characters using digits (0123456789), decimal points (.), and negative signs (-).

For example, some numbers that would be in the N = 4 output list are 1337, 3.14, .999, -789, -2.7, and -.09.

The numbers are to be written in the normal way, but in as short a form as possible. This means:

The decimal point should only be included if the number is not an integer.

e.g. 45.0 and 45. should be written as plain 45
-45.00 should be written as -45

There should be no leading zeroes to the left of the decimal point.

03 and 003 should be written as 3, but 30 and 300 are fine as they are
0.3 and 00.3 should be written as just .3
-03 should be written as -3
-0.3 should be written as -.3

There should be no trailing zeroes to the right of the decimal point

.50 and .500 should be written as .5
900.090 should be written as 900.09

The exception to the two last rules is zero itself, which should always be written as plain 0.
Positive signs (+) should not be used since they unnecessarily lengthen the number.

Also note that the negative sign (-) should not be used as a subtraction sign. It should only appear as the first character of numbers less than zero.

Formatting

The order of the output list of numbers does not matter. It could be ascending, descending, or completely mixed up. It only matters that all of the distinct numbers that can be written in N characters are present.

The list can be formatted in a reasonable way, using spaces, newlines, commas, or perhaps something else between the numbers, as long as things are consistent. Leading and trailing brackets (or similar) are alright but things like quotes around numbers are not. (i.e. don't visibly mix up strings and ints/floats in the output.)

For example, when N = 1, some valid outputs would be:

0 1 2 3 4 5 6 7 8 9

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

ans = { 5 8 9 1 3 2 0 3 4 7 6 }

But this would be invalid:

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

Examples

N = 1 -> 0 1 2 3 4 5 6 7 8 9

N = 2 -> -9 -8 -7 -6 -5 -4 -3 -2 -1 .1 .2 .3 .4 .5 .6 .7 .8 .9 10 11 12 ... 97 98 99

N = 3 -> -99 -98 ... -11 -10 -.9 -.8 ... -.2 -.1 .01 .02 ... .98 .99 1.1 1.2 ... 1.9 2.1 2.2 ... 2.9 3.1 ...... 9.9 100 101 ... 998 999

Lists are in ascending order, ellipsized in some places for reading convenience.

Scoring

The shortest code in bytes wins. In case of ties, the higher voted answer wins

Pyth, 57 bytes

j-f:T"^0$|^-?([1-9]\d*)?(\.\d*[1-9])?$"0{.P*Q+jkUT".-"Q\-

Try it on the online interpreter.

Way too long, and with horrific runtime (takes several seconds for N=4, running with N=5 is not recommended).

            .P           Q    all permutations of length (input) of
                 jkUT         ... the string "0123456789"
                +    ".-"     ... plus the chars "." and "-"
              *Q              ... whole thing times the input -- pyth has
                              no repeated_permutation, so this is necessary
           {                  uniquify
  f                           filter by
   :T"..."0                   does it match the really long regex?
 -                        \-  get rid of "-"
j                             join on newline

Regex explanation:

^0$|            "0", or...
^
 -?             optional negative sign
 ([1-9]\d*)?    optional part-before-decimal
 (\.\d*[1-9])?  optional part-after-decimal
$


ASCII Ball in Box Animation Write a program that displays a moving ASCII ball * inside a rectangle (20 by 10 chars including border). The ball must not cross the rectangle, e.g. bump off when it hits the wall. The scene must be cleared and redrawn every 0.1 seconds and the ball must move 1 char in x and y direction every frame. The shortest program written in any language wins.

Example output (frame 1)

+------------------+
|*                 |
|                  |
|                  |
|                  |
|                  |
|                  |
|                  |
|                  |
+------------------+

Example output (frame 2)

+------------------+
|                  |
| *                |
|                  |
|                  |
|                  |
|                  |
|                  |
|                  |
+------------------+

Example output (frame 8)

+------------------+
|                  |
|                  |
|                  |
|                  |
|                  |
|                  |
|                  |
|       *          |
+------------------+

Example output (frame 9)

+------------------+
|                  |
|                  |
|                  |
|                  |
|                  |
|                  |
|        *         |
|                  |
+------------------+

Ruby 1.9, 115 characters

The movement logic is quite similar to Danko's answer.

This version has been tested on Linux only.

p=0
loop{u=(?|+?\s*18+"|
")*8
u[165-21*(7-p%14).abs-(17-p%34).abs]=?*
p+=1
puts"\e[2J",r=?++?-*18+?+,u,r
sleep 0.1}


Read color in my way Different systems have different ways to describe colors, even if all of them are speaking in R-G-B-A space. A front-end developer who is familiar with CSS may prefer #RRGGBBAA. But Android developers may prefer #AARRGGBB. When handling AAS file format, #AABBGGRR is needed. That's too confusing. Maybe we need a program which can convert between different color formats.

Input:

The input contains 3 parts:

The color to be transformed (e.g. #1459AC0F), a string starting with sharp sign # followed by 8 hex digits.
The format of the given color (e.g. #RRGGBBAA), a string starting with # followed by 8 letters which fall into 4 different groups and each group is one of RR/GG/BB/AA.
The format to convert to.

Output:

Output the color in converted format

Test Cases:

Color, OriginalFormat, TargetFormat -> Result
#12345678, #RRGGBBAA, #AARRGGBB -> #78123456
#1A2B3C4D, #RRGGBBAA, #AABBGGRR -> #4D3C2B1A
#DEADBEEF, #AARRGGBB, #GGBBAARR -> #BEEFDEAD

Input / output are case insensitive. You may input / output in any acceptable way.

Rules:

This is code golf, shortest (in byte) codes of each language win

APL (Dyalog Unicode), 6 bytesSBCS

Full program. Prompts on STDIN for Original, then Target, then Color. Prints Result to STDOUT.

⍞[⍞⍋⍞]

Try it online!

  ⍞ prompt for Original

 ⍞⍋ prompt for Target and find the indices into Original that would make Original into Target

⍞[…] prompt for Color and use the above obtained indices to reorder Color


Hashiwokakero: Build bridges! Hashiwokakero ("build bridges" in Japanese) is a puzzle where you are tasked
with connecting a group of islands with bridges. The rules are:

Bridges must run either vertically or horizontally between two islands.
Bridges may not cross each other.
A pair of islands may be connected by at most two parallel bridges.
Each island is marked with a number between 1 and 8, inclusive. The number of bridges connected to an island must match the number on that island.
The bridges must connect the islands into a single connected group.

Your task is to write a program that will solve Hashiwokakero puzzles.

You may assume that any given puzzle is solvable and that there is only one solution.

The program should be reasonably efficient. For example, solving the 25x25 puzzle below shouldn't take more than 10 minutes on an average PC and it shouldn't use more than a gigabyte of memory. Solving smaller puzzles like the 7x7 one should take seconds.

Input:

The puzzle will be given as a 2D map of characters, with the digits 1 to 8 representing islands, and spaces representing water. The lines will be padded with spaces if necessary to make them all the same length.

Islands will always be separated horizontally and vertically by at least one square of water so that there is room to place the potential bridge between them. There will always be at least two islands in a puzzle.

Your program should preferably read the puzzle map from standard input, but you may specify an alternate input method if your programming language requires it.

Output:

The output should be like the input, except with spaces replaced by bridges as necessary. The bridges should be drawn using Unicode box drawing characters ─ (U+2500), │ (U+2502), ═ (U+2550) and ║ (U+2551) to represent horizontal and vertical single and double bridges.

If Unicode characters are a problem, you may use the ASCII characters -, |, = and H instead.

Winning criteria:

This is code golf. The shortest correct and reasonably efficient solution wins.

Examples:

Puzzle (7x7):

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

Solution:

2─2──1
│1──4─3
3──2║ ║
│  │4 ║
│3─2║ 3
1║  ║ │
 3──4─2

Puzzle (25x25):

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

Solution:

2─2─2──2  1 1─2─2──2──2─2
│      │  │1─3═5══4══4─2│
2  2─4─5══5═4═2│2──1 │ │3
│ 2│ ║1│ 1─3═3─2│    │ 2║
│ ║3═4│4══4─4═5─4─3──2 │3
2 4═5─4│  │ │ ║ │ │2───3│
│2─1║ ║4─2│ 4─3 │ 1│ 1 │2
2│1─3 ║║ │1 ║1──6══4 │ 2│
│3─2──4║ 3══6─3 ║  │ │ │2
2│2═3 │3──2 │ ║ 5─2│ 4─3│
│2─1│ │   │ │ ║ ║ │1 ║ │2
│ 1─3─3─3─3─5═8═7═6──5═4│
2──3───1│1─2│ ║ │ ║    ││
 1 │ 1──5─1││ 4─5─6─3─1│2
1│ │1──2║  │2 │ ║ ║ │3═4│
│3─5═4 │4──3│ 3═8═7═5│1│2
2│ │ ║ 3│ 1│2──2║ │ ║1│1│
│2 │ ║ ║2 │2──2│5═7═6─3─3
3│ 3─6─3│ 5═3 │2│ ║2│2─3│
║2 │ ║  │ ║ │ 1│2─3║2│ ║2
3│ 4═6──4─5─5──3─3─5││1║│
│2 │ │1 │ │2║2──1│ ║1││3│
2│ │ 1│ │ 1║2│3══6═5─2││2
│2─3──4═4──4─2│  │    │1│
2─2──2─2──2─2─2  1  1─3─2

Additional puzzles can be found here.

Haskell, 1074 characters

main=interact$unlines.(\f@(l:_)->let a=(length l,length f)in head.filter(網(0,0)a).計(0,0)a$f).lines
橋=結"─═"数;結=zip;網 置@(右,下) 域@(幅,高) 地|下>=高=實|右>=幅=網(0,下+1)域 地|目 置 地`含`島
 =折((&&).折((&&).not.(`含`島))實)實(潔 置 域 地)|實=網(右+1,下)域 地
導=[(種,動)|動<-[1,-1],種<-"─═│║"];潔 置 域 地=折(拡 置 域)(換 地 置 '0')導
拡 置 域(種,動)地|([地],置)<-続(行 置 種 動)域 種 動 種 地=潔 置 域 地|實=地
計 置@(右,下)域@(幅,高)地|下>=高=[地]|右>=幅=計(0,下+1)域 地|[価]<-目 置 地`価`島
 =見込(価-環 置 域 地)>>=折(\種->(fst.続(行 置 種 1)域 種 1' '=<<))[地]>>=計(右+1,下)域
 |實=計(右+1,下)域 地;見込 価|価<0=[]|価>4=[]|實=[[""],["─","│"],["─│","║","═"],["─║","═│"],["═║"]]!!価
続 置 域 種 動 空 地|存 置 域=建 置 域 種 動 空 地|實=([],置)
建 置 域 種 動 空 地|目 置 地`含`島=([地],置)|目 置 地==空=続(行 置 種 動)域 種 動 空(換 地 置 種)
 |實=([],置);存(右,下)(幅,高)|右>=0,幅>右,0<=下=高>下|實=not 實;環 置 域 地=折(環行 置 域 地)0導
環行 置 域 地(種,動)数|置<-行 置 種 動,存 置 域,事<-目 置 地,事==種,[価]<-事`価`(橋++桥)=数+価|實=数
行(右,下)種 数|種`含`橋=(右+数,下)|實=(右,下+数);目(右,下)地=地!!下!!右;島=結"12345678"数
換 地(右,下)事|(上に,線:下に)<-捌 下 地,(左,古:右)<-捌 右 線=上に++(左++(事:右)):下に
折=foldl.flip;捌 0覧=([],覧);捌 数(物:覧)|(一覧,他)<-捌(数-1)覧=(物:一覧,他);實=1>0;数=[1..]
価 _[]=[];価 事((物,数):覧)|事==物=[数]|實=価 事 覧;含 事 覧|[_]<-価 事 覧=實|實=1<0;桥=結"│║"数

Originally, I had it even more purely Japanese by also implementing the primitive functions in terms of simple pattern matching and list combinations:

Haskell, 1192

main=interact$unlines.(\f@(l:_)->let a=(length l,length f)in head.filter(網(0,0)a).計(0,0)a$f).lines
橋=結合"─═"数;結合 []_=[];結合(事:覧)(物:一覧)=(事,物):結合 覧 一覧
網 置@(右,下) 域@(幅,高) 地|下>=高=實|右>=幅=網(0,下+1)域 地|目 置 地`含`島
 =折る((&&).折る((&&).反対.(`含`島))實)實(潔 置 域 地)|實=網(右+1,下)域 地
導=[(種,動)|動<-[1,-1],種<-"─═│║"];潔 置 域 地=折る(拡 置 域)(換 地 置 '0')導
拡 置 域(種,動)地|([地],置)<-続(行 置 種 動)域 種 動 種 地=潔 置 域 地|實=地
計 置@(右,下)域@(幅,高)地|下>=高=[地]|右>=幅=計(0,下+1)域 地|[価]<-目 置 地`価`島
 =見込(価-環 置 域 地)>>=折る(\種->(一.続(行 置 種 1)域 種 1' '=<<))[地]>>=計(右+1,下)域
 |實=計(右+1,下)域 地;見込 価|価<0=[]|価>4=[]|實=[[""],["─","│"],["─│","║","═"],["─║","═│"],["═║"]]!!価
続 置 域 種 動 空 地|存 置 域=建 置 域 種 動 空 地|實=([],置)
建 置 域 種 動 空 地|目 置 地`含`島=([地],置)|目 置 地==空=続(行 置 種 動)域 種 動 空(換 地 置 種)
 |實=([],置);存(右,下)(幅,高)|右>=0,幅>右,0<=下=高>下|實=反対 實;環 置 域 地=折る(環行 置 域 地)0導
環行 置 域 地(種,動)数|置<-行 置 種 動,存 置 域,事<-目 置 地,事==種,[価]<-事`価`結 橋 桥=数+価|實=数
行(右,下)種 数|種`含`橋=(右+数,下)|實=(右,下+数);一(第,第二)=第;目(右,下)地=地!!下!!右;島=結合"12345678"数
換 地(右,下)事|(上に,線:下に)<-捌 下 地,(左,古:右)<-捌 右 線=結 上に(結 左(事:右):下に);変 関[]=[]
変 関(物:覧)=関 物:変 関 覧;折る 関 物[]=物;折る 関 物(事:覧)=折る 関(関 事 物)覧;捌 0覧=([],覧)
捌 数(物:覧)|(一覧,他)<-捌(数-1)覧=(物:一覧,他);實=1>0;反対 真|真=1<0|實=實;数=[1..];結=(++)
価 _[]=[];価 事((物,数):覧)|事==物=[数]|實=価 事 覧;含 事 覧|[_]<-価 事 覧=實|實=1<0;桥=結合"│║"数

$ make ;   def0 +RTS -M1g < test-25x25.txt
ghc -o bin/def0 golfed0.hs -rtsopts -O2
[1 of 1] Compiling Main             ( golfed0.hs, golfed0.o )
Linking bin/def0 ...
2─2─2──2  1 1─2─2──2──2─2
│      │  │1─3═5══4══4─2│
2  2─4─5══5═4═2│2──1 │ │3
│ 2│ ║1│ 1─3═3─2│    │ 2║
│ ║3═4│4══4─4═5─4─3──2 │3
...

runs in ≈3 minutes on my i5.

Commented version:

type Board = [[Char]]
type Location = (Int,Int)
type BoardDimensions = (Int,Int)

main=interact$unlines.(\f@(l:_)
  ->let a=(length l,length f)  -- dimensions of the field from the input
     in head.filter(網(0,0)a)   --   ↙−   determine all possible ways to build bridges
  {-                ↑      -}   .計(0,0)a $ f                                         ).lines
     -- and use the first that is simply connected.

 --  islands,            bridges
島=結合"12345678"数;  橋=結合"─═"数;  桥=結合"│║"数;               数=[1..]
 -- each with the associated "value" from the natural numbers _↗

     -- plan & commit the building of bridges
計 :: Location -> BoardDimensions -> Board -> [Board]
計    置@(右,下)   域@(幅,高)          地
 |下>=高=[地]        -- Walk over the board until every location was visited.
 |右>=幅=計(0,下+1)域 地
 |[価]<-目 置 地`価`島      -- When there is an island, read it's "value" 価
    =見込(価-環 置 域 地)  -- substract the value of the already-built bridges; fetch the ways to build bridges with the remaining value
     >>=折る(\種->(一.続(行 置 種 1)域 種 1' '=<<))[地]  -- for each of these ways, try to build a bridge.
      >>=計(右+1,下)域    -- for every possibility where that was successful, go on with the resultant board.
 |實=計(右+1,下)域 地

  -- Ways to build bridges with value 価:
見込 :: Int -> [[Char]]
見込    価
 |価<0=[]   -- not possible to build bridges with negative value
 |価>4=[]   -- nor with value >4  (we're always building south- / eastwards)
 |實=[ [""]      -- value 0
     ,["─","│"]  -- value 1
     ,["─│","║","═"],["─║","═│"],["═║"]]!!価  -- ... and so on

 -- continue, if Location is on the board, with the building of a bridge of type 種
続 :: Location -> BoardDimensions -> Char -> Int -> Char -> Board -> ([Board],Location)
続    置          域                  種      動      空      地
 |存 置 域=建 置 域 種 動 空 地
 |實=([],置)

      -- build that bridge,
建 :: Location -> BoardDimensions -> Char -> Int -> Char -> Board -> ([Board],Location)
建    置          域                  種      動      空      地
 |目 置 地`含`島=([地],置)  -- but if we've reached an island we're done
 |目 置 地==空 -- if we're in water or what else (空, can also take on the value of 種 if we only want to check if the bridge is already there)
    =続(行 置 種 動)域 種 動 空(換 地 置 種) -- place (換) the bridge and go (行く) to the next location
 |實=([],置)  -- if we've reached something else (i.e. crossing bridges), return no result.

     -- number of connections present at location 置
環 :: Location -> BoardDimensions -> Board -> Int
環 置 域 地=折る(環行 置 域 地)0導  -- for all neighbouring positions
環行 置 域 地(種,動)数
 |置<-行 置 種 動,存 置 域   -- if they're on the board
 ,事<-目 置 地,事==種    --   and there's a bridge in the correct direction
 ,[価]<-事`価`結 橋 桥=数+価  -- check its value and sum it to the previous ones
 |實=数   -- if there's no bridge there, don't sum anything

導=[(種,動)|動<-[1,-1],種<-"─═│║"]     -- directions to go

--     --     --     --     --     --     --     --     --     --     --     --

     -- test for connectedness:
網 :: Location -> BoardDimensions -> Board -> Bool
網    置@(右,下)      域@(幅,高)         地      -- Walk over the board until an island is
 |下>=高=實                                    -- found. 潔 marks all islands connected to
 |右>=幅=網(0,下+1)域 地                        -- that island; then check if any unmarked
 |目 置 地`含`島=折る((&&).折る((&&).反対.(`含`島))實)實(潔 置 域 地)  -- islands are left in the
 |實=網(右+1,下)域 地                                                          -- result.

         -- mark islands connected to the one at 置:
潔 :: Location -> BoardDimensions -> Board -> Board
潔    置           域                 地    =折る(拡 置 域)(換 地 置 '0')[(種,動)|動<-[1,-1],種<-"─═│║"]
 -- mark the island at 置 with '0', then, for all the possible ways to go...
     -- Proceed with the marking in some direction
拡 :: Location -> BoardDimensions -> (Char,Int) -> Board -> [[Char]]
拡 置 域(種,動)地     -- if an island is found in the given direction, give control to 潔 there
 |([地],置)<-続(行 置 種 動)域 種 動 種 地=潔 置 域 地
 |實=地   -- if none is found (i.e. there was no bridge), just return the board without further marking

--     --     --     --     --     --     --     --     --     --     --     --
-- Primitives:

存 :: Location -> BoardDimensions -> Bool
存(右,下)(幅,高)|右>=0,幅>右,0<=下=高>下|實=反対 實  -- check if (右,下) is on the board

行 :: Location -> Char->Int -> Location
行(右,下)種 数|種`含`橋=(右+数,下)|實=(右,下+数)   -- go in some direction (determined by where 種 leads to)

目 :: Location -> Board -> Char
目(右,下)地=地!!下!!右          -- lookup what's at location (右,下)

   -- replace what's at (右,下) with 事
換 :: Board -> Location -> Char -> Board
換 地(右,下)事|(上に,線:下に)<-捌 下 地,(左,古:右)<-捌 右 線=結 上に(結 左(事:右):下に)

変 :: (a -> b) -> [a] -> [b]
変 関[]=[]                       -- Standard Haskell map function (just noticed I didn't actually use it at all)
変 関(物:覧)=関 物:変 関 覧

折る :: (b -> a -> a) -> a -> [b] -> a
折る 関 物[]=物                            -- equivalent 折る=foldl.flip
折る 関 物(事:覧)=折る 関(関 事 物)覧

捌 0覧=([],覧)
捌 数(物:覧)|(一覧,他)<-捌(数-1)覧=(物:一覧,他)   -- splitAt

實=1>0           --true

反対 真|真=1<0|實=實  -- not

結=(++)     -- list linking

一(第,第二)=第    -- fst

価 :: Eq a => a -> [(a,b)] -> [b]
価 _[]=[]                             -- lookup function
価 事((物,数):覧)|事==物=[数]|實=価 事 覧

含 :: Eq a => a -> [(a,b)] -> Bool
含 事 覧|[_]<-価 事 覧=實|實=1<0      -- equivalent 含 x = elem x . map fst

結合 []_=[]                          -- zip
結合(事:覧)(物:一覧)=(事,物):結合 覧 一覧


List numbers within given ranges Goal:

Your goal is to print out numbers within a given range (Also including given values).

Input Format:

The input will look like:
(int-int, int-int, ...)

... meaning the user can add as many int-int as they'd like.

Other Info:

You will only have to handle non-negative integer numbers.
The first integer in int-int will always be smaller, or the same, then the next integer in int-int
The input will always have at least two int-int
Each int-int will followed by a comma and a space, except for the last one.
This is code-golf meaning the shortest answer wins!

Examples / Test Cases:

Example 1:
Input:
(10-13, 11-15, 0-3)
Output:
10 11 12 13 11 12 13 14 15 0 1 2 3
Example 2:
Input:
(1-5, 1-15)
Output:
1 2 3 4 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Example 3:
Input:
(1-2, 1-3, 1-3, 1-2)
Output:
1 2 1 2 3 1 2 3 1 2
Example 4:
Input:
(4-6, 0-1, 9-9)
Output:
4 5 6 0 1 9

Minkolang 0.13, 12 bytes
nd1+?.n~Lr$N

Try it here.
Explanation
n      Take number from input (-1 if input is devoid of numbers)
d1+    Duplicate and add 1
?.     If this is 0, stop.
n~     Get number from input and negate it (because of the '-')
L      Pops b,a and pushes a,a+1,a+2,...,b-1,b
r      Reverses list
$N     Outputs whole stack as numbers


HappyCube Puzzle Solver This challenge is inspired by a puzzle I played, consisting of foam pieces like these:

which have to be assembled into 3D cubes, like these:

The puzzle pieces can be viewed as grids of 5 * 5 squares, whose middle 3 * 3 squares are always solid, while the 16 squares on the edges can be solid or empty.

A piece will be described using a string of 16 characters (0s and 1s), representing the configuration of its edges (0=empty, 1=solid), in clockwise order, starting from the top left corner.

For example, the string:

0101001000101101

represents this piece:

 # #
####
 ####
####
# #

In order to fit the pieces together to form the cube, every piece can be rotated in any direction. For example, these are the valid rotations of the piece shown above:

 # #    # #     #    ## #
 ####  ####    ####   ####
####    ####  ####   ####
 ####  ####    ####   ####
  # #  # #    ## #     #

# #      # #   # ##    #
####    ####  ####   ####
 ####  ####    ####   ####
####    ####  ####   ####
 # #    # #     #     # ##

Challenge

Write a program or function that takes as input 6 puzzle pieces and prints or returns a 2D representation of the solved cube.

Input

The input will be a string of 6 rows, where each row consists of 16 0 or 1 characters, representing a piece's edges (in the format described above).

It can be assumed that there is a solution for the input.

The trailing newline is optional.

Output

The result will be an ASCII representation of the solved cube, unfolded in 2D, like this (the diagram uses Rubik's Cube notation for side names):

    +---+
    |BA |
    |CK |
    |   |
+---+---+---+---+
|LE |DO |RI |UP |
|FT |WN |GHT|   |
|   |   |   |   |
+---+---+---+---+
    |FR |
    |ONT|
    |   |
    +---+

To avoid the possibility of presenting the solution in multiple ways, the piece placed DOWN will always be the first piece present in the input, in the same rotation as it is specified there.

Every piece will be represented graphically as a 5 * 5 matrix, using spaces to denote empty squares.
For solid squares you can use whatever non-space character you wish, as long as:

any piece of the puzzle will have its solid squares represented using the same character
any two adjacent pieces use different characters

Space padding to the right and the trailing newline are optional.

Test Cases

1.

Input:

0010010101010101
0010001011011010
0101001001010010
0010110100101101
0010110110101101
0010001011010101

Output:

     @ @
     @@@
    @@@@@
     @@@
** **@#@** *# #
 ***#####***#####
*****###*****###
 ***#####***#####
  * @#@#** ** # #
    @@@@
     @@@@
    @@@@
     @ @

2.

Input:

0001110110101101
1010010111011101
0101010101010010
1010001000100011
1010001001010001
0110010100100010

Output:

      @
     @@@@
    @@@@
     @@@@
** **@@## * *# #
****#####****###
 ****###*****####
****#####***####
** *#@#@# * # #
     @@@@
    @@@@
     @@@@
     @ @

3.

Input:

0101001011011010
0010001000100010
0101001011010010
0101010101011010
0101101001011101
1010001001011101

Output:

     @ @@
    @@@@@
     @@@
    @@@@@
* * @#@#* *   #
*****###*****###
 ***#####***#####
*****###*****###
  * ##@##* *  #
    @@@@
     @@@@
    @@@@
    @@ @@

This is codegolf, so the shortest program in bytes wins.

Haskell, 1007 One Thousand and One Bytes 923 900 830 bytes

I happened to have already made a happycube solver, now I just need to golf it. Taking a ten byte penalty for using fancy block elements:

import Data.List
r=reverse;z=zipWith;f=foldl1;t=take;g=t 4;d=drop;m=map
n x=t 5x:n(d 4x)
u v a b=init a++v max(last a)(b!!0):d 1b
a!b|k<- \x y->last$' ':[a|b!!x!!y>0]=(k 0<$>[0..4]):((\i->k 3(4-i):[a,a,a]++[k 1i])<$>[1..3])++[k 2<$>[4,3..0]]
p y|(e:v)<-m(g.n.cycle.m(read.pure))$"0":(lines$y),[j,k,l,x,y,r]<-x v=mapM putStrLn$f(u z)$f(z(u id))<$>z(z(!))[a,"▒█▒█",a][[e,k,e,e],[l,j,x,r],[e,y,e,e]];a=" ░  "
x(p:q)=[p:u|x<-permutations q,u@[e,g,y,k,l]<-sequence$(\c->nub$[c,r.m r$c]>>=g.m g.tails.cycle)<$>x,and$zipWith4(\a n b m->all(==1).init.d 1$z(+)(a!!n)$r$b!!m)([l,e,p,p,p,p,e]++u)[3,3,0,3,1,2,0,1,2,2,2,1](y:g:u++[y,k,k,l,g])[1,0,2,1,3,0,0,0,3,1,2,3]++z((((==1).sum.m(!!0)).).z(!!))[[p,e,g],[y,p,e],[k,p,g],[k,p,y],[l,y,e],[l,y,k],[l,g,e],[l,g,k]][[0,3,1],[0..2],[0,3,2],[1..3],[0,1,1],[3,2,2],[1,0,0],[2,3,3]]]!!0

That's a mouthful. Usage:

*Main> mapM_ (\s->p s>>putStrLn"")["0010010101010101\n0010001011011010\n0101001001010010\n0010110100101101\n0010110110101101\n0010001011010101","0001110110101101\n1010010111011101\n0101010101010010\n1010001000100011\n1010001001010001\n0110010100100010","0101001011011010\n0010001000100010\n0101001011010010\n0101010101011010\n0101101001011101\n1010001001011101"]
     ░ ░
     ░░░
    ░░░░░
     ░░░
▒▒ ▒▒░█░▒▒ ▒█ █
 ▒▒▒█████▒▒▒█████
▒▒▒▒▒███▒▒▒▒▒███
 ▒▒▒█████▒▒▒█████
  ▒ ░█░█▒▒ ▒▒ █ █
    ░░░░
     ░░░░
    ░░░░
     ░ ░

      ░
     ░░░░
    ░░░░
     ░░░░
▒▒ ▒▒░░██ ▒ ▒█ █
▒▒▒▒█████▒▒▒▒███
 ▒▒▒▒███▒▒▒▒▒████
▒▒▒▒█████▒▒▒████
▒▒ ▒█░█░█ ▒ █ █
     ░░░░
    ░░░░
     ░░░░
     ░ ░

    ░░ ░
    ░░░░░
     ░░░
    ░░░░░
  ▒ ▒█░█░ ▒ ▒ █
▒▒▒▒▒███▒▒▒▒▒███
 ▒▒▒█████▒▒▒█████
▒▒▒▒▒███▒▒▒▒▒███
 ▒ ▒██░██ ▒   █
     ░░░░
    ░░░░
     ░░░░
    ░░ ░░

Some of the examples have more than one solutions, that's why some of the outputs look different. Ungolfed:

import Data.List (nub, transpose, (\\))
import Control.Monad (guard)

newtype CubePiece = CubePiece [[Int]] deriving Eq
newtype Solution = Solution [CubePiece]

side :: Int -> CubePiece -> [Int]
side n (CubePiece c) = c!!n

corner :: Int -> CubePiece -> Int
corner n (CubePiece c) = head $ c!!n

strToCube str = CubePiece $ hs' . (\x@(a:_)->x++[a]) $ l
  where
    l = map (read.pure) str
    hs' [a] = []
    hs' x = take 5 x : hs' (drop 4 x)

orientations :: CubePiece -> [CubePiece]
orientations (CubePiece cube) = map CubePiece $ nub $ (take 4 . iterate rotate $ cube) ++
  (take 4 . iterate rotate . reverse . map reverse $ cube)
  where
  rotate (a:as) = as++[a]

sideFits ::  (CubePiece, Int) -> (CubePiece, Int) -> Bool
sideFits (c1,n1) (c2,n2) = case (zipWith (+) a b) of
  [_,1,1,1,_] -> True
  _ -> False
  where
  a = side n1 c1
  b = reverse $ side n2 c2

cornerFits :: (CubePiece, Int) -> (CubePiece, Int) -> (CubePiece, Int) -> Bool
cornerFits (c1,n1) (c2,n2) (c3,n3) = a + b + c == 1
  where
  a = corner n1 c1
  b = corner n2 c2
  c = corner n3 c3

printSolution str = putStrLn . specialUnlines . map rivi $
  [[empty,gshow '░' c2,empty,empty],[gshow '▒' c3,gshow '█'c1,gshow '▒'c4,gshow '█'c6],[empty,gshow '░'c5,empty,empty]]
  where
  Solution [c1,c2,c3,c4,c5,c6] = solve . map strToCube . lines $ str
  empty = replicate 5 "     "
  rivi = map (foldl1 specialConcat) . transpose
  specialUnlines = unlines . foldl1(\a b->init a++[zipWith max(last a)(head b)]++tail b)
  specialConcat a b
    | last a==' '=init a++b
    | otherwise = a++tail b

gshow char (CubePiece c) =
  [ map (k 0) [0..4]
  , (k 3 3) : m ++ [(k 1 1)]
  , (k 3 2) : m ++ [(k 1 2)]
  , (k 3 1) : m ++ [(k 1 3)]
  , map (k 2)[4,3..0]
  ]
  where
  k n1 n2 = if (c!!n1)!!n2 == 1 then char else ' '
  m=replicate 3 char

solve :: [CubePiece] -> Solution
solve pieces = Solution $ head $ do
  let c1' = pieces!!0
  let c1 = c1'

  c2'  <- pieces \\ [c1']
  c2   <- orientations c2'
  guard $ sideFits (c1,0) (c2,2)

  c3'  <- pieces \\ [c1',c2']
  c3   <- orientations c3'
  guard $ sideFits (c1,3) (c3,1)
  guard $ sideFits (c2,3) (c3,0)
  guard $ cornerFits (c1,0) (c2,3) (c3,1)

  c4'  <- pieces \\ [c1',c2',c3']
  c4   <- orientations c4'
  guard $ sideFits (c1,1) (c4,3)
  guard $ sideFits (c2,1) (c4,0)
  guard $ cornerFits (c1,1) (c2,2) (c4,0)
  c5' <- pieces \\ [c1',c2',c3',c4']
  c5 <- orientations c5'
  guard $ sideFits (c1,2) (c5,0)
  guard $ sideFits (c4,2) (c5,1)
  guard $ sideFits (c3,2) (c5,3)
  guard $ cornerFits (c5,0) (c1,3) (c3,2)
  guard $ cornerFits (c5,1) (c1,2) (c4,3)

  c6' <- pieces \\ [c1',c2',c3',c4',c5']
  c6 <- orientations c6'
  guard $ sideFits (c6,0) (c2,0)
  guard $ sideFits (c6,1) (c3,3)
  guard $ sideFits (c6,2) (c5,2)
  guard $ sideFits (c6,3) (c4,1)
  guard $ cornerFits (c6,0) (c4,1) (c2,1)
  guard $ cornerFits (c6,3) (c4,2) (c5,2)
  guard $ cornerFits (c6,1) (c3,0) (c2,0)
  guard $ cornerFits (c6,2) (c3,3) (c5,3)
  return $ [c1,c2,c3,c4,c5,c6]

main = mapM_ printSolution ["0010010101010101\n0010001011011010\n0101001001010010\n0010110100101101\n0010110110101101\n0010001011010101","0001110110101101\n1010010111011101\n0101010101010010\n1010001000100011\n1010001001010001\n0110010100100010","0101001011011010\n0010001000100010\n0101001011010010\n0101010101011010\n0101101001011101\n1010001001011101"]


Regex - Match half of the strings Okay, the challenge is that you have to write a regex that matches half of all strings.

Some rules to clarify:

For ANY string length(>0), if I permute all strings(of that length), exactly half of them should be matched. Put more lightly, if I generate a random string of that length it should have a 50% chance of being matched. (this means that you cannot just match all even-length strings)

You may assume that strings contain only A-Z, a-z, and 0-9.

0 length strings are undefined, you can choose to either match them or not.

Shortest regex wins.

6

/^[5-Z]/

In ASCII's order, there's 0-9 then A-Z then a-z
So Half of the string begin with 5-Z, the other half doesn't.


Longest Sublist with Equal Occurrences Given a non-empty list of integers between 1 and 9 inclusive, find the longest contiguous sublist such that the number of occurrences of each element (of the sublist) within the sublist is equal (not the number of consecutive occurrences, just the total count). You may return any non-empty subset of the solutions.
Examples
Input                         ->  Output

1, 2, 3                           [1, 2, 3]
1, 2, 2, 3, 3, 4                  [2, 2, 3, 3]
1, 2, 3, 3, 4, 4, 3, 3, 2, 1      [3, 3, 4, 4], [3, 4, 4, 3], [4, 4, 3, 3]
1, 1, 1, 1, 1                     [1, 1, 1, 1, 1]
1, 2, 3, 2, 1                     [1, 2, 3], [3, 2, 1]
1, 2, 3, 4, 4, 3                  [1, 2, 3, 4], [3, 4, 4, 3]
3, 2, 3, 4, 4, 3                  [3, 4, 4, 3]

this is code-golf, so the shortest code in bytes wins
Standard Loopholes are forbidden, as usual
I/O may be in any reasonable format. You can do I/O with a string of digits since all inputs will be between 1 and 9, for example (this is mostly to allow regex solutions if anyone can figure that out).

Jelly, 8 7 bytes
ẆĠẈEƊƇṪ

Try it online!
How it works
ẆĠẈEƊƇṪ - Main link. Takes L on the left
Ẇ       - All non-empty contiguous sublists of L, longest last
    ƊƇ  - Keep those sublists S for which the following is true:
 Ġ      -   Group the indices of S by the elements
  Ẉ     -   Length of each
   E    -   All equal?
      Ṫ - Get the last (i.e. the longest) element


How to code colors in hex Hexagonal tessellations, or tilings of the plane, are three-colorable -- meaning that using only three colors, such as Red, Blue, and Green, every hexagon can be colored without any two hexagons that share a border sharing a color. A partial example showing such a pattern.

Given a partial hexagonal tiling in ASCII (via STDIN, reading from a file, etc.), change the characters' colors (via ANSI codes, image manipulation, etc.) to fit this coloring. The twist is the middle of the hexagons (the *, below) are the three colors, and the lines between need to be a mix of their two corresponding hex's * colors. If the line is on the outside border, it should match the corresponding *.

For example, given the partial hexagonal tiling of

 / \ / \ / \ / \
| * | * | * | * |
 \ / \ / \ / \ /
  | * | * | * |
   \ / \ / \ /

suppose we decide to color the top-left hex * to be Red, and its two neighbors to be Blue and Green (going clockwise). Then the | line needs to be Magenta and the / line needs to be Yellow. If we keep coloring, we'll eventually end up with something like this (enlarged for clarity):

Or, for an input of

     / \
    | * |
   / \ /
  | * |
 / \ /
| * |
 \ /

you might color it like so (enlarged for clarity):

A few additional test cases (your code should be able to handle these):

 / \ / \
| * | * |
 \ / \ /
  | * |
 / \ / \
| * | * |
 \ / \ /

 / \
| * |
 \ / \
  | * |
 / \ /
| * |
 \ /

 / \
| * |
 \ /

Rules

The input is guaranteed to have at least one hexagon, and no input will have a "hole."
You don't need to start your coloring with Red, so long as you maintain the three-color rule.
If the partial tiling can be two-colored, you can do so without penalty (such as in the second example) - you don't necessarily need to extrapolate the partial tiling to a full tiling.
The hexagon centers * must be colored with either Red, Blue, or Green, while the lines between must be either Cyan, Yellow, or Magenta. For example, having a Magenta * is not allowed, and a Red | or \ or / must be on the outside border of the drawing. See Colors, below.
If your console doesn't have these exact colors, please use the closest approximation and specify in your answer what approximation you're using.
Leading or trailing whitespace, including trailing newlines, are acceptable so long as the characters line up.
The partial tiling can be input with space-padding to form a rectangle, if that makes it easier for your code.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
Output can be to the console, saved as an image, etc.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Colors and Color Mixtures:

The three available base colors are (with color codes in RGB decimal format):

Red (255,0,0)
Green (0,255,0)
Blue (0,0,255)

The combinations are:

Red and Green combine to make Yellow (255,255,0)
Blue and Green combine to make Cyan (0,255,255)
Red and Blue combine to make Magenta (255,0,255)

JavaScript (ES6), 219 203 201 bytes

f=
s=>s.split`
`.map((b,i,a)=>b.replace(/./g,(c,j)=>`((a[x+i]||``)[b=y+j]==`*`&&15<<b%3*4)|(y<0?8<<9:g(x,y-2)),(g(0,2)|g(-1,1)|g(1,1)).toString(16).slice(1)}>${c}`)).join`
`
<input type=button value="Colourise!" onclick=i.innerHTML=f(i.textContent)>

 / \ / \
| * | * |
 \ / \ / \
  | * | * |
 / \ / \ / \
| * |   | * |
 \ / \ / \ / \
  | * | * | * |
 / \ / \ / \ /
| * | * |
 \ / \ /

Explanation: Each character is wrapped in a font tag to set its colour, which is calculated by checking each square, plus the squares two to the left and right, plus the four squares one away diagonally, for *s and if so combining the colours of all *s found. The * colours are chosen simply by taking their horizontal coordinate modulo 3 and shifting a bitmask appropriately. Edit: Saved 2 bytes by switching from #RRGGBB to #RGB colours.


Hello world! with limited character repetition In a language of your choice, write a program that exactly outputs the characters Hello world! followed by a newline. The code:

should not use any character more than twice (alphanumeric, symbol, whitespace...anything)
should not use any external resources
should not use any user input
should not output anything else

An example of a valid python program:

print("He%so world!"%(2*'l'))

An example of an invalid python program (the character 'r' is used three times):

print("Hel"+chr(108)+'o world!')

Winner is whoever has the most votes after 14 days.

EDIT:  A winner has been chosen!  Thanks all for your work on this question!

Ruby (1.9+)

Since this is a popularity contest let's try to not use ANY of the characters from 'Hello world!' while still using other characters only a maximum of two times:

puts("S\107VsbG8gV29ybGQhCg".unpack(?m))

It's 40 chars btw.

Bash

And this one uses unicode magic.

Notes:

While the orignal characters appear elsewhere (unlike the ruby example), the printed string contains only non-ascii characters.
Two from the three spaces are actually tabs, so there are no utf-8 characters that appear more than 2 times
As binary some of the octets do appear more than 2 times, hopefully that's not against the rules. I'm trying to resolve them though.

Code:

echo ' ¡'|iconv -t  asCIi//TRANSLIT

For those who don't have a proper font installed it looks like this:

Here is the hexdump:

00000000  65 63 68 6f 20 27 f0 9d  93 97 f0 9d 90 9e f0 9d  |echo '..........|
00000010  91 99 f0 9d 92 8d f0 9d  93 b8 e2 80 8a f0 9d 93  |................|
00000020  a6 f0 9d 97 88 f0 9d 96  97 f0 9d 96 91 f0 9d 98  |................|
00000030  a5 c2 a1 27 7c 69 63 6f  6e 76 09 2d 74 09 61 73  |...'|iconv.-t.as|
00000040  43 49 69 2f 2f 54 52 41  4e 53 4c 49 54 0a        |CIi//TRANSLIT.|
0000004e

You have to run it on a machine where the default charset is utf-8. I tried on an OSX10.8 using iTerm2 with the following environment:

PHP 5.4

This uses zLib: (unfortunately it does uses the characters e and o)

<?=gzuncompress('x▒▒H▒▒▒W(▒/▒IQ▒!qh');

Hexdump:

00000000  3c 3f 3d 67 7a 75 6e 63  6f 6d 70 72 65 73 73 28  |<?=gzuncompress(|
00000010  27 78 9c f3 48 cd c9 c9  57 28 cf 2f ca 49 51 e4  |'x..H...W(./.IQ.|
00000020  02 00 21 71 04 68 27 29  3b                       |..!q.h');|
00000029

+1

Here is the ruby 2.0 code I used to test for duplicates:

d=ARGF.read
p [d.split(//),d.unpack('C*')].map{|x|x.inject(Hash.new(0)){|i,s|i[s]+=1;i}.select{|k,v|v>2}}


How short can you get? You are to write a program that, when given an integer between 1 and 5 (or 0 and 4 if you wish to use 0-indexing), outputs one of Code, Golf, and, Coding or Challenges. Each input can map to any of the five outputs. However, the mapping must be one to one (each input goes to a different output) and consistent when running the program multiple times.

For example, 1 -> Coding, 2 -> Golf, 3 -> and, 4 -> Code and 5 -> Challenges is a perfectly acceptable mapping. The capitalisation and spelling of the outputs must match, but leading and trailing whitespace is perfectly acceptable.

Rather than code-golf, we will use a different scoring system (lets use abcdef as an example program):

If your program works whenever any single (\$1\$) character is removed, your score is \$1\$.

So bcdef, acdef, abdef, abcef, abcdf and abcde should all work as program on their own
By "work", I mean that the program still fulfils the first two paragraphs of this challenge spec. The 5 possible inputs may be different to the unaltered program, and to each of the other altered programs, so long as they meet the rules above.

If your program still works whenever any pair (\$2\$) of consecutive characters are removed, your score is \$2\$

So, to qualify for a score of \$2\$, abcd, abcf, abef, adef and cdef must all work according to the challenge spec

And so on. If your program still works whenever any subset of length \$n\$ of consecutive characters is removed from it, your score is \$n\$.

The program with the largest \$n\$ wins. In order to compete, all programs must have a score of at least \$1\$. Your program must work for all \$i \le n\$ in order to qualify for a score of \$n\$. So in order to score \$5\$, your program must also score \$1, 2, 3\$ and \$4\$.

This is a Python program which will output all the possible alterations to your original program, along with the score they're worth.

8086 machine code (MS-DOS .COM), score 26 402

The file is 52 947 bytes long. The length was a product of what produced benign instruction sleds, and the maximum file size for .COM files (65 280 bytes -- 65 264 in case an interrupt happens before you can stop it).

Here in binary form, with repeating lines snipped out for obvious reasons:

00000000 : E9 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 : .ggggggggggggggg
00000010 : 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 : gggggggggggggggg
    <...>
00006720 : 67 67 67 67 67 90 D1 EE AD 93 AC E8 00 00 5A 2C : ggggg.........Z,
00006730 : 30 01 C2 3C 04 75 03 83 C2 02 D1 E0 D1 E0 01 C2 : 0..<.u..........
00006740 : 83 C2 1B B4 09 CD 21 CD 20 43 6F 64 65 24 47 6F : ......!. Code$Go
00006750 : 6C 66 24 61 6E 64 24 24 43 6F 64 69 6E 67 24 43 : lf$and$$Coding$C
00006760 : 68 61 6C 6C 65 6E 67 65 73 24 EB 9F 9F 9F 9F 9F : hallenges$......
00006770 : 9F 9F 9F 9F 9F 9F 9F 9F 9F 9F 9F 9F 9F 9F 9F 9F : ................
    <...>
0000CE80 : 9F 9F 9F 9F 9F 9F 9F 9F 9F 9F 9F 9F 9F 9F 9F D1 : ................
0000CE90 : EE AD 93 AC E8 00 00 5A 2C 30 01 C2 3C 04 75 03 : .......Z,0..<.u.
0000CEA0 : 83 C2 02 D1 E0 D1 E0 01 C2 83 C2 1B B4 09 CD 21 : ...............!
0000CEB0 : CD 20 43 6F 64 65 24 47 6F 6C 66 24 61 6E 64 24 : . Code$Golf$and$
0000CEC0 : 24 43 6F 64 69 6E 67 24 43 68 61 6C 6C 65 6E 67 : $Coding$Challeng
0000CED0 : 65 73 24                                        : es$

In readable form:

org 0x100
cpu 8086

SLED_LEN    equ (0x6767 - (part1_end - part1) + 2)

db 0xe9
times SLED_LEN db 0x67

part1:
    nop
    shr si, 1       ; SI = 0x80
    lodsw           ; SI = 0x82
    xchg bx, ax     ; AX = 0
    lodsb           ; AL = first character of command line argument

    ; Load DX with IP, since we only know our strings' relative position
    call near .nextline
.nextline:
    pop dx

    sub al, '0'
    add dx, ax
    cmp al, 4
    jne .skip
    add dx, 2

.skip:
    shl ax, 1
    shl ax, 1
    add dx, ax

    add dx, 0x1b
    mov ah, 0x09
    int 0x21
    int 0x20

p1_msg0 db "Code$"
p1_msg1 db "Golf$"
p1_msg2 db "and$$"
p1_msg3 db "Coding$"
p1_msg4 db "Challenges$"

part1_end:

part2:
    db 0xeb
    times SLED_LEN db 0x9f

    shr si, 1       ; SI = 0x80
    lodsw           ; SI = 0x82
    xchg bx, ax     ; AX = 0
    lodsb           ; AL = first character of command line argument

    ; Load DX with IP, since we only know our strings' relative position
    call near .nextline
.nextline:
    pop dx

    sub al, '0'
    add dx, ax
    cmp al, 4
    jne .skip
    add dx, 2

.skip:
    shl ax, 1
    shl ax, 1
    add dx, ax

    add dx, 0x1b
    mov ah, 0x09
    int 0x21
    int 0x20

p2_msg0 db "Code$"
p2_msg1 db "Golf$"
p2_msg2 db "and$$"
p2_msg3 db "Coding$"
p2_msg4 db "Challenges$"

Rundown

This is a slightly adapted variation on a previous answer of mine.

The active part is duplicated so that there is always one untouched by radiation. We select the healthy version by way of jumps. Each jump is a near jump, and so is only three bytes long, where two last bytes are the displacement (i.e. distance to jump, with sign determining direction). This displacement is replicated over and over, forming a long NOP sled of sorts.

We can divide the code into four parts which could be irradiated: jump 1, code 1, jump 2, and code 2. The idea is to make sure a clean code part is always used. If one of the code parts is irradiated, the other must be chosen, but if one of the jumps is irradiated, both code parts will be clean, so it will not matter which one is chosen.

The reason for having two jump parts is to detect irradiation in the first part by jumping over it. If the first code part is irradiated, it means we will arrive off mark, somewhere in the second NOP sled. If we make sure that such a botched landing selects code 2, and a proper landing selects code 1, we're golden.

For both jumps, we duplicate the displacement word, making each jump part one opcode followed by a massive repetition of the displacement. This ensures that irradiation somewhere in the sled will still make the jump valid, as long as at least two bytes of the sled remains. Irradiation in the first byte will stop the jump from happening at all, since the following sled will form a completely different instruction.

Take the first jump:

E9 67 67 67 67 ...      jmp +0x6767 / dw 0x6767 ...

If either of the 0x67 bytes are removed, it will still jump to the same place, as long as at least one word remains. If the 0xE9 byte is removed, we will instead end up with

67 67 67 67...

each of which is a address-size override prefix. The CPU will gladly chomp them all down, and then we fall through to code 1, which must be clean, since the damage was in jump 1.

If the jump is taken, we land at the second jump:

EB 9F 9F 9F 9F ...       jmp -0x61 / db 0x9f

If this byte sequence is intact, and we land right on the mark, that means that code 1 was clean, and this instruction jumps back to that part. The replicated displacement byte guarantees this, even if it is one of these displacement bytes that were damaged.

The astute reader will notice that this instruction jumps too far back, but that's alright, since if we hit the jump, then part1's NOP sled must be wholly intact, making a slightly longer jump backwards okay.

If we either land off the mark (because of a damaged code 1 or jump 1) or the 0xEB byte is the damaged one, the remaining bytes will also here be benign:

9F 9F 9F 9F ...          lahf / lahf

Whichever the case, if we end up executing that sled of instructions, we know that either jump 1, code 1, or jump 2 were irradiated, which makes a fall-through to code 2 safe.

Testing

Testing proved problematic. I've done some tests on certain corner-cases and a few random ones, but I have to find a better way for exhaustive testing. It should not be a problem up to the above-mentioned score.

The following program was used to automatically create all versions of the .COM file for a certain gap size. It also creates a BAT file that can be run in the target environment, which runs each irradiated binary, and pipes their outputs to separate text files. Comparing the output files to validate is easy enough, but DOSBox does not have fc, so it was not added to the BAT file.

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

int main(int argc, char **argv)
{
    FILE *fin, *fout, *fbat;
    int fsize;
    char *data;
    int gapsize = 1;

    if (!(fin = fopen(argv[1], "rb")))
    {
        fprintf(stderr, "Could not open input file \"%s\".\n", argv[1]);
        exit(1);
    }

    if (!(fbat = fopen("tester.bat", "w")))
    {
        fprintf(stderr, "Could not create BAT test file.\n");
        exit(2);
    }

    if (argc > 2)
    {
        gapsize = atoi(argv[2]);
    }

    fseek(fin, 0L, SEEK_END);
    fsize = ftell(fin);
    fseek(fin, 0L, SEEK_SET);

    if (!(data = malloc(fsize)))
    {
        fprintf(stderr, "Could not allocate memory.\n");
        exit(3);
    }

    fread(data, 1, fsize, fin);

    fprintf(fbat, "@echo off\n");

    for (int i = 0; i <= fsize - gapsize; i++)
    {
        char fname[512];

        sprintf(fname, "%06d.com", i);

        for (int j = 0; j < 5; j++)
            fprintf(fbat, "%s %d >> %06d.txt\n", fname, j, i);

        fout = fopen(fname, "wb");

        fwrite(data, 1, i, fout);
        fwrite(data + i + gapsize, 1, fsize - i - gapsize, fout);

        fclose(fout);
    }

    free(data);
    fclose(fin);
    fclose(fbat);
}


Swapping "Good" and "Bad" Challenge Description:

Write a program that asks the user for input. The user will enter Good or Bad. You do not have to support any other input. If the user enters Good, print Bad and vice versa (to stdout etc).

Notes:

1) You cannot use any other pair of two words.

2) Your program only has to ask and print once.

3) You do not need to display prompt string.

4) The output must appear separated from the input by any means.

5) No function is allowed accepting the value and returning the result; User must interact with the program.

Good luck!

Python 3,  32  31 bytes

exit('GBoaodd'['G'<input()::2])

Try it online!

How?

Tests if input is 'Good' by comparing 'G'<input().

Uses the fact that in Python False==0 and True==1 to use the result as the start index of a slice of 'GBoaodd' using an undefined stop and a step of 2 with 'GBoaodd'[start:stop:step].

Prints to STDERR (saving a byte with exit in place of print).


Check if computer is connected to the internet Write a program which, according to whether the script has access to the internet, produces an output which is "Truthy/Falsey". You may try and connect to any existing site, at your own discretion (don't use a shady site which only has 10% uptime - try to keep to above 80% annual uptime). If the site is down, your program does not have to work.

It must be a standalone program or a function. You may use libraries outside of the standard library to achieve this. Standard loopholes are forbidden. This is code golf, so the code with the shortest byte-count wins.

Example pseudocode:

function a:
    try:
        connect to internet
        return 1
    catch error:
        return 0

This is my first post on code golf, so if this violates any rules in any way or is a dupe, please alert me.

EDIT: Due to numerous suggestions, I have removed the UTF-8 byte count restriction

Bash (with dnsutils), 3 bytes
Sends a DNS request for "." (DNS root), exit code is 0 for success and >0 otherwise.
Golfed
dig

Test
% dig >/dev/null; echo $?;
0

% nmcli nm wifi off
% dig >/dev/null; echo $?;
9

Disclaimer
This will obviously only work if your DNS server is sitting in the provider's network, i.e. in the "Internet" (as your provider network is normally a part of it), or if your system is using a public DNS server (like 8.8.8.8 from Google, which Android based systems use), as otherwise, you can get a cached copy from a local LAN server (or localhost).
But I assume this is not against the code-golf rules, as there are obviously more than one system where this does work as intended.
Pure-HTTP methods can also give false positives, due to an intermediate caching proxy, and are not guaranteed to work everywhere, so that is not something unique to this method.
A slightly more reliable version, 8 bytes
dig +tra

(a little tribute to @Digital Trauma !)
Enables the "trace mode", which will force dig to do the recursive search by itself (see https://serverfault.com/a/778830), avoiding any cache issues.


Inverse of Conway base 13 function in \$\mathbb{Q}\$ (The \$\mathbb{Q}\$ in the title means rational numbers.)

Background

Conway base 13 function is an example of a strongly Darboux function, a function that takes every real number on any open interval \$(a,b)\$. In other words, for any given real numbers \$a, b, y\$, you can find a value \$x\$ between \$a\$ and \$b\$ such that \$f(x) = y\$.

The function is defined as follows:

Write the input value x in base 13 using thirteen symbols 0 .. 9, A, B, C, without any trailing infinite stream of Cs. (It is related to the fact 0.9999... = 1 in base 10, or 0.CCC... = 1 in base 13.)
Delete the sign and decimal point, if present.
Replace As with +, Bs with -, Cs with ..
Check if some (possibly infinite) suffix of the sequence starts with a sign (+ or -) and contains exactly one . and no extra signs. If such a suffix exists, interpret it as a decimal number; it is the value of \$f(x)\$. Otherwise, \$f(x) = 0\$.

Some examples:

\$f(123B45.A3C14159\dots _{13}) = f(0.A3C14159\dots _{13}) = 3.14159\dots \$
\$f(B1C234 _{13}) = -1.234\$
\$f(1C234A567 _{13}) = 0\$

Task

Given three rational numbers \$a = \frac{a_n}{a_d}, b = \frac{b_n}{b_d}, y = \frac{y_n}{y_d}\$ given as integer fractions, find a value of \$x = \frac{x_n}{x_d}\$ between \$a\$ and \$b\$ (exclusive) such that \$f(x) = y\$ (where \$f\$ is the Conway base 13 function). There are infinitely many values of \$x\$ that satisfy the condition for any input; just output one of them.

You can assume \$a < b\$, \$a_d, b_d, y_d > 0\$, \$y \ne 0\$, and the fractions are given in the reduced form. Negative input numbers are represented using negative numerators. You don't need to reduce the output fraction.

Standard code-golf rules apply. The shortest code in bytes wins.

Examples

a = 0/1, b = 1/1, y = 1/3

Decimal representation of \$y\$ is \$0.\overline{3}\$ (where the overline is the notation for repeating decimal). To get this value, the minimal base-13 suffix of \$x\$ is \$+.\overline{3}\$ or \$AC\overline{3}\$. An example of such an \$x\$ would be \$0.AC\overline{3}_{13} = 569/676\$. Proof by Wolfram|Alpha.

a = 2017/2197, b = 2018/2197, y = -1/5

The minimal base-13 suffix of \$x\$ is \$-.2 = BC2_{13}\$. But the value of a is exactly \$0.BC2_{13}\$, so we can't use that. And the value of b is \$0.BC3_{13}\$, so we're forced to begin with \$0.BC2\$. One possible value of \$x\$ is \$0.BC2BC2_{13} = 4433366 \; / \; 4826809\$.

a = 123/10 = c.3b913b91..., b = 27011/2196 = c.3b93b9..., y = 987/1

One possible answer is \$x = c.3b92a987c_{13} = 130435909031 \; / \; 10604499373\$.

a = -3/2, b = -4/3, y = -1/7

One possible answer is \$x = -1.5bc\overline{142857}_{13} = -28108919 \; / \; 19316024\$.

Python 2, 254 237 219 216 207 bytes
-3 bytes thanks to @KevinCruijssen !
Can save 1 more byte by replacing X=e**(A+B) with X=e**A**B, but the result will be humongous, and the time taken to run will be very long.

e=13
a,A,b,B,y,Y=input()
X=e**(A+B)
x=a*X/A+2
r=abs(y)
s="AB"[y<0]+`r/Y`+"C"
R=[]
exec"R=[r]+R;r=r%Y*10;s+=`r/Y`;"*-~Y
n=~R.index(r)
T=e**-n-1
S=e**len(s)*T
print(int(s,e)*T+int(s[n:],e))*((x>0)*2-1)+x*S,X*S

Try it online! or Check all test cases!
A program that takes in 6 integers from STDIN, and prints out the numerator and denominator of the result.
Big idea

First, find a number \$c\$ such that \$a < c < b\$ and \$c\$ has finite base-13 representation. Note that \$c\$ should be "sufficiently far away" from \$a\$ and \$b\$. This will be the prefix of \$x\$.
For example: \$a = 1.1..._{13}, b = 1.3..._{13}\$ then \$c = 1.2_{13}\$. We say that \$c\$ is sufficiently far away from \$a\$ and \$b\$, since we can add any suffix to \$c\$ and it is guaranteed to stay in the range \$(a,b)\$.

Then find the suffix of \$x\$ by finding the base-10 representation of \$y\$, then replacing +-. with ABC. E.g with \$y = 1/3\$, the suffix is \$+0.(3)=A0C(3)\$

Join the prefix and suffix together. E.g \$x = 1.2A0C(3)\$.

Details
Finding the prefix:
The prefix has the form \$x/X\$, where \$X\$ is a power of 13.
Consider the integers \$\Bigl \lfloor \frac{aX}{A} \Big \rfloor \$ and \$\Bigl \lfloor \frac{bX}{B} \Big \rfloor \$ (where \$X = 13^i\$), which are the truncations of \$a/A\$ and \$b/B\$ to a certain base-13 precision. If there is an integer \$x\$ between those 2 numbers such that \$x\$ is at least 2 away from both numbers, then \$x/X\$ can be the prefix. This is because no matter what suffix is added, the value of \$x/X\$ won't change by more than \$1/X\$.
\$X=13^{A+B}\$ is guaranteed to be large enough to see a large gap between the truncation of \$a/A\$ and \$b/B\$.
This is the part that finds the prefix:
X=e**(A+B)
x=a*X/A+2

Finding the suffix:
First, the long division \$y/Y\$ is performed to find the decimal representation (with repeated digit). r is the current remainder, and R keeps track of the seen remainder after each digit division, in order to detect repeating decimals. \$y/Y\$ is calculated until \$Y+1\$ digits after the decimal point, which is sufficient to detect repeating groups of digits.
r=abs(y)
s="AB"[y<0]+`r/Y`+"C"
R=[]
exec"R=[r]+R;r=r%Y*10;s+=`r/Y`;"*-~Y

The suffix has the form \$stttt... = s(t)\$, where \$s\$ is the result of truncated \$y/Y\$ above, and \$t\$ is the repeating decimals found in \$s\$.
n=~R.index(r)
t = s[n:]

Thus, our result should have the form \$\frac{x + 0.sttt..._{13}}{X}\$ (or \$\frac{x - 0.sttt..._{13}}{X}\$ if \$x\$ is negative)
To convert 0.s(t) in base 13 to fraction, the following formula is used:
$$ 0.s(t) = 0.sttt... = \frac{s.(t)}{13^i} $$
$$ s.(t) = s.ttt... = s + \frac{t}{13^j-1} $$
where \$i, j\$ are the number of digits in \$s, t\$.


Have I had lunch yet? You love lunch. However, you are on a diet and want to make sure you don't accidentally eat lunch twice in one day. So you need to make a program to help you make sure.

However, one complication is that you eat lunch on a very weird schedule. The time you eat lunch at is MONTH:DAY PM (you can use UTC or localized time zone). That's right, if the day is July 14, you eat lunch at 7:14 PM.

For your program, you need to use the current date and time (don't take input), and output a consistent truthy value if you have already eaten lunch for the day (or it is lunch time now), or a consistent falsy value if you haven't.

Examples: (Time you run program => output)

May 4th 11:35 AM => false (you will eat lunch at 5:04 PM)
June 3rd 5:45 PM => false (you will eat lunch at 6:03 PM)
July 28th 8:30 PM => true (you ate lunch at 7:28 PM)
December 15th 3:25 PM => true (you ate lunch at 12:15 PM)
February 29th 2:29 PM => true (it is exactly lunch time)
October 12th 12:00 AM => false (day just started)

Reference:

How a 12 hour clock works

Swift 3, 310 bytes

import Foundation;var n=String(describing:Date());var k=n.startIndex;print(Int(n[n.index(k,offsetBy:5)...n.index(k,offsetBy:6)])!*60+Int(n[n.index(k,offsetBy:8)...n.index(k,offsetBy:9)])!+720<=Int(n[n.index(k,offsetBy:11)...n.index(k,offsetBy:12)])!*60+Int(n[n.index(k,offsetBy:14)...n.index(k,offsetBy:15)])!)

Check it out!
This prints true and false, for truthy and falsy respectively.

NOTE: This only works until the year 9999, at 11:59:59 PM, because it uses Strings to compare the dates.


Quine with prime sourcecode character distribution constraints Your program should take no input, and no network or other connections.
Your program should output it's sourcecode.
The sourcecode must consist of 3 types of characters: Numeric (0-9), Alpha (a-z|A-Z) and symbols !(0-9|a-z|A-Z). Constraints for the distribution of characters is:

3.1. Every neighbouring characters with equal character-type makes a character-group.
3.2. Each character-group length in bytes must be a prime-number (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, ...)
3.3. The total number of character-groups of each character-type must be a neighbouring (but not equal) fibonacci sequence number. For example: 3 groups of numbers, 5 groups of alpha, 8 groups of symbols.
3.4. A character-group of one charater-type cannot be adjacent to another character-group of the same character-type, because that will create one bigger group instead.

Example valid sourcecode (regarding character distribution, it does however not output it's sourcecode):

"."."."aa321'","/hithere' 12345678901,.,.,12345,.,

Character distribution in the example: 2 groups of Alpha. 3 group of numeric. 5 groups of other characters. The numbers 2, 3 and 5 are neighbouring numbers in the fibonacci sequence.

This is code-golf, good luck have fun!

Golfscript, 21 15 characters
11{'aa.~' }aa.~

After removing all NOPs, their images, and the leading 11, this becomes the quine
{`'.~'}.~

reading: block(string(dup, eval)); dup; eval.
Now to shoot for the stars (20 characters - the minimum for 2-3-5) or even galaxies (12 characters - the absolute minimum)  I've taken a short stop at Alpha Centauri B to refuel, now I'm drifting through intergalactic medium. Thanks,  Goldbach's conjecture.
Live: http://golfscript.apphb.com/?c=MTF7J2FhLn4nMTE7fWFhLn4K