text:
Find the numbers and calculate output
Objective
Given an input list of 6 distinct digits, find 3 numbers a, b and c such that a × b = c, with a having 2 digits, b having 1 digit and c having 3 digits. In a more visual way, your program must arrange those 6 digits in the boxes of this image:

If more than one solution exists, you may output any of them.
Input
6 distinct digits. You may take them in any reasonable way for your language.
Output
The 3 numbers a, b and c. The output format is relatively free, as long as the 3 numbers are separated and are always printed in the same order (but not necessarily in the order a, b, c).
Test Cases
1, 2, 3, 4, 5, 6 -> 54,3,162
2, 3, 4, 5, 6, 7 -> 57,6,342 or 52,7,364

Scoring
The shortest code in bytes wins.

That's the first thing I thought off when I saw the challenge too @Dada... I suggest putting it in the sandbox to get some feedback before posting it :-)

Is the input guaranteed to result in a solution?

I have edited the wording of your challenge quite a bit to make it clear (in my opinion). Make sure I didn't change the goal of the challenge.

I also think the challenge needs a more explicit title, but I'm out of ideas right now.

Title suggestion: Arithmetically splitting

I guess I'm not surprised that there are no backtracking algorithms here but I am a little sad.

Should an input of 0,1,2,3,4,5 result in 13,4,052; no solution; or is any behaviour OK?

If multiple solutions exist, may the program output all of them?

Just to extend @JonathanAllan point: should we consider the set of digits [0 .. 9] or [1 .. 9]? Fun fact: my code claims that 14*3==052. Which is true ... if you read 052 as 42 in octal, like JS does (unless it runs in strict mode).

JavaScript (ES6), 90 88 bytes
Takes input as an array of 6 digits. Returns a string describing a possible solution (such as '54*3==162') or exits with a 'too much recursion' error if (and only if) there's no solution.
f=(a,k=1)=>eval(s='01*2==345'.replace(/\d/g,n=>a[n],a.sort(_=>(k=k*2%3779)&2)))?s:f(a,k)

How it works
This is a deterministic algorithm.
The primes P=2 and Q=3779 were chosen in such a way that the sort callback (k = k * P % Q) & 2 is guaranteed to generate all 720 possible permutations of the input array over time. More precisely, all permutations are covered after 2798 sorts -- which should be within the recursion limit of all browsers.
We inject each permutation in the expression 01*2==345 by mapping the digits to the corresponding entries in the array.
We evaluate this expression and do recursive calls until it's true.
Test

f=(a,k=1)=>eval(s='01*2==345'.replace(/\d/g,n=>a[n],a.sort(_=>(k=k*2%3779)&2)))?s:f(a,k)

console.log(f([1,2,3,4,5,6])); // 54*3==162
console.log(f([2,3,4,5,6,7])); // 52*7==364
console.log(f([1,2,3,4,6,7])); // 73*2==146

Assuming the output format is still valid, use - instead of == (and reverse the ?:) to save a byte.

@Neil Actually, I made the same suggestion to zeppelin. I probably should golf it some more as well, but I must admit that I like the current output format.

Did you bruteforce to find 3379, or did you use mathematical reasoning? If so, could provide your way of finding it? :)

@TuukkaX Nothing really fancy here. I just bruteforced it, my criteria being 1) as few digits as possible for P and Q and 2) as few sort iterations as possible.

Brachylog (2), 10 bytes
p~c₃o.k×~t

Try it online!
Far too slow to run in a reasonable length of time (the Brachylog interpreter spends a long time doing multiplications on empty strings, 4-digit numbers, negative numbers etc. using a very slow constraint solver). The TIO link uses an input with only 3 digits (this program can handle input with any number of digits). This is a function whose input is a number containing all the digits required (e.g. 234567) – the lack of duplicates in the input means that you can always just put any 0 at the end to avoid a leading zero – and whose output is a list in the order [b, a, c] (e.g. [6, 57, 342]).
Explanation
p~c₃o.k×~t
p           Permute the digits of the input
 ~c₃        Split them into three groups
    o       Sort the three groups
     .      to produce the output, which must have the following property:
      k     all but the last group
       ×    when multiplied together
        ~t  produces the last group

So where did the requirement on the groups to be 2, 1, and 3 digits go? Well, we know there are 6 digits in the input, and the groups are in sorted orders. The only possible sizes they can have, therefore, are [1, 1, 4], [1, 2, 3], or [2, 2, 2]. The first case is impossible (you can't multiply two 1-digit numbers to produce a 4-digit number, as 9×9 is only 81), as is the last case (you can't multiply two 2-digit numbers to produce a 2-digit number, as even 10×10 produces 100). Thus, the return values [b, a, c] must be 1, 2, and 3 digits long in that order, so a is 2 digits, b is 1 digit, and c is 3 digits, as requested.

Well...I surrender

Brachylog, 17 bytes
p~c[Ċ,I,Ṫ]cᵐ.k×~t

Try it online!
Explanation
p                   Try a permutation of the Input
 ~c[Ċ,I,Ṫ]          Deconcatenate it; the result must be a list of the form [[_,_],_,[_,_,_]]
          cᵐ.       Output is the list of integers you get when mapping concatenate on the
                      previous list
             k×~t   The first two ints of the Output, when multiplied, result in the third
                      int of the Output

05AB1E, 15 13 bytes
Saved two bytes thanks to Emigna!
œJvy3L£Â`*Qi,

Uses the CP-1252 encoding. Try it online!
Explanation:
œ                 # Get all permutations of the input
 J                # Join them to get the numbers
  vy              # For each element in the list..
    3L            #   Push the list [1, 2, 3]
      £           #   Pops a and pushes [a[0:1], a[1:3], a[3:6]]
       Â`         #   Bifurcate and flatten
         *        #   Multiply the top two elements in the stack
          Qi      #   If equal to the third element..
            ,     #     Print the array

You can replace 213S with 3L as the order didn't have to be 2,1,3 according to the specs.

Good to know that £ cumulatively vectorizes... If that's the correct way to say that.

Bash + coreutils, 70
for((b=1;b;));{
a=`shuf -ze $@`
b=${a:0:2}*${a:2:1}-${a:3:3}
}
echo $b

No particularly easy way to generate all the permutations.  Instead randomly generate permutations and calculate until we find a good one.
Output is in the form A*B-C - i.e. the expression that will evaluate to zero when we have the correct permutation.
Try it online.

CJam, 23 bytes
qm!{3/)2/+:i}%{(\:*=}=p

Try it online!

Python 2, 105 bytes
lambda s:[(x[0],x[1:3],x[3:])for x in permutations(s)if eval('%s*%s%s==%s%s%s'%x)]
from itertools import*

Try it online!
88 bytes solution with a more flexible output
lambda s:[x for x in permutations(s)if eval('%s*%s%s==%s%s%s'%x)]
from itertools import*

Try it online!
where the output would be ['6', '5', '7', '3', '4', '2'] instead '6', '57', '342'

You didn't put your import at the top... shakes head

@mbomb007 gotta work on TIO ¯\(ツ)/¯

You're the first person I've seen who actually put the f= in the header. It's not a big deal.

PHP, 110 bytes
It'll get there... eventually...
<?$v=$argv;unset($v[0]);do shuffle($v)&[$a,$b,$c,$d,$e,$f]=$v;while("$a$b"*$c!="$d$e$f");echo"$a$b $c $d$e$f";

Ungolfed:
<?
$v=$argv;
unset($v[0]);
do
  shuffle($v);
  [$a,$b,$c,$d,$e,$f]=$v;
while("$a$b"*$c!="$d$e$f");
echo"$a$b $c $d$e$f";

PHP, 77 bytes
for(;;)eval(strtr('0.*1-"428"||die("0.,1,428");',1/7,str_shuffle($argv[1])));

Takes input as a string.

Pip, 18 bytes
17 bytes of code, +1 for -S flag.
$/_=1FI_^@3,5MPMa

Takes input as a string of digits via command-line argument. Output is in the order c, b, a. Try it online!
This code outputs all solutions if multiple exist. If it is required to output only one solution, then add three bytes and wrap the program in (...0).
Explanation
                   a is 1st cmdline arg (implicit)
              PMa  Compute all permutations of a
             M     To each, map this function:
          3,5       Range(3,5)--contains values 3 and 4
       _^@          Split the function argument at those indices
                    This transforms a string like 342657 into a list [342; 6; 57]
     FI            Now filter the list of split permutations on this function:
$/_                 Fold on division: takes 1st element and divides it by the rest
   =1               Compare the quotient with 1
                    This keeps only the permutations where the first number is the product
                    of the other two
                   Autoprint the list (implicit), with each sublist on a separate line
                   and space-separated (-S flag)

Ruby, 60 bytes
->x{x.permutation{|a|(eval a="%d%d*%d==%d%d%d"%a)&&puts(a)}}

Prints all solutions as "a*b==c"
Example:
->x{x.permutation{|a|(eval a="%d%d*%d==%d%d%d"%a)&&puts(a)}}[[1,2,3,4,5,6]]
54*3==162

->x{x.permutation{|a|(eval a="%d%d*%d==%d%d%d"%a)&&puts(a)}}[[2,3,4,5,6,7]]
52*7==364
57*6==342

ES6 (Javascript), 85, 82, 79 bytes
Accepts an array of digits (strings), returns a 3-element array [A,B,C] =>  C=A*B
Golfed
R=(w,[a,b,c,d,e,f]=w)=>f*(d+=e)^(a+=b+c)?R(w.sort(_=>Math.random()-.5)):[a,d,f]

EDITS:

Saved 3 more bytes by reusing d and a, and getting rid of == (Thanks @Arnauld !)
Saved 3 bytes using destructuring assignment

Try It !

R=(w,[a,b,c,d,e,f]=w)=>f*(d+=e)^(a+=b+c)?R(w.sort(_=>Math.random()-.5)):[a,d,f];

function generate(A) {
   console.log(R([...A]));
}
<input type="text" id="A" value="123456"/><button onclick="generate(A.value)">GENERATE</button>

Can you guarantee that your random sort will actually cover all permutations?

@Neil, if you are looking for strict formal proof, I don't think I can provide you with one, but empirically it does result in a pretty much uniform distribution of permutations.

Batch, 305 bytes
@echo off
set/pd=
for /l %%i in (0,1,719)do set n=%%i&call:c
exit/b
:c
set t=%d%
set s=
for /l %%j in (6,-1,1)do set/ap=n%%%%j,n/=%%j&call:l
set s=%s:~0,2%*%s:~2,1%-%s:~3%
set/an=%s%
if %n%==0 echo %s%
exit/b
:l
call set u=%%t:~%p%%%
call set s=%%s%%%%u:~,1%%
call set t=%%t:~,%p%%%%%u:~1%%

Takes input on STDIN as a string [1-9]{6} and outputs all solutions in dd*d-ddd format. Batch isn't very good at string manipulation so generating the 720 permutations is a little awkward.


text:
Recursive string substitution
The task
Write a program or function that given three strings A, B, C produces an output string where each instance of B in A has been recursively substituted with C.
Recursively substituting means repeating a substitution where at each step all non-overlapping instances of B in A (chosen greedily from left to right) are replaced with C until B is no more contained in A.
Input/Output

You may use any of the default methods for I/O.
Strings will contain only printable ASCII characters (and may contain any of them) .
B will never be an empty string, while A and C might be.
Strings are to be considered plaintext, you can't for example treat B as a Regex pattern.
Some combinations of inputs will never terminate. Your program can do anything in those cases.

Test cases
These are in the format: A/B/C\nOutput
Hello, world!/world!/PPCG
Hello, PPCG

Uppercase is up/up/down
Uppercase is down

ababababa/aba/ccc
cccbcccba

delete/e/{empty string}
dlt

{empty string}/no/effect
{empty string}

llllrrrr/lr/rl
rrrrllll

+-+-+-+/+-+/+
+

ababababa/aba/bada
badabbadbada

abaaba/aba/ab
abb

((())())())/()/{empty string}
)

Examples that don't terminate:
grow/ow/oow

loop/lo/lo

Another test case: ((())())())/()/

@ConorO'Brien added

At first, I failed to make it case-sensitive. downpercase is down

05AB1E, 2 bytes
`:

Try it online!
Explanation
`    # split input to stack
 :   # replace (until string doesn't change)

This could be : for 1 byte if we didn't have to deal with empty strings.

If I understand it correctly, your 4-byte solution is valid. "Some combinations of inputs will never terminate. Your program can do anything in those cases."

@Leo. Right you are. I skimmed over that part :)

So basically : is a builtin that solves the whole challenge? I should have banned builtins ;)

@Leo: If it weren't for the empty strings a single built in would solve this yes. And the only difference with empty strings is that we need to specify that there are 3 inputs, which otherwise would be implicitly inferred by the operation :)

Is something like this also possible?

@Adnan: Ah yes. I didn't notice that input format was flexible. Thanks :)

Python 2, 43 bytes
lambda s,*l:eval('s'+'.replace(*l)'*len(s))

Try it online!
Evaluates a string of the form
s.replace(*l).replace(*l).replace(*l) ...

To reach a fixed point if one exists, it suffices to do replacements equal to the length of the original string.

ES6 (Javascript), 47, 43 bytes

Saved 4 bytes using currying (Thanks @Neil !)

Golfed
c=>b=>R=a=>(x=a.split(b).join(c))==a?x:R(x)

Try It

Q=c=>b=>R=a=>(x=a.split(b).join(c))==a?x:R(x)

function doit() {
  console.log(Q(C.value)(B.value)(A.value));
}
A: <input type="text" value="abaaba" id="A"/> B: <input type="text" value="aba" id="B"/> C: <input type="text" value="ab" id="C"/> <input type="submit" onclick="doit();" value="REPLACE"/>

You can save 4 bytes by currying the arguments in reverse order: c=>b=>g=a=>a==(a=a.split(b).join(c))?a:g(a)

Oops. http://i.imgur.com/vPCycwR.png

@Metoniem Some combinations of inputs will never terminate. Your program can do anything in those cases.

@zeppelin Oh, I see.

Retina, 27 bytes
Byte count assumes ISO 8859-1 encoding.
+`(.+)(?=.*¶\1¶(.*))
$2
G1`

Input should be linefeed-separated.
Try it online! (For convenience, uses a test-suite input format where each line is a slash-separated test cases.)

C#, 44 Bytes
Short Version:
r=(a,b,c)=>a==(a=a.Replace(b,c))?a:r(a,b,c);

Example Program:
using System;

namespace ConsoleApplication1
{
    class Program
    {
    static void Main(string[] args)
        {
            Func<string, string, string, string> r = null;
            r=(a,b,c)=>a==(a=a.Replace(b,c))?a:r(a,b,c);

            Action <string, string, string, string> test =
                (a, b, c, answer) =>
                {
                    var result = r(a, b, c);
                    Console.WriteLine("A: \"{0}\"\r\nB: \"{1}\"\r\nC: \"{2}\"\r\nResult: \"{3}\"\r\n{4}\r\n\r\n",
                        a, b, c, result, result == answer ? "CORRECT" : "INCORRECT"
                        );
                };

            test("Hello, world!", "world!", "PPCG", "Hello, PPCG");
            test("Uppercase is up", "up", "down", "Uppercase is down");
            test("ababababa", "aba", "ccc", "cccbcccba");
            test("delete", "e", "", "dlt");
            test("", "no", "effect", "");
            test("llllrrrr", "lr", "rl", "rrrrllll");
            test("+-+-+-+", "+-+", "+", "+");
            test("ababababa", "aba", "bada", "badabbadbada");
            test("abaaba", "aba", "ab", "abb");
            test("((())())())", "()", "", ")");

            Console.WriteLine("Press any key...");
            Console.ReadKey();
        }
    }
}

Explanation:
The function is written as a tail recursive expression, avoiding the return keyword and curly brackets by exploiting the following:

An assignment within parenthesis returns the value assigned
The left side of the equality check will be evaluated before the right side assignment, allowing us to compare before/after inline, and still access the result

This lets us keep it to a single statement.
EDIT:
Went back to omitting the type of function r, since that appears to be acceptable.  With type declaration using arrays, it is 68 characters.  Without, it is 44 characters.

If the function will only work if given a specific name, you'll need to spend the bytes to give the function that name. It's not immediately obvious to me whether that's 2 bytes for r= or many more for a declaration (partly because I don't fully know the rules, partly because I don't know C# well enough to apply them).

Yeah, I was just fixing that after having read someone else's comment on a different entry.  And it is many more, since the types must all be specified.  I switched to using an array to save on that, and save bytes on the recursive call.

What do you mean with does not produce the correct output? I don't think you need to output the input, in fact, some of the other answers don't do it. Did I missed a comment saying that I need to output the input?

Nevermind, I've found the problem, it isn't recursive.

Japt, 15 bytes
@¥(U=UqV qW}a@U

Test it online!
How it works
@¥(U=UqV qW}a@U  // Implicit: U, V, W = input strings
            a@U  // Return the first non-negative integer mapped by the function X => U
@          }     // that returns truthily when mapped through this function:
     UqV qW      //   Split U at instances of V, and rejoin with W.
  (U=            //   Set U to this new value.
 ¥               //   Return (old U == new U). This stops the loop when U stops changing.
                 // Implicit: output result of last expression

Japt has a recursive-replace built-in, but it sees the first input as a regex. If the inputs were guaranteed to only contain alphanumeric characters this three-byte solution would work:
eVW

If the input were allowed to contain any char except ^, \, or ], this 12-byte solution would be valid instead:
eV®"[{Z}]"ÃW

Ruby, 29 bytes
->a,b,c{1while a.gsub! b,c;a}

Given 3 arguments, apply substitution to the first until there is nothing to substitute anymore.
Explanation

1 before the while is simply a nop
gsub! returns the string or nilif no substitution occurred

C#, 33 49 bytes
Probably, one of the smallest snippets written in C#... And since Replace is native to the string struct, there's no need for usings ( At least not on VS built-in feature, C# Interactive... )
Also, since B always has a value, the code doesn't need any validations.

Golfed
(a,b,c)=>{while(a!=(a=a.Replace(b,c)));return a;}

Ungolfed
(a, b, c) => {
    while( a != ( a = a.Replace( b, c ) ) );

    return a;
}

Full code
using System;

namespace Namespace {
    class Program {
        static void Main( string[] args ) {
            Func<string, string, string, string> func = (a, b, c) => {
                // Recursively ( now truly recursive ) replaces every 'b' for 'c' on 'a',
                // while saving the value to 'a' and checking against it. Crazy, isn't it?
                while( a != ( a = a.Replace( b, c ) ) );

                return a;
            };

            int index = 1;

            // Cycle through the args, skipping the first ( it's the path to the .exe )

            while( index + 3 < args.Length ) {
                Console.WriteLine( func(
                    args[index++],
                    args[index++],
                    args[index++]) );
            }

            Console.ReadLine();
        }
    }
}

Releases

v1.1 - +19 bytes - Fixed solution not being recursive.
v1.0 -  33 bytes - Initial solution.

I see c# I upvote

@NelsonCasanova Sounds like me.

Does Replace perform recursive replacement?

@Laikoni no. For instance, "((())())())".Replace("()", "") returns (())).

Then this solution is not valid under the rules of the challenge. You should delete it to prevent downvotes, then fix your solution to handle recursive replacement and finally undelete it.

Processing, 75 72 bytes
void g(String a,String[]s){for(;a!=(a=a.replace(s[0],s[1])););print(a);}

Prints the results. Call it like g("llllrrrr", new String[]{"lr","rl"});
void Q110278(String a, String[]s){             //a is the string to be replaced
                                               //s is the array containing the subsitution

  for(; a!=
            (a = a.replace(s[0], s[1])) ;);

  //for-loop where we continuously perform substitution on a
  //until a is equal to substituted a

  //at the end, print the final version of a
  print(a);
}

Mathematica, 35 32 Bytes
#//.x_:>StringReplace[x,#2->#3]&

Arguments given as a sequence. Never terminates for grow example, returns loop for loop example. Three bytes off thanks to Martin's suggestion.

FixedPoint tends to be too long and can be emulated with //.: #//.x_:>StringReplace[x,#2->#3]&

Thanks @MartinEnder. That's a good way of getting ReplaceRepeated to work for strings!

btw, this will only loop $RecursionLimit times, which is 2^16 by default, not that it affects your answer

@ngenesis I'm not sure that ReplaceRepeated is controlled by $RecursionLimit- I just tested it by setting the limit to 20 and the program still happily loops along for non-terminating input..

For ReplaceRepeated there's a separate option (which can't be used with the //. syntax), called MaxIterations. That one defaults to 2^16. (cc @ngenisis)

@MartinEnder We all learned something :)

Pyke, 6 bytes
hVQtX:

Try it here!

///, 3 bytes
///

Put string B after the first slash, C after the second and A at the end, ie:
/<B>/<C>/<A>

Try it online!

I don't think this is an acceptable way of taking inputs

To my knowledge, /// doesn't accept input in any other way.

Well, I think it would be interesting to discuss whether this is acceptable or not, then :) Anyway, I've noticed another problem with your submission: it doesn't work if a / is present in any of the input strings

JavaScript (Firefox 48 or earlier), 43 bytes
c=>b=>g=a=>a==(a=a.replace(b,c,'g'))?a:g(a)

Takes arguments curried in reverse order. Firefox used to have a non-standard third parameter to replace which specified regexp flags. This parameter was removed in Firefox 49.

SmileBASIC, 72 68 bytes
I=0DEF R A,B,C
I=INSTR(A,B)?A*(I<0)A=SUBST$(A,I,LEN(B),C)R A,B,C
END

One of the rare cases where making a function is actually SHORTER in SmileBASIC.

Javascript 130 bytes
f=(a,b,c)=>a.indexOf(b)<0?a:f(eval("a.replace(/"+b.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g,"\\$&")+"/g,c)"),b,c)

Javascript will only replace all simultaneously if you give it a regex. In order to make this regex work for all values, all characters that are used for regex need to be replaced with the escaped version. Finally, the replace is evaluated to replace all instances of B in A with C and passing that back around to the function again.

Cheddar, 37 bytes
(a,b,c)f->a has b?f(a.sub(b,c),b,c):a

On phone so TIO link is a bit difficult to add. Basically uses recursion while checking is b is in a. Solution could of been (a,b,c)->a.sub(Regex{b,"cr"},c) but doesn't work for some reason.

Does sub replace all or just the first?

@LliwTelracs because they are strings .sub will replace all

This doesn't seem to work? Try it online!

@ConorO'Brien crap silly mistake sides of ternary are off

q, 15 bytes
{ssr[;y;z]/[x]}

Example:
q){ssr[;y;z]/[x]}["llllrrrr";"lr";"rl"]
"rrrrllll"

link to interpreter download
Explanation: ssr, / (converge)

Perl 6, 40 bytes
{$^b;$^c;($^a,{S:g/$b/$c/}...*eq*)[*-1]}

Try it (if tio.run gets updated)
Try an altered version
Expanded:
{
  $^b;           # declare second parameter ( not used here )
  $^c;           # declare third parameter  ( not used here )

  (

    $^a,         # declare first parameter, and use it to seed the sequence

    {S:g/$b/$c/} # replace globally

    ...          # keep doing that

    * eq *       # until there are two that match

  )[*-1]
}

PHP, 102 bytes
list($n,$s,$a,$b)=$argv;$f=str_replace($a,$b,$s);while($s!=$f){$s=$f;$f=str_replace($a,$b,$s);}echo$f;

Test cases (functional)
Test case with loop error

Hi! Usually, when submitting a function, you should add to the bytecount all the things needed for the function to be defined (in your case function replace(...){...}, otherwise your submission is just a snippet, which is disallowed by default

@Leo Didn't know that, edited my answer ;)

PHP, 46 bytes
function g($a,$b,$c){echo strtr($a,[$b=>$c]);}

Java - 157 bytes
String r(String f){if(f.length()<1)return "";String[]x=f.split("/");if(x[0].contains(x[1]))return r(x[0].replace(x[1],x[2])+'/'+x[1]+'/'+x[2]);return x[0];}

For empty input it returns an empty string.
Crashes with StackOverflowException error when B is empty or it is fed with data like this A/A/A.
How it works:
r("ABCD/A/F") returns value of r("FBCD/A/F") which returns FBCD
If there is no more characters to be replaced it returns the final output

Ungolfed code code with comments:
String r (String f) {
    if(f.length() < 1)
        return ""; // For empty input return empty output
    String[] x = f.split("/"); // Get all 3 parameters
    if (x[0].contains(x[1])) // If input contains replaced value
        return r(x[0].replace(x[1],x[2])+'/'+x[1]+'/'+x[2]); // Return value of r() with one character replaced
    return x[0]; // If nothing to replace return the output(modified input)
}

AutoHotkey, 87 bytes
StringCaseSense,On
Loop{
IfNotInString,1,%2%,Break
StringReplace,1,1,%2%,%3%
}
Send,%1%

%1%,%2%, and %3% are the first 3 arguments passed to a function
If a function expects a variable argument, the %s are dropped
Changing the case-sensitivity setting costs 19 bytes but, without it, you get things like downpercase is down.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Draw an asterisk analog clock for hour N
Challenge:
Create a function or program that will take an input N (a number from 0 - 24) which represents the HOUR.
Output should draw an analog clock out of asterisks showing the hour N.

Notes:
•The minute hand must be longer than the hour hand (in terms of number of asterisks used)
•The minute hand must be at least 2 asterisks.
•Noon, 3pm, 6pm, and 9pm will always be orthogonal. Your output for intermediary hours, when arranged by degrees, should be in the same order as the hours of the day. What I mean is at noon the hour hand is 0º and at 3pm the hour hand is 90º so for your output cases of 1pm and 2pm the following must be true:  0pm_deg < 1pm_deg < 2pm_deg < 3pm_deg. Apart from this rule the actual degree amount can be whatever you decide, obviously it will change depending on font and other native factors.
•The connecting joint between the hour hand and minute hand is a circular/oval unicode character of any kind. o, O, •, 0, etc.

Example Input / Output (May vary depending on drawing styles)
 N = 3;

 *
 *
 *
 O  *  *

 N = 4;

 *
 *
 *
 O
    *
       *

 N = 5;

 *
 *
 *
 0
  *
   *

 N = 6;

 *
 *
 o
 *

 N = 7;

      *
      *
      *
      •
    *
  *

 N = 0,12,24;

 *
 *
 *
 o

Example of Differentiating Outputs:
 N = 4     VS     N = 5     VS     N = 6

  *                *                *
  *                *                *
  O                O                O
      *              *              *

This is code-golf, so the program with the shortest bytecount wins!

Hours usually are from 0-23 or 1-12 not 0-24 unless you have 25 hours in a day

The minute hand must be longer than the hour hand, but do they need to maintain their sizes? E.g., could the minute hand for 3 be a different size than the minute hand for 7?

@LliwTelracs but 23:00 is 11:00. In my mind I was trying to loop around back to the 12 hand again

@AdmBorkBork They do not need to maintain their sizes. I'll edit that in.

Do the hour-hand asterisks need to be in a straight line? Your example for N=4 doesn't have this property (maybe a typo).

@GregMartin I think that is my fault

Can you include a test case with 6 < N < 12, so we see an example where the minute hand isn't on the left side of the output?

@GregMartin Good catch, thanks! And Wheat I think I had the typo in my original haha

@LliwTelracs the 0-24 thing should be fine for this challenge since 0%12 = 12%12 = 24%12

@LliwTelracs  Some days sure feel like they do!

@LliwTelracs Depends.  In some places, 0:00 is start-of-day and 24:00 is end-of-day, where 24:00 Monday = 0:00 Tuesday.   It's just nothing exists besides 24:00:00.0000000

Are leading or trailing blanks/newlines accepted? What about padding?

@Titus since this is a drawing challenge I'll rule that it's okay to use freedom in drawing, the only requirements are the actual asterisks and circles themselves, as for padding (whether it be from new lines or spaces) I'm okay with it!

Javascript (ES6), 105 76 65 bytes

F=N=>`  *
ab*12
 9@3
87654`.replace(/\w/g,y=>'0x'+y^N%12?' ':'*')

N =  <input type="number" min="0" max="24" value="2" id="I" />
<button onclick="console.log(F(I.value))">Run</button>

-29 bytes:

Reduced size of minute and hour hand to 2 and 1 asterisks respectively. Smaller clock = less bytes :-P

-11 bytes:

Changed string comparison to numeric comparison.
y==(N%12).toString(16)?'*':' ' -> '0x'+y^N%12?' ':'*'

Original with longer hands: (105 94 bytes)

F=N=>`    *
a b * 1 2
  ab*12
  99@33
  87654
8 7 6 5 4`.replace(/\w/g,y=>'0x'+y^N%12?' ':'*')

N =  <input type="number" min="0" max="24" value="2" id="I" />
<button onclick="console.log(F(I.value))">Run</button>

That's really clever!

Oh wow I like this a lot!

Oops. My Python answer looks a bit like your original. I posted before I saw your answer, honestly. Guess we had the same idea with hex.

and I somehow read it as "The hour hand must be at least 2..." so +1 for reading it properly and shortening the hands.

@ElPedro that's what I thought I read originally also :)

CSS/HTML(JavaScript), 62 + 106 = 180 168 bytes

pre{position:absolute;left:99px;bottom:99px;transform-origin:50% 80%}
<input oninput=h.style.transform=`rotate(${this.value*30}deg)`>
*
*
o

*

Edit: Saved 9 bytes thanks to @nderscore.

Very cool idea!

Really nice answer.

You can shave 4 bytes off your input tag by swapping it with this

You could also embed the function code in the oninput attribute directly: <input oninput=h.style.transform=\rotate(${this.value*30}deg)`>`

Python 2, 148 140 135 bytes
-8 by deleting some leftover spaces and an unneeded newline.
-5 by changing (' ','*') to ' *'
a=input()
b='''    *
a b * 1 2
  ab*12
9 9 o 3 3
  87654
8 7 6 5 4'''
for x in range(1,12):b=b.replace(hex(x)[2],' *'[x==a%12])
print b

Try it online!

C (gcc), 144 bytes
#define v ,t
h;t(i){putchar(i>12?i-9:h^i?32:42);}n(i){h=i%12;puts("  *")v(10)v(11)v(h)v(1)v(2)v(19)v(12)v(9)v(57)v(3)v(19)v(8)v(7)v(6)v(5)v(4);}

Try it online!

+1; Holy recursion! I find it hilarious that you can save bytes in a code-golf challenge by macroing a comma ahha

I wasn't expecting it either, though there's no recursion in sight. This is a hard coded answer, albeit slightly obfuscated.

I don't think you need the space before the comma

SmileBASIC, 90 88 74 bytes
INPUT H?("  *"+" "*47)*2;"  o
R=H/1.9LOCATE 2.5+SIN(R)*2,3.5-COS(R)*2?"*

Example output:
? 5
  *
  *
  o

   *

? 3
  *
  *
  o *

Python 3, 86 85 bytes
-1 byte, better clockface (credit DuctrTape, as used in my Jelly answer)
def f(h):print(*([c,' *'[h%12+64==ord(c)]][c>'@']for c in'''
K*A
J*B
I0C
HFD
G E'''))

Try it online!

Jelly, 35 34 33 bytes
ị“ tI©’Œ?Ḋ¤µ⁶ẋ13”*⁸¦Ṗ;“**o”ṙ7s5ZY

Try it online! (tI©!) or see all (0 - 24).
How?
ị“ tI©’Œ?Ḋ¤µ⁶ẋ13”*⁸¦Ṗ;“**o”ṙ7s5ZY - Main link: h
          ¤                       - nilad followed by link(s) as a nilad:
 “ tI©’                           -     base 250 number: 522956007
       Œ?                         - shortest permutation of [1,N] that would be at
                                     that index in a lexicographically sorted
                                     list: [2,3,4,5,6,7,1,12,11,10,9,8,13]
         Ḋ                        - dequeue: [3,4,5,6,7,1,12,11,10,9,8,13]
ị                                 - index into (1-based and modular, so h=2 picks 4,
                                     as does h=14 [as do h=26, h=-10, etc.])
           µ                      - monadic chain separation (call the result j)
            ⁶                     - space character
             ẋ13                  - repeat 13 times
                   ¦              - apply to index...
                  ⁸               - ...left argument (j)
                ”*                -     an asterisk character (replacemes the space
                                         at index j with an asterisk)
                    Ṗ             - pop the last character off the list †
                     ;“**o”       - concatenate "**o"
                           ṙ7     - rotate left by 7 ‡
                             s5   - split into chunks of length 5 (columns)
                               Z  - transpose (get the rows of the clock)
                                Y - join with line feeds
                                  - implicit print

Note that “ tI©’Œ?Ḋ (permutation at index, dequeued) is a byte save over “9ȧỤ_ÑḶ’b⁴ (base 16 of), which is a byte save over “¦þxṙ<ȥ’ḃ13 (bijective base 13 of).
† Regarding the pop - we have an extra space in the string, which is where the asterisk for 0, 12, 24 will go to to allow mod-12 indexing of the list of indexes, popping the last character off there is byte-cheaper than doing the concatenation of “**o” beforehand and overwriting one of those asterisks.
‡ Regarding the rotation - this is a byte save over constructing a string with the `“**o” in the middle (either with it before or after the asterisk placement).

Haskell, 148 bytes
c n=mapM_ putStrLn$(t(n-3)!(t n!(\_->'*')))(map(\x->(2!(\_->x))"     ")"**O  ")
n!f=(\(x,a:y)->x++f a:y).splitAt n
t n=2+truncate(2.5*sin(n*pi/6))

Function c is the one that solves the given task

Bash + Unix utilities, 57 bytes
tr `dc -e12o$1O%p` \*<<<'B*1
A*2
9O3
864
7 5'|tr 1-9AB \

(There's a space after the final backslash.)
Try it online!
Not a very pretty clock, but it meets all the requirements.

PHP, 71 bytes
1 asterisk hours hand, 2 asterisk minutes hand.
$s="  *
  *
  O
";$s[ord(BGHNTSRQPJDE[$argv[1]%12])&31]="*";echo$s;

takes input from command line argument; run with -nr.

define template
map hour to position (decode from letter) and set character at position to asterisk
print

05AB1E, 41 bytes
This is too slow for TIO.
14Ýœ•2!&ô÷‰•èv… *@y_2L11+¹12%0‚ìyå+èJ}3ô»

For similar code working on TIO try this
Pretty sure this can still be both golfed and sped up.
Explanation coming later.

Logicode 634 bytes
Couldn't figure out how to input so there is a var a=... for the input at the top of tio link
circ v(a)->cond((a&1000)+0)&a->0/a
circ n(a)->cond a&10000->((a&100)+0)|!(a&100)&((a&011)|100)/a
circ y(a)->cond((a&100)+0)&a->a&10011/a
var s=@100000
var m=@101010
var x=y(n(v(a)))
var e=x&1000
var f=(x&100)+0
var t=(x&10)+00
var o=(x&1)+000
circ r(a,b)->cond(a)->b/@a
out s+s+s+s+m
out r(e&t&!o,m)+s+r(o&e&t,m)+s+m+s+r(o&!e&!f&!t,m)+s+r(t&!o&!f&!e,m)
out s+s+r(e&t&!o,m)+r(e&t&o,m)+m+r(o&!t&!f&!e,m)+r(t&!o&!f&!e,m)
out r(e&o&!t,m)+s+r(e&o&!t,m)+s+@110000+s+r(t&o&!f&!e,m)+s+r(t&o&!f&!e,m)
out s+s+r(e&!t&!o,m)+r((f&t&o),m)+r(f&t&!o,m)+r(f&!t&o,m)+r(f&!t&!o,m)
out r(e&!t&!o,m)+s+r(f&t&o,m)+s+r(f&t&!o,m)+s+r(f&o&!t,m)+s+r(f&!t&!o,m)

Have given up on golfing this. Could make it shorter at the cost of making the clock look horrible though.
Try it Online

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Convert AWG to Inches
AWG (American Wire Gauge) is a common way of specifying wire sizes. Your task in this challenge is to convert from a given gauge to the diameter of the wire in inches.
The size in inches for the gauges from 4/0 to 40 are shown in the table below:
Gauge to inches table
| AWG | Diameter (Inches) |
|-----|-------------------|
| 4/0 | 0.46              |
| 3/0 | 0.4096            |
| 2/0 | 0.3648            |
| 1/0 | 0.3249            |
| 1   | 0.2893            |
| 2   | 0.2576            |
| 3   | 0.2294            |
| 4   | 0.2043            |
| 5   | 0.1819            |
| 6   | 0.162             |
| 7   | 0.1443            |
| 8   | 0.1285            |
| 9   | 0.1144            |
| 10  | 0.1019            |
| 11  | 0.0907            |
| 12  | 0.0808            |
| 13  | 0.072             |
| 14  | 0.0641            |
| 15  | 0.0571            |
| 16  | 0.0508            |
| 17  | 0.0453            |
| 18  | 0.0403            |
| 19  | 0.0359            |
| 20  | 0.032             |
| 21  | 0.0285            |
| 22  | 0.0253            |
| 23  | 0.0226            |
| 24  | 0.0201            |
| 25  | 0.0179            |
| 26  | 0.0159            |
| 27  | 0.0142            |
| 28  | 0.0126            |
| 29  | 0.0113            |
| 30  | 0.01              |
| 31  | 0.00893           |
| 32  | 0.00795           |
| 33  | 0.00708           |
| 34  | 0.0063            |
| 35  | 0.00561           |
| 36  | 0.005             |
| 37  | 0.00445           |
| 38  | 0.00397           |
| 39  | 0.00353           |
| 40  | 0.00314           |

Clarifications

For gauges less than 0, you can take the input as either 3/0 or 000
You only have to support from the given 4/0 to 40
The Wikipedia page has some helpful formulas you can try to use if you don't want to hardcode everything
Output your answers to at least 3 sig-figs
This code-golf, so shortest code in bytes wins!

It's amazing what Americans can do to avoid using the metric system :-P

This isn't kolmogorov-complexity as it is a conversion to output and not a constant output

Can we take input as an array? 0000 as [0, 0, 0, 0] and 40 as [40]

J, 33 26 bytes
0.46%92^39%~*@".{3+".,~1-#

Try it online!
Takes input as a string with gauges less than zero as a string of zeroes. Finds the index of that string and divides 0.46 (the diameter of 0000) by the 39th root of 92 (the ratio between gauges) that many times.
Explanation
0.46%92^39%~*@".{3+".,~1-#  Input: string S
                         #  Length of S
                       1-   Subtract it from 1
                   ".,~     Eval S and append it, forms [1-len(S), eval(S)]
                 3+         Add 3 to each
            *@".            Sign of the eval
                {           Use that to index into the previous list
        39%~                Divide by 39
     92^                    Raise 92 to that power
0.46%                       Divide 0.46 by that and return

JavaScript (ES7), 36 bytes
s=>.46/92**(((+s||1-s.length)+3)/39)

Takes input in "0000" format.

Bash + GNU utils, 47
bc -l<<<"e(l(92)*(36-(${1/\/0/*-1+1}))/39)/200"

Straightforward arithmetic expression evaluation using bc.  Input given as a command-line parameter.
Gauges less than 0 are given as n/0.  The bash parameter expansion ${1/\/0/*-1+1} converts these to -ve numbers and adds one which makes the arithmetic come out right.
bc -l gives 20 decimal places by default.  bc's exponentiation operator ^ can only handle integer exponents so ln(y*e(x)) is used instead.
Try it online.

Maybe mention that the output values lack the leading zero or add it yourself? As a side note, there is also the possibility to solve this directly in a bc script, though in more bytes.

Jelly, 18 bytes
VoLC$+3÷39µ92*.46÷

Try it online!
A monadic link taking a tring and returning a number. The '0...0' cases produce some extra output, but the return value is correct, as may be seen by ignoring the first two lines here.
How?
VoLC$+3÷39µ92*.46÷ - Main link: guageString
V                  - evaluate as Jelly code (a string of zeros evaluates to 0)
    $              - last two links as a monad
  L                -     length
   C               -     complement (1-length)
 o                 - Or (integer value for > 0, 1-lenght for strings of zeros)
     +3            - add 3
       ÷39         - divide by 39
          µ        - monadic chain separation (call the result p)
              .46÷ - 0.46 divided by
           92*     - 92 raised to the power of p

Python 3, 45 bytes
lambda s:.46/92**((3+(int(s)or 1-len(s)))/39)

Try it online!

05AB1E, 25 23 bytes
8Ø50/92ID1‹ig(>}3+39/m/

Try it online!
Explanation
8Ø                       # push the 8th prime (0-indexed) = 23
  50/                    # divide by 50 = 0.46
     92                  # push 92
       I                 # push input
        D1‹i   }         # if input < 1
            g(>          # calculate -len(input)+1
                3+       # add 3
                  39/    # divide by 39
                     m   # raise 92 to this power
                      /  # divide 0.46 by this

Excel, 53 49 bytes
=92^((36-IF(ISNUMBER(A1),A1,49-CODE(A1)))/39)/200

Takes gauges less than Zero as String (1/0, 2/0 etc.)

Perl 5, 39 + 1 (-p) = 40 bytes
s/(.).0/1-$1/e;$_=.005*92**((36-$_)/39)

Try it online!
Takes the bigger gauges as "n/0".


text:
Is my Graph Graceful?
A Graceful Graph is a type of Simple Graph.  Graceful graphs are special because there is a way to label all their nodes with positive integers so that when the edges are also labeled with the differences of the nodes they connect, no two edges have the same label and every label up to the number of edges is used.
Worked Out Example
Here is a Simple graph that we suspect is a Graceful graph

Let us try the following labeling:

Note we are permitted to skip integers in our node labeling.  Now we label every edge with the positive difference between the nodes it connects.  For increased visibility I have labeled these in red.

Each edge has a unique number and no number between between 1 and 7 (the number of edges we have) is left out.  Thus our graph is graceful.
Task
Given a graph, via any reasonable method of input, output a truthy value if it is graceful and a falsy value otherwise.
This is code-golf so the objective is to minimize your byte count.
Test Cases
Here graphs are represented as an array of edges:
3 nodes:

[(0,1),(0,2),(1,2)]

True

Labeling:

Node 0 -> 0
Node 1 -> 2
Node 2 -> 3

5 nodes:

[(0,1),(0,4),(1,2),(2,3),(3,4)]

False

5 nodes:

[(0,1),(1,2),(2,3),(3,4)]

True

Labeling:

Node 0 -> 0
Node 1 -> 1
Node 2 -> 3
Node 3 -> 6
Node 4 -> 10

9 nodes

[(0,1),(1,2),(1,7),(1,8),(2,3),(2,6),(3,4),(4,5)]

True

Labeling:

Node 0 -> 0
Node 1 -> 1
Node 2 -> 3
Node 3 -> 6
Node 4 -> 10
Node 5 -> 15
Node 6 -> 11
Node 7 -> 7
Node 8 -> 8

5 nodes

[(0,1),(0,2),(1,2),(1,3),(1,4),(3,4)]

False

I think algorithms to check gracefulness are only known for certain classes of graphs (e.g. trees)

@ngenisis It can certainly be brute forced.  There are more efficient algorithms for certain classes but you can use restraints on the edge sizes to create a maximum node label difference.

[(0,1),(1,2),(2,3),(3,4)] is probably a noteworthy edge case.

Unless I'm missing something, graphs of the form {(k-1,k) : 0 < k < n} require the highest labels of all graphs with the same number of nodes.

@Dennis Oh yes.  That is certainly true they should require n(n+1)/2 as their highest label.  I have added your test case.

Can we take one-indexed nodes?

@Dennis I sure hope so

@Dennis Yes.  I/O Format is very flexible so the focus is on the algorithm rather than the pre and post processors.

I'm being fussy (or wrong) here, but you say positive integers at the start of the question and use 0 as a label later. Could you change that to say just integers?

Jelly, 12 bytes
FSŒ!ị@€ḅ-AċJ

Takes an array of edges as 1-indexed node pairs.
Try it online! (Horrendously inefficient. Don't bother with the actual test cases.)
How it works
FSŒ!ị@€ḅ-AċJ  Main link. Argument: A (array of pairs)

FS            Flatten and sum, yielding s. This is an upper bound for the labels
              a graceful labeling (if one exists) would require.
  Œ!          Take all permutations of [1, ..., s].
      €       For each permutation P:
    ị@          Replace each integer in A with the element of P at that index.
       ḅ-     Convert all pairs from base -1 to integer, mapping (a,b) to b-a.
         A    Take absolute values.
           J  Yield the indices of A, i.e., [1, ..., len(A)].
          ċ   Count the occurrences of [1, ..., len(A)] in the result to the left.

ḅ- is one of my favorite Jelly tricks :-)

Mathematica, 121 116 bytes
Edit: Saved 5 bytes thanks to JungHwan Min and Martin Ender
Cases[Range[1+Tr[n=Range@Length[e=EdgeList@#]]]~Tuples~VertexCount@#,w_/;Sort[Abs[#-#2]&@@w[[List@@#]]&/@e]==n]!={}&

Explanation

Pure function which takes a Mathematica Graph object with vertices {1, 2, ..., k} for some nonnegative integer k. In the worst case, we will only need vertex labels ranging from 1 to 1 + (1 + 2 + ... EdgeCount@#). Since it saves us some bytes later, we will let e be the list of edges and n be the list {1, 2, ..., EdgeCount@#}, so the vertex weights will be drawn from Range[1+Tr[n=Range@Length[e=EdgeList@#]]]. We generate a list of all Tuples of length VertexCount@#, then we choose the Cases which give graceful labelings and check to see that the result is Unequal to the empty list {}. Gracefulness of the list of vertex weights w is checked by Mapping the function Abs[#-#2]&@@w[[List@@#]]& over the list of edges e, Sorting the result, and checking whether the result is Equal to n. Here is a breakdown of that function:
               List@@#     Replace the Head of the edge with List; i.e., UndirectedEdge[a,b] becomes {a,b}.
            w[[       ]]&  Select the corresponding vertex weights from the list w.
          @@               Replace the Head of that expression (List) with the function
Abs[#-#2]&                   which returns the absolute difference between its first two arguments.
                           This effectively passes the vertex weights into the absolute difference function.

save a byte by messing with some precedence: VertexCount[#]->VertexCount@#

Btw, the Tr trick for Length no longer saves bytes if you need to add parentheses. Length[e=EdgeList@#] is the same length. But it's shorter to avoid that altogether and rewrite the triangular number there as Tr@Range@EdgeCount@# (and then replace e at the end with EdgeList@#. Second, the function operator rarely saves bytes, in this case I think it's shorter to use Cases instead of Select and then w_/; instead of w.

Python3, 449 bytes
R=range
def f(g):
 q=[(v:={**{i:-1 for j in g for i in j},0:0},[],{*v}-{0})]
 while q:
  m,e,n=q.pop(0)
  if not n:
   if all(i in e for i in R(1,len(g)+1)):return m
   continue
  for i in n:
   if(k:=[N for j in g if i in j and m[(N:=j[j[1]!=i])]!=-1]):
    y=[m[N]for N in k]
    for o in{*R(min(y)+1,max(y)+len(g)+1)}-{*m.values()}:
     E=[abs(Y-o)for Y in y]
     if all(U not in e and U<=len(g)for U in E):q+=[({**m,i:o},e+E,n-{i})]
    break

Try it online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Shortest program to throw NullPointerException in Java
I find NullPointerException to be interesting since there are no explicit pointers in Java. Here is a program that throws such an exception.
class c {
  public static void main(String[]s) {
    throw new NullPointerException();
  }
}

What is the shortest Java program that throws NullPointerException?

http://stackoverflow.com/questions/25694872/

We strongly discourage single-language challenges.

 62 Bytes (17 byte statement)
-2 bytes thanks to @PeterTaylor.
class C{public static void main(String[]s){s=null;s.clone();}}

Without knowing about the throw trick, this is the first thing that occurred to me. Using the main class's type is the shortest one available, and casting null is shorter than declaring C c=null;. notify is also the shortest method on an object that doesn't throw an exception.

19 bytes, see this Meta post

@JonathanAllan doesn't the question ask for a "java program"? According to that meta post, the full program is required unless only a function is requested.

it was not specified as "full program" Meta (every Java program will have that same boilerplate anyway - so to compare them we can just count the content).

((C)null).wait(); will work too.

wait's declaration throws InterruptedException, so the class will not compiler without a try/catch or throws declaration.

Compiles, runs and raises a NullPointerException at ideone.

You don't need a class name at all since you have a variable. s=null;s is one char shorter than ((C)null)

@JonathanAllan that only works with the added throws declaration on main.

@mackthehobbit Ah, yes.

@PeterTaylor huh, that didn't occur to me at all. Nice!

clone() also requires a throws because of CloneNotSupportedException

Java 8 - 56 53 bytes (11 byte snippet)
interface P{static void main(String[]a){throw null;}}

ideone
From the documentation:

Class NullPointerException
...
Thrown when an application attempts to use null in a case where an object is required. These include:
...

Throwing null as if it were a Throwable value.

That is completely missing the point of the meta question and answer you linked to, which is about full program vs function. See http://meta.codegolf.stackexchange.com/a/2423/194

Yes. You can save a byte by using enum instead of class.

@PeterTaylor could not get that to compile, but found a useful tip about Interface having default public scopes in Java 8.

It seems to need the declaration statement to be closed with a semicolon ideone which is still 56, what did I miss?


text:
Multiply without multiplying, without loops either
Make a function, method, program or routine that will accept two interger parameters (say x and y) and the total of the two values multiplied. Except straight multiplication is not allowed so you must not simply do something like:
int multiply (int x, int y) {
    return x*y;
}

Also you must not use a for () loop, like this:
int multiply (int x, int y) {
    int z = 0;
    for (int i = 0;i < y; i++){
        z += x;
    }
    return z;
}

Everything else is up to you. A winner is you with the most compact solution.

What about division?

Do X without Y is generally considered a bad idea for a challenge.

I don't understand what you mean but this may be a duplicate. Example functions/methods are for illustrative purposes only.

"What about division?"... from above "Everything else is up to you" so what about division?

@ShaunBebbers ATaco is referring to this.

Can said integers be negative?

You say "two integer parameters", but from your second code snippet it seems you mean "positive integers". Can you clarify?

The function examples are for illustrative purposes only; +/- numbers are allowed

When I say "numbers" I mean integers.

But then the second snippet would produce a wrong result for negative inputs. So it's not really illustrative

Yes it's for illustrative purposes only, as in it's an example.

Again, it's a misleading example, as it produces wrong results. I think it should be deleted, or modified to account for the sign

Okay well I think it's going to be closed anyway (I noticed a potential duplicate after the fact, by which time someone had posted an answer). Sorry for the confusion, but my point was not to use for() loops, regardless of what C script was contained in the for() loop.

I think this is closeable both as too broad, and as unclear. (Is * in Underload a valid answer, for example? It concatenates its two arguments, but Underload uses a representation for integers in which concatenating them causes them to be multiplied, sort of like xy in mathematics means x × y.)

@ShaunBebbers Why not ban other loops such as while(){} or do{}while()? while(){} can be made to work as a repeat n times loop too.

This is very likely to be closed so I wouldn't worry about it. Anyway I would have had to give an example of every type of loop and in every language I could think of, including -/+ counts.

@ShaunBebbers First of all, this challenge has been already closed. Second, I think that +/- support can be easily added using absolute values.

If "Put on hold" means the same as "closed" then you are right. So why ask questions on something that has been closed?

Ruby, 27 bytes
->i,j{(j!=0)?(i/(1.0/j)):0}

What about j=0?

@Sanchises fixed

Yes I can see division by zero being an issue unless Ruby returns infinity as an answer

j=0 is no problem, at least on ruby 2.3. Just try it.

Mathematica, 12 bytes
Exp@*Tr@*Log

Pure function taking a list of numbers (even complex numbers) as input and returning a number. Takes the logarithm of all the numbers in the list, adds them together, and exponentiates the result. Rules of exponents and logarithms ftw! (And because Mathematica calculates Log[0] as -∞ and can subsequently manipulate that symbolically, it arrives at the correct answer if one input number equals 0.)
Mathematica, 24 bytes
Tr[1^Flatten@Array[,#]]&

Pure function taking a list of nonnegative (unfortunately) integers as input and returning their product. Simply creates an array of the appropriate dimensions and counts the number of entries (using Tr[1^...] as a golfy shorthand for Length@...). Since we don't care what's actually in the array, we can fill it with Nulls using Array[,#], which doesn't cost any bytes for the first argument.

But how can you compute exponents and logarithms without using multiplication internally? (That's the issue with this sort of challenge -- the rules need to be specified in detail.)

Quite a good point. Mathematica doesn't actually compute the decimal expansion of say Log[2] unless you make it; it just knows how Log and Exp interact with each other. But of course, a transformation rule like Exp[Log[a]+Log[b]] = a*b uses multiplication behind the scenes. (The OP says "straight multiplication" isn't allowed, so presumably this is? But yeah, I agree with your issue.)

I think this follows the OP's rules -- you don't literally use multiplication in your program. I just think that the challenge could be worded in a way that would make it more interesting.

Python, 48 39 bytes
-9 bytes thanks to @ovs
f=lambda x,y,t=0:x and f(x-1,y,t+y)or t

Recursively adds y to t, and returns the sum of t when x is 0.

lambda a,b:eval(("+a"*b)[1:]) would work. This won't work when b is 0 though.

Would that not also count as "straight multiplication"?

I don't know :/ Might as well be.

Ruby, 22 bytes
->a,b{eval ?a<<42<<98}

Maybe bending the rules? This is no "straight" multiplication.

Perl, 19 bytes
18 bytes of code + -p flag.
s/.*/"$&+"x<>.0/ee

Try it online!
It takes two numbers (say m and n) and converts them into m+m+...+m+0 (n times) and evaluates this string. (the final +0 is to make sure that if one of the number is 0, then the result is 0 and not an empty string)


text:
Generalization of Eight Queen Puzzle
Here's one generalized version of the famous Eight Queen's Puzzle:

Given an n × n chess board, and an integer m (≤ n). Find all possible ways to put nm Queens such that

there are m Queens at each row
there are m Queens at each column

(note that we do not impose any restriction on the diagonals).

As you might see, it is possible, e.g. [1 denotes a Queen]:
n = 3, m = 2
1   1   0
0   1   1
1   0   1

n = 15, m = 2
0   0   0   0   0   0   1   0   0   1   0   0   0   0   0
0   0   0   0   0   0   1   0   1   0   0   0   0   0   0
0   0   1   0   0   0   0   0   0   0   0   0   0   1   0
1   0   0   0   0   0   0   0   0   0   0   0   0   1   0
1   0   1   0   0   0   0   0   0   0   0   0   0   0   0
0   1   0   0   0   0   0   0   0   1   0   0   0   0   0
0   0   0   1   0   0   0   0   0   0   0   0   0   0   1
0   0   0   1   0   1   0   0   0   0   0   0   0   0   0
0   1   0   0   0   0   0   1   0   0   0   0   0   0   0
0   0   0   0   0   0   0   1   1   0   0   0   0   0   0
0   0   0   0   1   0   0   0   0   0   0   1   0   0   0
0   0   0   0   1   0   0   0   0   0   0   0   0   0   1
0   0   0   0   0   1   0   0   0   0   0   1   0   0   0
0   0   0   0   0   0   0   0   0   0   1   0   1   0   0
0   0   0   0   0   0   0   0   0   0   1   0   1   0   0

Input: n, m
Output: Number of solutions
Winning Criteria: Single thread, Fastest [I will test with n = 15, m = 8 in my computer]
Optional: Print all solutions (as in the format given in examples)
Preferred Language: Python 2.7, Julia
Good luck!

Back of the envelope suggests about 10^50 solutions for n = 15, m = 8.

This is the third time today I've run into this problem. The world is a funny place.

@xnor, it's 649920606971625785993833472182540933121831448000. Pretty good estimate.

I find it quite distracting to call this a generalisation of the eight queens problem. It would make slightly more sense to call it a generalisation of the eight rooks problem, but the literature (A008300 and see refs.) seems to describe the problem principally in terms of 0-1 matrices. It's clear that printing all solutions is a non-goer for all but some very small inputs, so I would remove that suggestion.


text:
Change the Code, Change the Sequence: Cops
This is a cops-and-robbers challenge. For the robbers thread, go here.
This challenge involves two OEIS sequences chosen by the cops -- S1, S2 -- and how well those sequences can be golfed and obfuscated.
The Cops' Challenge
Your challenge as a cop is to pick a freely available language, and two OEIS sequences. Then, write code A in that language that takes input n and produces S1(n). When that code is modified by a Levenshtein distance of X characters (with X no more than 0.5 * (length A)), and turned into code B in the same language, it must then produce S2(n). You must actually write this code B, but don't reveal it until your challenge is safe (see below).
The cops' submissions must include the language name, the full code A, the byte-count of A, the X value of how many changes to get to their secret B code, and the chosen S1 and S2 sequence numbers. You can choose whether each sequence is 0-indexed or 1-indexed, but please specify that in your submission.
To crack a particular submission, robbers must come up with a program C in the same language (and version) that produces S2(n) and is Y character changes away from A (with Y <= X). Robbers do not necessarily need to find the exact same B code that the cop (secretly) produced.
Winning and Scoring
If your cop answer has not been cracked within 7 days (168 hours), you may reveal your own B solution, at which point your answer is considered safe. As long as you don't reveal your solution, it may still be cracked by robbers, even if the 7 days have already passed. If your answer does get cracked, please indicate this in the header of your answer, along with a link to the corresponding robber's answer.
Cops win by having the uncracked submission with the shortest A. If tied, then the smallest X will be used as tie-breaker. If still tied, the earlier submission will win.
Further Rules

You must not use any built-ins for hashing, encryption, or random number generation (even if you seed the random number generator to a fixed value).
Either programs or functions are allowed, but the code must not be a snippet and you must not assume a REPL environment.
You may take input and give output in any convenient format. The input/output methods must be the same for both sequences.
The definitive calculator for the Levenshtein distance for this challenge is this one on Planet Calc.
In addition to being a CnR challenge, this is code-golf so all usual golfing rules apply.

Also, make sure if you change something in this question, that you update the robbers one.

What if a cop names a function/variable really big with respect to the actual code generating the sequence? It'll be possible to create any sequence in this case with its lev distance being less that (0.5*len(A))

@hashcode55 Two things -- 1) that's not likely going to be a good candidate for winning the cops' thread. 2) if it's enormous like that, it also gives a good leeway for the robbers to crack it.

"this is code-golf so all usual golfing rules apply" Does this mean that code A must be golfed as much as possible, or can it be intentionally written in a too verbose/awkward way to make it more similar to code B?

@smls Writing goofy code is fine. Obviously, different algorithms will be golfed differently. Just because there's a different algorithm that's shorter isn't an issue. Intentionally padding with spaces or comments is not okay, though.

My usual question: if the language uses a bizarre encoding, is the Levenshtein distance measured using bytes or characters?

@ais523 I've only ever encountered Levenshtein in terms of characters, so that's what we're using here. I'll edit that in explicitly.

@AdmBorkBork If the programs need to be golfed, that should be mentioned in the spec. Also, does this apply only for A or for B as well?

Search un-cracked answers

Brain-Flak, 28 bytes, Distance of 4, A002817, A090809 Cracked
This answer uses 1-indexing
(({({}[()])}{}){({}[()])}{})

Try it online
For anyone interested there are 27475 valid Brain-Flak programs with Levenshtein distance 4 from this program and 27707 with distance 4 or less.  So a brute force solution would be feasible on a consumer grade computer.

It'd probably be shorter and quicker to read if you have X = 4 instead of Levenshtein distance of 4.

@mbomb007 I personally get a bit confused when challenges use a bunch of letter variables to stand in for things I was trying to avoid confusion.   I have made it shorter now, hopefully without causing any confusion.

shrug. If everyone read the question, they should get it. X is really the only variable they need to know.

@mbomb007 Although, the question also asks for a byte count.

That's not defined as a "variable" with a letter assigned to it, though.

"27707 with distance 4 or less" Surely this implies 232 valid programs with distance 2, right? I don't believe there are any at a distance of 1 or 3.

@ETHproductions yes that is true.

Cracked!

7, 33 characters, 13 bytes, X = 10, A000124 → A000142, Safe
171720514057071616777023671335133

Try it online!
The Levenshtein distance is measured in terms of characters, so I've written the program in terms of the characters it contains above (and Try it online!, including the language itself, is happy to run programs encoded in ASCII). However, the program is stored in disk using 7's sub-byte encoding, meaning that the program itself is actually the following hexdump (thus 13 bytes long):
00000000: 3cf4 2982 f1ce 3bfe 13dc b74b 7f         <.)...;....K.

(Because the Levenshtein distance is measured in terms of characters, you aren't necessarily adding/deleting/changing 10 bytes here, so it's probably best to work with the original ASCII.)
The program as written implements A000124 (triangular numbers + 1); any crack must implement A000142 (factorials). Both programs take input from stdin (as decimal integers), write their output to stdout, and treat an input of 1 as meaning the first element of the sequence (and an input of 2 as the second element, etc.).
Hopefully the very high X value will stop people brute-forcing the program, this time (which is always a risk with cops-and-robbers entries in 7).
The solution
177172051772664057074056167770236713351353

Try it online!
Differences from the original:

17 172051     405707 1 61677702367133513 3
177172051772664057074056167770236713351353

I don't have explanations prepared for how these work, so it's going to take me a while to get an explanation up, as I'm going to have to figure it out from almost-scratch. Hopefully there will be an explanation eventually.

Pyke, Levenshtein distance of 1, A036487, A135628.
Cracked!
X*e

Try it here!

Perl 6, 10 bytes, X = 1, A000012 → A001477

Cracked!
*[0]o 1***

S1 = A000012 = 1,1,1,1,1,... = The all 1's sequence. (0-indexed)
S2 = A001477 = 0,1,2,3,4,... = The nonnegative integers. (0-indexed)

Try it online!
Confirmed to work with Perl 6 release 2017.01, and with the Perl6 version running on TIO.
(A could be further golfed to 1*** – I hope it it's also allowed as it is.)

Perl 6, 13 bytes, X = 1, A161680 → A000217

Safe!
{[+] [,] ^$_}

S1 = A161680 = 0 0 1 3 6 10 15 21... = Zero followed by the triangular numbers.
S2 = A000217 = 0 1 3 6 10 15 21 28 ... = The triangular numbers.
Zero-indexed.

Try it online!
(Confirmed to work with the Perl 6 version running on TIO.)
Solution
{[+] [\,] ^$_}

How the original works:
{           }  # A lambda.
          $_   # Lambda argument.                     e.g. 4
         ^     # Range from 0 to n-1.                 e.g. 0, 1, 2, 3
     [,]       # Reduce with comma operator.          e.g. 0, 1, 2, 3
 [+]           # Reduce with addition operator.       e.g. 6

How the solution works:
{            } # A lambda.
           $_  # Lambda argument.                     e.g. 4
          ^    # Range from 0 to n-1.                 e.g. 0, 1, 2, 3
     [\,]      # Triangle reduce with comma operator. e.g. (0), (0,1), (0,1,2), (0,1,2,3)
 [+]           # Reduce with addition operator.       e.g. 10

Exploits the fact that numeric operators like addition treat a list as its number of elements, so in the example the sum is 1 + 2 + 3 + 4 = 10.
And yeah, the "Reduce with comma operator" no-op in the original is kinda skirting the code-golf rules, but I prefer to look at it as a silly algorithm which has been golfed as much as possible (whitespace etc.) for what it is... :)

This is begging to be brute forced, if I had the time or the inclination (and the knowledge of perl).

This has survived long enough to be marked as safe

Jelly, 11 bytes, X = 5, A005185 → A116881
ịḣ2S;
1Ç¡ḊḢ

This is a full program that takes an integer as command-line argument and prints an integer.
Both sequences are indexed as on OEIS, i.e, A005185 is 1-indexed and A116881 is 0-indexed.
Try it online!

Javascript, 41 bytes, Distance of 3, A061313, A004526, Cracked
f=x=>{return x>1?x%2?f(x+1)+1:f(x/2)+1:0}

Try it Online
Uses 1 based indexing, solution uses 0 based indexing.
Once again, a different solution...
f=x=>{return x>1?x<2?f(x-1)+1:f(x-2)+1:0}

Cracked.

By the way, you shouldn't use https://tio.run permalinks. They will stop working soon.

^ Use https://tio.run/nexus instead.

Pyke, Levenshtein distance of 2, A008788, A007526
Cracked!
'th^

Try it here!
Let's get slightly harder shall we?
The first answer is 1 based and the crack is 0 based.

Cracked.

Perl 6, 19 bytes, X = 1, A000045 → A000035

Cracked!
{(0,1,*+*...*)[$_]}

S1 = A000045 = 0 1 1 2 3 5 8 13 21 34... = "Fibonacci numbers". (0-indexed)
S2 = A000035 = 0 1 0 1 0 1 0 1 0 1... = "Period 2". (0-indexed)

Try it online!
(Confirmed to work with the Perl 6 version running on TIO.)

Cracked.

WolframAlpha, 18 bytes, X = 1
Cracked by math_junkie!
(sum1to#of n^1)*2&

Sometimes WolframAlpha will actually be able to display a pure function like this in functional form (other times it gets confused); but it can be cheerfully invoked with a given input—for example, (sum1to#of n^1)*2&@5 yields 30.
S1 = A002378 (pronic numbers)
S2 = A000537 (sum of the first n cubes)
Both sequences are 0-indexed.

Cracked!

Javascript, 15704 bytes, distance of 2, A059841 and A000004 - cracked
This solution is extremely long, so you can find the full code at this github gist.
The original answer (this one) is 1 indexed.
(I know this is way too long, it is just for fun.)

Cracked. Also, adding absolutely useless code !+[]-(!+[]) isn't really in the spirit of the rules

Just so you know, this answer is causing some issues for the OP of this challenge. Apparently it causes the whole page to be blocked because it looks like sketchy JavaScript. Could you maybe put the code in an external link? (Gist, pastedump, etc)

Actually, I've put it in a gist myself. If you would rather have the code somewhere else, feel free to edit it again if I've overstepped my bounds.

I guess that the !+[]-(!+[]) does make it so that you can't just reverse the conversion. But some of the other garbage just makes it longer. The equivalent code is only 15640 bytes.

Brain-Flak, 16 bytes, Levenshtein distance of 4, A000217 and A002378 -- Cracked by Martin Ender!
({({}[()])()}{})

Try it online!
This should be fairly easy to crack.

Cracked.

@WheatWizard Oh, whoops, I didn't realize I forgot too.

Javascript, 30 bytes, Distance of 4, A000290, A000079, -Cracked!
f=x=>{return x?2*x-1+f(x-1):0}

0-based indexing
@Kritixi Lithos's solution was actually different from mine
f=x=>{return x?f(x-1)+f(x-1):1}

Try it online

This is x**2 and not 2**x

I think it's A000290, not A000079.

@KritixiLithos it is supposed to be both. I changed the wrong sequence link on the top when I changed the other end.

Cracked

Javascript (ES6), distance is 1, A000079 and A000004 - cracked
as=function(){ return 2*2**((11)*-1*~arguments[0]/11-(4-(as+[]).length%89))-(as+[]).length%7}

The original answer (this one) is 0 based.
Now that it has been cracked, here is the original B function:
as=function(){ return 2*2**((1^1)*-1*~arguments[0]/11-(4-(as+[]).length%89))-(as+[]).length%7}

I was able to get my  crack http://codegolf.stackexchange.com/a/109976/64505 to behave inconsistently between two different environments.

Perl 6, 7 bytes, X = 2, A059841 → A001477

Cracked!
+(*%%2)

S1 = A059841 = 1 0 1 0 1 0 1 0... = "*Period 2: Repeat (1,0)". (0-indexed)
S2 = A001477 = 0 1 2 3 4 5 6 7... = "The nonnegative integers". (0-indexed)

Try it online!
(Confirmed to work with the Perl 6 version running on TIO.)

Am I doing this right? http://codegolf.stackexchange.com/a/110001/60793

Java 7, Levenshtein distance of 4, A094683, A000290, Cracked
int x{double r=1;for(int i=0;i<42;i++)r=r/2+n/r/2;int k=(int)((int)n*(float)n/Math.pow(n,(Math.sin(n)*Math.sin(n)+Math.cos(n)*Math.cos(n))/2));return n%4%2==(int)Math.log10(Math.E)/Math.log((double)'H'-'@')?(int)r:k;}

0-indexed.
Try it here!

@LliwTelracs did that for the first 15 non-negative integers, see my updated answer.

Cracked


text:
Change the Code, Change the Sequence: Robbers
This is a cops-and-robbers challenge. For the cops thread, go here.
This challenge involves two OEIS sequences chosen by the cops -- S1, S2 -- and how well those sequences can be golfed and obfuscated.
The cops are constructing code A that produces S1 and giving a number X that they claim is the best Levenshtein distance possible (in characters) to create B that produces S2.
The Robbers' Challenge
To crack a particular cop's submission, robbers must come up with a program C in the same language (and version) as that answer that produces S2(n) and is Y character changes away from A (with Y <= X). Robbers do not necessarily need to find the exact same B code that the cop (secretly) produced. The robbers' submissions must adhere to the same 0-index or 1-index as specified by the cop's submission.
If you manage this, post an answer with the solution, linking to the cop's answer, and leave a comment on the cop's answer linking back to yours.
Each cop answer can only be cracked once, and of course, you're not allowed to crack your own answer. If the cop's answer turns out to be invalid before or after being cracked, it is not counted towards the robber's score.
Winning and Scoring
Robbers are scored by (X - Y)*5 + 5 for each of their cracks, and the robber with the overall highest score wins.
Further Rules

You must not use any built-ins for hashing, encryption, or random number generation (even if you seed the random number generator to a fixed value).
Either programs or functions are allowed, but the code must not be a snippet and you must not assume a REPL environment.
You may take input and give output in any convenient format. The input/output methods must be the same for both sequences.
The definitive calculator for the Levenshtein distance for this challenge is this one on Planet Calc.
In addition to being a CnR challenge, this is code-golf so all usual golfing rules apply.

Search un-cracked answers

Pyke, Levenshtein distance of 1, A036487, A135628 - score 5
Crack of an entry by muddyfish
wX*e

Try it here!
The original code, X*e, squares the input, X, multiplies that by the input *, and halves then floors the result, e.
The trick is that 'X' is 56 in the base 96 representation of w, so wX yields 56, multiply that by the input then floor and halve and you get 28 times the input as needed.

Exactly what I had. Lasted slightly longer than I expected

As soon as I saw it I knew it was the intended solution.

Brain-Flak, 28 bytes, Distance of 4, A002817, A090809
(({(({})[()])}{}){{({}[()])}{}})

This answer was discovered with the help of a brute-forcer, which generated 35,000 possible programs (Lot's of them were imbalanced, and thus invalid brain-flak code, but I rolled with the bug and found the answer anyway). This was around the 20 thousandth program tested, and it took around an hour to find (though I don't know exactly how long since I was away when it finished).
I kind of didn't want to post this answer yet, since I don't yet have a full understanding of how this program works. However, the answer is about to be safe so I don't want it to expire. I hope to update this answer more once I fully understand it, as well as posting the code I used to find this answer. But for now, I'll just post a partial explanation.
#Push the sum of:
(

    #The (n-1)th triangular number, and the range [1, n] (The range doesn't count towards the sum I believe)
    ({(({})[()])}{})

    #Triangulate every number on the stack
    {{({}[()])}{}}

)

This makes sense because OEIS states:

For n>0, the terms of this sequence are related to A000124 by a(n) = sum( i*A000124(i), i=0..n-1 ). [Bruno Berselli, Dec 20 2013]

And A000124 are the triangular numbers + 1. However, I don't know exactly what the forumla is, so I can't fully explain how this works.

Perl 6, 19 bytes, X = 1, A000045 → A000035
{(0,1,*+<*...*)[$_]}

+> in place of +< would also work.
Try it online!
How it works
infix ... is quite useful for simple recursive sequences. The (0,1,*+*...*) part of the original code, which is a shorthand for
(0, 1, -> $x, $y { $x + $y } ... *)

specifies a sequence that begins with 0 and 1, then adds items by computing the sum of the former two items of the sequence.
In contrast, (0,1,*+<*...*) uses left bit-shift (+>, right bit-shift would also work) to construct the parity sequence. Since shifting 1 zero units to the left is 1, and shifting 0 one unit to the left is 0, we get the desired alternating patterns of ones and zeroes.

Perl 6, 10 bytes, distance 1 - score 5
Crack of an entry by smls
*[0]o 1***

Becomes:
*[0]o 1*+*

Try It Online!

Good job! I didn't think of this solution, mine was a bit more tricky and actually required the *[0]o  to be there. I guess that means I can come up with another challenge based on my "trick" ...:)

I don't really know Perl, just saw the *** and thought it looks like it could unfold the dyadic multiplication operation, *, with the previous arguments, I really don't know what the code actually does. Feel free to edit in some explanation!

1*** is parsed as  1 ** *, i.e. a lambda that does "1 to the power of x". 1*+* is parsed as 1 * (+*), i.e. a lambda that does "1 multiplied by (x converted to a number)".

Perl 6, distance 2, smls
Original:
+(*%%2)

Crack:
+(*+0%2)

Try it online!

Darn, again a simple solution I didn't consider... (Mine was the much more obfuscated +(^*Z%2). I guess I'm not very good at drafting these challenges.

WolframAlpha, Distance 1, Greg Martin, A002378, A000537
(sum1to#of n^1)^2&

How it works
I realized that interestingly, (n*(n+1)/2)^2 is a formula for the second sequence. Since sum(1 to n) is equivalent to n*(n+1)/2, I just had to switch the * to a ^.

You should inform him that you have cracked his answer

Well spotted! :)

Brain-Flak, 20 bytes, DJMcMayhem
({({})({}[()])()}{})

Try it online!
Added a ({}) at the beginning of the loop to double the value in each iteration.

Nice! FWIW, the 18 byte solution I had was ({(({}[()])){}}{})

JavaScript, Distance 4, LliwTelracs
Original:
f=x=>{return x?2*x-1+f(x-1):0}

Crack:
f=x=>{return x?2*(-0+f(x-1)):1}

Try it online!

JavaScript(ES6), Distance 1, Advancid
Original:
as=function(){ return 2*2**((11)*-1*~arguments[0]/11-(4-(as+[]).length%89))-(as+[]).length%7}

Crack:
as=function(){ return 0*2**((11)*-1*~arguments[0]/11-(4-(as+[]).length%89))-(as+[]).length%7}

Try it online!
or
as=function(){ return 2*1**((11)*-1*~arguments[0]/11-(4-(as+[]).length%89))-(as+[]).length%7}

Try it Online!
Somehow I was able to get it to behave differently between TIO and repl.it (absolutely no clue why 2*1^... would be equal to 0 as according to repl.it)

I'm too dumb, I didn't think about changing the 2 to a 0. Here is the B function: as=function(){ return 2*2**((1^1)*-1*~arguments[0]/11-(4-(as+[]).length%89))-(as+[]).length%7}.

Javascript, 41 bytes, Distance of 3, A061313, A004526
f=x=>{return x>>1;0?x%2?f(x+1)+1:f(x/2)+1:0}

Try it online!

Java, Distance 4, Peech, A094683, A000290
Original:
int x{double r=1;for(int i=0;i<42;i++)r=r/2+n/r/2;int k=(int)((int)n*(float)n/Math.pow(n,(Math.sin(n)*Math.sin(n)+Math.cos(n)*Math.cos(n))/2));return n%4%2==(int)Math.log10(Math.E)/Math.log((double)'H'-'@')?(int)r:k;}

Crack:
int x{double r=1;for(int i=0;i<42;i++)r=r/2+n/r/2;int k=(int)((int)n*(float)n/Math.pow(n,(Math.sin(n)*Math.sin(n)+Math.cos(n)*Math.cos(n))/2));return n%4%1==(int)Math.log10(Math.E)/Math.log((double)'H'-'@')?(int)n*n:k;}
                                                                                ^                                                         ^^^

returns n*n

Javascript, Advancid, distance of 2, A059841 and A000004
Only leaving the code behind the TIO link because it seems to be breaking the site.
Thanks to @nderscore, whose code I used to decrypt the initial code
There was some redundant code such as using !![]+[]+[] instead of !![]+[].
The addition of !+[]-(!+[]) (+1-1) initially prevented decryption.
Try it Online

Pyke, Levenshtein distance of 2, A008788, A007526
'SS^

Try it here!
How it works
This does mixed base conversion.
'S grabs the input n and applies, pushing [1, ..., n] on the stack. The next S takes input n and pushes the same array once more.
' seems to cause the next command to be applied to the previous top on the stack; I'm a little fuzzy on the details.
Finally, ^ applies mixed base conversion, so [1, ..., n] [1, ..., n] f computes
a(n) := [1]n + n + (n)(n-1)... + [n!]1 where the brackets indicate the place value and the number to their right the digit.
Now, a(n) = (1 + (1)(n-1) + (n-1)(n-2)(n-3) + ... + (n-1)!)n = n(a(n) + 1), which is the same recursive formula that defines a(n) in [A007526]. Since an empty sum is zero, a(0) = 0 and the base case matches as well.

How did you get it with so few attempts? I'm interested in your thought processes

Mixed base conversion is a rather common golfing trick. It's not the first time I used it.


text:
Find a balanced Neighborhood
Your task will be to take a balanced-string and a integer representing a Levenshtein distance (the number of characters that have to be inserted, deleted or changed to make one string into another) and you must find the number of balanced strings with that distance from the original string (i.e. the neighborhood of that string).
Stipulations

Balanced strings will consist only of the characters ()<>[]{}

You will only be asked to find neighborhoods for positive even distances

Input and output is flexible.  As long as you take in all the proper data and output the correct answer without violating any loopholes I am happy with your answer.

You may choose to divide all of your integer inputs by 2 if you choose.

This is code-golf so the objective is to minimize the number of bytes in your answer

This was inspired by this CMC and this answer

Testcases
   Case   | Distance | Size of Neighborhood
--------------------------------------------
    ()    |    2     |         18
   ({})   |    2     |         33
   (())   |    2     |         32
    <>    |    4     |        186
   [][]   |    4     |        688
  <(){}>  |    4     |        1379
    {}    |    6     |        2270
  []{}[]  |    6     |        41097

Here are a few small examples with the actual neighborhoods included:
(), 2 :
{'', '<>', '()[]', '()()', '(())', '([])', '()<>', '{}', '{()}', '<>()', '(){}', '{}()', '<()>', '(<>)', '[()]', '[]()', '({})', '[]'}

({}), 2 :
{'([]{})', '()', '{}', '<({})>', '({<>})', '<{}>', '({()})', '(<>{})', '({}<>)', '({[]})', '(({}))', '({{}})', '({}[])', '{({})}', '({})()', '{}({})', '(())', '()({})', '([])', '<>({})', '({}{})', '({}){}', '({})<>', '(<{}>)', '({})[]', '((){})', '[{}]', '{{}}', '[]({})', '(<>)', '({}())', '([{}])', '[({})]'}

(()), 2 :
{'(())[]', '<>(())', '()', '{}(())', '{()}', '({()})', '{(())}', '(([]))', '(({}))', '(()[])', '(())<>', '((()))', '([])', '((<>))', '()(())', '(<()>)', '([()])', '[(())]', '(()){}', '(())()', '(()())', '(<>())', '(()<>)', '((){})', '<(())>', '<()>', '([]())', '(<>)', '({}())', '[()]', '({})', '[](())'}

<>, 4 :
{'<><<>>', '(<>)<>', '[<>][]', '<<><>>', '(){<>}', '(<>)()', '[<()>]', '<({})>', '<>()<>', '<[<>]>', '[][]<>', '<>[]<>', '<><><>', '[]<{}>', '[]<<>>', '[]<><>', '{<><>}', '[{<>}]', '<(<>)>', '(())<>', '{}<>{}', '()(<>)', '{()<>}', '(())', '{<>{}}', '(<><>)', '([])<>', '[]<[]>', '<{}<>>', '<><()>', '{()}<>', '{{}}<>', '{<>()}', '<<>>()', '{<<>>}', '<()>()', '<[]>()', '<>[<>]', '(<>())', '{}<>()', '(()<>)', '[{}]', '{{}}', '[]()', '[(<>)]', '<{}[]>', '<<>>[]', '{}<()>', '<>', '[()]<>', '<()><>', '[[]]<>', '[{}]<>', '[]<>[]', '()[<>]', '[]<>()', '{<>}{}', '{<[]>}', '<>(<>)', '(<>)[]', '<{}>()', '{}<><>', '{<>}()', '{[]}', '{[]}<>', '<<<>>>', '[]<()>', '<<[]>>', '<<{}>>', '[[]]', '()()<>', '[]{<>}', '<><[]>', '[[]<>]', '<{}()>', '<{<>}>', '<[]{}>', '{}<{}>', '<{}>[]', '()<<>>', '(<()>)', '[]{}', '{{}<>}', '{}()', '()<>[]', '<{}><>', '{[<>]}', '<><{}>', '<(())>', '<><>{}', '[()]', '<<>>{}', '{}{}<>', '[<<>>]', '<[][]>', '(<<>>)', '<[]><>', '[<>]<>', '[<>[]]', '[{}<>]', '{()}', '{<>[]}', '[]{}<>', '{(<>)}', '(<[]>)', '()[]<>', '<>{<>}', '{[]<>}', '(<>{})', '({}<>)', '[<><>]', '<><>()', '{}[<>]', '<{[]}>', '<<()>>', '<<>{}>', '([<>])', '<[]()>', '()()', '([])', '[[<>]]', '((<>))', '[](<>)', '(){}<>', '[()<>]', '<([])>', '<()()>', '[][]', '<<>[]>', '[<[]>]', '({})<>', '<{{}}>', '<[{}]>', '<{}{}>', '{}(<>)', '<<>><>', '[<>()]', '[][<>]', '({})', '{}[]<>', '{}<[]>', '<[()]>', '()[]', '<()>[]', '{{<>}}', '(<>){}', '{}{}', '({<>})', '{<()>}', '{}{<>}', '[]()<>', '<[]>[]', '(<>[])', '<[]>{}', '{}()<>', '()<[]>', '()<{}>', '{}<<>>', '<{}>{}', '{}[]', '()<>{}', '<()<>>', '[<>{}]', '{<>}[]', '<<>()>', '<><>[]', '{<{}>}', '<()[]>', '()<><>', '[<>]()', '()<>()', '{}<>[]', '<{()}>', '(<{}>)', '(){}', '()<()>', '<(){}>', '{<>}<>', '<[[]]>', '[]<>{}', '([]<>)', '<[]<>>', '[<>]{}', '<()>{}', '<>{}<>', '[<{}>]'}

Trying to make a Brain-Flak brute-forcer? :D

@mbomb007 I have taken into account all of your advice.  Thanks for the help!

Related >:D

Related.

Mathematica, 187 173 bytes
Length@Union@Select[""<>#&/@(Tuples[Characters@" ()[]<>{}",StringLength@#+#2]/." "->""),sFixedPoint[StringReplace["()"|"[]"|"{}"|"<>":>""],s]==""&&EditDistance[s,#]==#2]&

Brute force pure function. # represents the first argument (starting string) and #2 represents the second argument (distance).
Characters@" ()[]<>{}" is the list of possible characters (including " ")
Tuples[Characters@" ()[]<>{}",StringLength@#+#2] is the list of all tuples of those characters with length at most the original string length plus the distance.
Tuples[Characters@" ()[]<>{}",StringLength@#+#2]/." "->"" replaces all of the " " characters with the empty string.
""<>#&/@(...) joins all of those character lists into strings.
Next we Select all such strings which are balanced and which have the appropriate EditDistance with the following function:
s                                                                                String s
                                                                                 maps to
  FixedPoint[StringReplace["()"|"[]"|"{}"|"<>":>""],s]                                              the fixed point of cancelling out pairs of brackets
                                                      ==                                             equals
                                                        ""                                          the empty string
                                                          &&                                        and
                                                            EditDistance[s,#]==#2                   the distance from s to # is #2

Next we use Union to delete the duplicates and take the Length.


text:
Stable marriage problem
Background
Suppose that there are 2*n people to be married, and suppose further that each person is attracted to exactly n other people under the constraints that:

Attraction is symmetric; i.e. if person A is attracted to person B, then person B is attracted to person A.
Attraction is antitransitive; i.e. if person A and person B are each attracted to person C, then person A and person B are not attracted to each other.

Thus the network of attractions forms the (undirected) complete bipartite graph Kn,n. We also assume that each person has ranked the people they are attracted to.  These may be represented as edge weights in the graph.
A marriage is a pairing (A,B) where A and B are attracted to each other. The marriage is unstable if there is another marriage where one person from each marriage could divorce their partner and marry each other and both end up with someone they ranked higher than their former partner.
Goal
Your task is to write a complete program or function which takes each person's preferences as input and outputs a marriage for each person such that each marriage is stable.
Input
Input may be in any convenient format; e.g., weighted graph, ordered list of preferences, dictionary/assocation, etc. You may optionally take the total number of people as input, but no other input is allowed.
Output
Output can also be in any convenient format; e.g. list of tuples, minimal edge cover, a function which associates to each person their partner, etc. Note that the only constraint is that each marriage is stable, there are no other optimality requirements.
Notes

You can find more information and an O(n^2) algorithm to solve this problem on Wikipedia or this Numberphile video. You are free to use any algorithm, however.
Standard loopholes are forbidden.
This is code-golf. Shortest answer (in bytes) wins.

Attraction is symmetric Ha!

@LuisMendo I'm continuing in the storied tradition of unrealistic word problems :)

It's Valentine's day tho (UTC+8 here)

Mathematica, 28 bytes
On would think, this is cheating. I for myself like this:
Combinatorica`StableMarriage

Needs to be called with the weight matrices of the preferences for
men and women.
Returns the direct indizes for the coupling.

(Yes Combinatorica is deprecated but it costs fewer bytes than FindIndependentEdgeSet)

Example (GoT-like):
(To be fair - i guessed the weights...but i'm okay with the results)

m = {{2, 4, 3, 1}, {1, 2, 4, 3}, {3, 2, 1, 4}, {4, 2, 1, 3}};
w = {{2, 3, 4, 1}, {3, 2, 1, 4}, {3, 2, 4, 1}, {4, 1, 2, 3}};
result = Combinatorica`StableMarriage[w, m];
MapThread[
  UndirectedEdge[Show[#1, ImageSize -> 130],
    Show[#2, ImageSize -> 130]] &, {names1,
   names2[[result]]}] // TableForm

+1 for exploiting Mathematica's epic library of useless-to-everyone-except-code-golfers functions.

I need to get in the habit of disallowing built-ins even when I'm confident that one doesn't exist :)

Never underestimate Mathematicas built-ins ;D


text:
Decode a UTF-8 character
The challenge
Your task is to decode the first character in a UTF-8 byte sequence. The input is a byte array or a byte string holding a UTF-8 byte sequence.
If the (start of the) sequence is valid, the output is the Unicode code point of the first character in the sequence which is a number between 0 and 0x10FFFF. Your program or function can return a numeric data type or return or print a textual representation of the number in any base.
If the sequence is invalid, your program must signal an error. You can return a unique value that is outside the range of Unicode code points, throw an exception, or whatever.
The UTF-8 string must be decoded according to RFC 3629. Here's the UTF-8 syntax from the RFC:
UTF8-octets = *( UTF8-char )
UTF8-char   = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4
UTF8-1      = %x00-7F
UTF8-2      = %xC2-DF UTF8-tail
UTF8-3      = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) /
              %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail )
UTF8-4      = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /
              %xF4 %x80-8F 2( UTF8-tail )
UTF8-tail   = %x80-BF

Any byte sequence that doesn't match the syntax above must result in an error. Besides the more obvious cases of invalid input, this means:

No overlong encodings.
No code points above 0x10FFFF.
No surrogates.

Trailing bytes after the first character are allowed and don't have to be checked for validity. Unexpected end of input must obviously result in an error but you can assume that the byte sequence isn't empty.
Zero-terminated strings are allowed. If you choose to work with zero-terminated strings, U+0000 can't be detected, so it's OK to only handle code points U+0001 to U+10FFFF. Otherwise, U+0000 must be handled.
Test input
Here are some hex byte sequences that can be used as test input. The valid sequences may optionally be followed by any other bytes.
01           Valid, U+0001   START OF HEADING
41           Valid, U+0041   LATIN CAPITAL LETTER A
7F           Valid, U+007F   DELETE
C3 9F        Valid, U+00DF   LATIN SMALL LETTER SHARP S
E2 80 94     Valid, U+2014   EM DASH
F0 9F A4 98  Valid, U+1F918  SIGN OF THE HORNS
F4 8F BF BF  Valid, U+10FFFF Noncharacter but valid

85           Invalid, starts with continuation byte
C0 80        Invalid, overlong two-byte sequence
C3 C0        Invalid continuation byte
D4           Invalid, unexpected end of input
E0 9F BF     Invalid, overlong three-byte sequence
E3 82        Invalid, unexpected end of input
ED A2 93     Invalid, surrogate U+D893
F0 8A B2 A0  Invalid, overlong four-byte sequence
F1 B3 B8     Invalid, unexpected end of input
F2 80 B2 53  Invalid continuation byte
F4 93 81 B3  Invalid, code point above U+10FFFF
F5           Invalid start byte
FF           Invalid start byte

Rules

Functions are allowed.
Using any UTF-8 decoding features of your programming language is not allowed. You can't just call ord in Perl, for example.
This is code golf. The shortest answer wins. No loopholes.

You say that we must reject invalid UTF-8, but you also say that we only need to decode one character. What if the first code point is valid UTF-8, but 1000 code points later the stream is invalid?

How does the prohibition on UTF-8 decoding features work in cases where a language naturally does Unicode decoding as part of the process of reading input? (Not necessarily planning to answer in such a language, but I know they exist.)

@orlp Bytes after the first character don't have to be checked for validity. I just tried to make that point clearer in the description.

@ais523 Then you have to find some way to get the input as a sequence of numbers representing the UTF-8 bytes.

This whole thing seems to be written for someone who already understands the specifications; for me it's pretty unclear. "Any byte sequence that doesn't match the syntax above", for example does not explain what the "syntax above" means. Also, what are "overlong encodings" and what are "surrogates"?