答:
C, 125 bytes

```<code>char*s="char*s;l,i;f(){l=i=strlen(s);while(i--)putchar(s[rand()%l]);}";l,i;f(){l=i=strlen(s);while(i--)putchar(s[rand()%l]);}
</code>```

C, 60 bytes for golfed but not quine code taking any string

```<code>l,i;f(char*s){l=i=strlen(s);while(i--)putchar(s[rand()%l]);}
</code>```

While for counting characters my solution needed 86:

```<code>c[256];i;f(char*s){i=256;while(*s)c[*s++]++;while(--i)while(c[i]?c[i]--:0)putchar(i);}
</code>```

Title: Faux Source Code

Body:
Output one random character for each character of source code (as illustrated below). The probability of each character is its frequency in the original source code. Thus the output will be fake source code resembling a quine.

Specification

Restrictions

Standard quine constrains apply. No empty programs or functions. Also no reading your own source.

Output

The number of characters output should be exactly the number of characters in the source code

Each output character should be randomly choosen

The probability of choosing any character is equal to (occurrences in source) / (length of source)

This means that even a unary solution needs to 'randomly' choose 1 with probability 1. Which is to say that the output can't be hard coded.

Winning

This is code golf, so fewest bytes wins

Example

```<code>Program           Frequency           Probability           Possible Output
-------           ---------           -----------           ---------------
 a@!@              a - 1               a - 25%               @@a@
                   ! - 1               ! - 25%
                   @ - 2               @ - 50%
</code>```

```<code>Program           Frequency           Probability           Possible Output
-------           ---------           -----------           ---------------
caBaDBcDaBDB       a - 3               a - 25%               aaaBBBBccDDD
                   B - 4               B - 33%
                   c - 2               c - 17%
                   D - 3               D - 25%
</code>```

Body:
C, 125 bytes

char*s="char*s;l,i;f(){l=i=strlen(s);while(i--)putchar(s[rand()%l]);}";l,i;f(){l=i=strlen(s);while(i--)putchar(s[rand()%l]);}

C, 60 bytes for golfed but not quine code taking any string

l,i;f(char*s){l=i=strlen(s);while(i--)putchar(s[rand()%l]);}

While for counting characters my solution needed 86:

c[256];i;f(char*s){i=256;while(*s)c[*s++]++;while(--i)while(c[i]?c[i]--:0)putchar(i);}


问:
Tips for golfing in Ruby
What general tips can you give for golfing in Ruby?

I'm looking for ideas that can be applied to code golf problems in general that are specific to Ruby. (For example, "Remove comments" would not be an answer.)

Please post one tip per answer.

答:
Kernel#p is a fun method.

Use p var instead of puts var. This works perfectly with integers and floats, but not with all types. It prints quotation marks around strings, which is probably not what you want.

Used with a single argument, p returns the argument after printing it.

Used with multiple arguments, p returns the arguments in an array.

Use p (with no arguments) instead of nil.

ContentLicense: CC BY-SA 3.0

Title: Tips for golfing in Ruby


问:
Noah's (upgraded) ark
As preparation for the nth Exodus, Noah decides to write a program that will decide If he will let animals on his ark.  However, Noah wants to go back to grass roots. Thus he decides that the program should be as small and as simple as possible.

GOAL:

Recreate the Contrabulous Choosematron, in a way that follows evangelical stories.

INPUT:

The program is simple, and elegant, and takes in 2 inputs:

The species of animal [String]

and The animal's gender [boolean]

OUTPUT:

The program then puts out Either 'Y' or 'N', Which determines whether or not the given  animal is allowed onto the ark.

RULES:

Only one Animal of each species and gender is allowed on the ark. No more.

Your output can be any set of boolean values (true false, yes no, y n, yin yang) so long as they're easily distinguishable.

If your program should want to accept a list of input, rather than use STDIN, that's fine. However, each output has to be in corresponding order of the input (FIFO), as well as be in the exact same format as the input.

This is a golf, so the lowest byte count wins, good luck!!!!

EXAMPLE:

"Monkey" true<

y

"Monkey" false<

y

"Monkey" false<

n

"Monkey with symbols" false<

y

"monkey" true<

n

This is valid, as your program doesn't need to distinguish that Monkey, and monkey with symbols are the same thing species, however, Monkey and monkey are very much the same thing, and so the last critter would be denied.

答:
Perl, <s>15</s> 13 bytes

Includes +1 for -n

Input on STDIN (or 1 or more filenames as argument like cat), one animal and gender per line in any consistent notation. Prints a line with 1 for true, an empty line for false

```<code>perl -M5.010 -n ark.pl
</code>```

ark.pl

```<code>say!${+lc}++
</code>```

Title: Noah's (upgraded) ark

Body:
Perl, <s>15</s> 13 bytes

Includes +1 for -n

Input on STDIN (or 1 or more filenames as argument like cat), one animal and gender per line in any consistent notation. Prints a line with 1 for true, an empty line for false

perl -M5.010 -n ark.pl

ark.pl

say!${+lc}++


问:
Print multiplication tables by input
In this challenge you've to print multiplication tables by input, Here are some examples:

```<code>Input: 2

Output:
0 2  4 6 8  10  12  14  16  18  20

Input: 20

Output: 20 40 60 80 100 120 140 160 180 200
</code>```

Rules

The shortest code in bytes wins.

This challenge is a code-golf, It follows code-golf general rules (code-golf)

If, just if, your code can't print number, you can use letters, Here is an example:

Input: B

Output: B D F H J L N P R T

You can choose to start from 0 or your number (like 20). You can choose if put spaces or don't. The challenge is free, just take an input and print multiplication tables.

Your output must list the first 10 members of the times table for the given number. You may leave out 0*n.

Title: Print multiplication tables by input

Body:
C, 39 bytes

i;F(n){while(i<11)printf("%d ",n*i++);}

Ideone it!

Input:

10

Output:

0 10 20 30 40 50 60 70 80 90 100


问:
All Binary Combinations to Decimal
Disclaimer

This question is not a duplicate of this question. I'm not counting specific digits, as we already have those set in the initial parameters. This question is focusing on the decimal numbers that can be constructed from the binary strings based on the digits provided.

Challenge

Given two integers X and Y, representing the number of zeroes (0) and ones (1) respectively, calculate all the possible decimal equivalents that can be determined from creating binary strings using only the zeroes and ones provided, and display them as output.

Example 1:

Input: 0 1

Output: 1

Explanation: Only one 1 to account for, which can only be converted one way.

Example 2:

Input: 1 1

Output: 1,2

Explanation: 01 converts to 1, 10 converts to 2.

Example 3:

Input: 3 2

Output: 3,5,6,9,10,12,17,18,20,24

Explanation: Three 0s and two 1s make 00011 (3), 00101 (5), 00110 (6), 01001 (9), 01010 (10), 01100 (12), 10001 (17), 10010 (18), 10100 (20), 11000 (24)

Limitations and Rules

I will only expect your code to work where 0 < X + Y <= 16 so the maximum number in the output could only occur from 16 1s, i.e. parameters 0 and 16.

As a result of the above limitation, the range of numbers we'd expect in the output are from 0 and 65535.

I will accept functions or code, so long as the resulting output is provided, whether this be a comma separated list, an array, list outputted to STDOUT, etc. The only criteria I must stress about the output is that it must be sorted.

This is code golf, minimum bytes will receive maximum glory.

We will not tolerate silly loopholes

答:
Groovy 80 Bytes

based on the answer by @carusocomputing

his 123 Byte solution can be compressed into 80 Bytes:

80 Byte Solution

```<code>{a,b->([0]*a+[1]*b).permutations()*.join().collect{Integer.parseInt(it,2)}}(1,2)
</code>```

For an input of 1,2 you get:

```<code>[5, 3, 6]
</code>```

Title: All Binary Combinations to Decimal

Body:
Groovy 80 Bytes

based on the answer by @carusocomputing

his 123 Byte solution can be compressed into 80 Bytes:

80 Byte Solution

{a,b->([0]*a+[1]*b).permutations()*.join().collect{Integer.parseInt(it,2)}}(1,2)

For an input of 1,2 you get:

[5, 3, 6]


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

How they count

Like English, they have dedicated words for 0-20, 30, 40 and 100

Instead of saying twenty-one and twenty-two, they say one and twenty and two and twenty

Starting with fifty they say multiples of 10 as n*20

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

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

Expected output

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

Rules

You may use any separator to separate the numbers

Due to a typo in the original specification, you may use forth instead of fourth.

You may write a function or write to std-out

Standard loopholes apply

This is codegolf; shortest code in bytes win!

答:
///, 434 bytes

```<code>/(/\/\///D/\/7(7/ and (2/twenty(4/ times (_/half ([/42
(&/three(;/thir()/four(!/fort($/_fifth[(#/seven(^/eight(@D;ty
(%D_!h[(*D_;d[(-/nine(`D!y
(F/five(T/teen
(O/one(X/six(GD&[(HD)[(ID2
(Y/two(AD$/zero
O
Y
&
)
F
X
#
^
-
ten
eleven
twelve
;T)TfifTXT#T^een
-T2
OIYI&I)IFIXI#I^I-I;ty
O@Y@&@)@F@X@#@^@-@!y
O`Y`&`)`F`X`#`^`-`_;d42
O*Y*&*)*F*X*#*^*-*&[OGYG&G)GFGXG#G^G-G_!h[O%Y%&%)%F%X%#%^%-%)[OHYH&H)HFHXH#H^H-H$OAYA&A)AFAXA#A^A-AO hundred
</code>```

Try it online!

Title: Count to 100 in Danish

Body:
///, 434 bytes

/(/\/\///D/\/7(7/ and (2/twenty(4/ times (_/half ([/42
(&/three(;/thir()/four(!/fort($/_fifth[(#/seven(^/eight(@D;ty
(%D_!h[(*D_;d[(-/nine(`D!y
(F/five(T/teen
(O/one(X/six(GD&[(HD)[(ID2
(Y/two(AD$/zero
O
Y
&
)
F
X
#
^
-
ten
eleven
twelve
;T)TfifTXT#T^een
-T2
OIYI&I)IFIXI#I^I-I;ty
O@Y@&@)@F@X@#@^@-@!y
O`Y`&`)`F`X`#`^`-`_;d42
O*Y*&*)*F*X*#*^*-*&[OGYG&G)GFGXG#G^G-G_!h[O%Y%&%)%F%X%#%^%-%)[OHYH&H)HFHXH#H^H-H$OAYA&A)AFAXA#A^A-AO hundred

<a href="http://slashes.tryitonline.net/#code=LygvXC9cLy8vRC9cLzcoNy8gYW5kICgyL3R3ZW50eSg0LyB0aW1lcyAoXy9oYWxmIChbLzQyCigmL3RocmVlKDsvdGhpcigpL2ZvdXIoIS9mb3J0KCQvX2ZpZnRoWygjL3NldmVuKF4vZWlnaHQoQEQ7dHkKKCVEXyFoWygqRF87ZFsoLS9uaW5lKGBEIXkKKEYvZml2ZShUL3RlZW4KKE8vb25lKFgvc2l4KEdEJlsoSEQpWyhJRDIKKFkvdHdvKEFEJC96ZXJvCk8KWQomCikKRgpYCiMKXgotCnRlbgplbGV2ZW4KdHdlbHZlCjtUKVRmaWZUWFQjVF5lZW4KLVQyCk9JWUkmSSlJRklYSSNJXkktSTt0eQpPQFlAJkApQEZAWEAjQF5ALUAheQpPYFlgJmApYEZgWGAjYF5gLWBfO2Q0MgpPKlkqJiopKkYqWCojKl4qLSomW09HWUcmRylHRkdYRyNHXkctR18haFtPJVklJiUpJUYlWCUjJV4lLSUpW09IWUgmSClIRkhYSCNIXkgtSCRPQVlBJkEpQUZBWEEjQV5BLUFPIGh1bmRyZWQ&input=">Try it online!


答:
C (gcc), <s>72</s> 68 bytes

f(a,b){for(a=1<<a+b;a--;)__builtin_popcount(a)^b||printf("%d\n",a);}
```

Try it online!

Unfortunately there is no popcount() in the standard library, but it is provided as a "builtin function" by GCC. The output is sorted, but in reverse order.

Thanks to @ceilingcat for shaving off 4 bytes!

Title: All Binary Combinations to Decimal

Body:
Disclaimer

This question is not a duplicate of this question. I'm not counting specific digits, as we already have those set in the initial parameters. This question is focusing on the decimal numbers that can be constructed from the binary strings based on the digits provided.

Challenge

Given two integers X and Y, representing the number of zeroes (0) and ones (1) respectively, calculate all the possible decimal equivalents that can be determined from creating binary strings using only the zeroes and ones provided, and display them as output.

Example 1:

Input: 0 1

Output: 1

Explanation: Only one 1 to account for, which can only be converted one way.

Example 2:

Input: 1 1

Output: 1,2

Explanation: 01 converts to 1, 10 converts to 2.

Example 3:

Input: 3 2

Output: 3,5,6,9,10,12,17,18,20,24

Explanation: Three 0s and two 1s make 00011 (3), 00101 (5), 00110 (6), 01001 (9), 01010 (10), 01100 (12), 10001 (17), 10010 (18), 10100 (20), 11000 (24)

Limitations and Rules

I will only expect your code to work where 0 < X + Y <= 16 so the maximum number in the output could only occur from 16 1s, i.e. parameters 0 and 16.

As a result of the above limitation, the range of numbers we'd expect in the output are from 0 and 65535.

I will accept functions or code, so long as the resulting output is provided, whether this be a comma separated list, an array, list outputted to STDOUT, etc. The only criteria I must stress about the output is that it must be sorted.

This is code golf, minimum bytes will receive maximum glory.

We will not tolerate silly loopholes

Body:
C (gcc), <s>72</s> 68 bytes

f(a,b){for(a=1<<a+b;a--;)__builtin_popcount(a)^b||printf("%d\n",a);}

Try it online!

Unfortunately there is no popcount() in the standard library, but it is provided as a "builtin function" by GCC. The output is sorted, but in reverse order.

Thanks to @ceilingcat for shaving off 4 bytes!

ContentLicense: CC BY-SA 4.0


问:
Bitflip and negate
Given an integer, make an expression that produces it from 0 using unary negation - and bitwise complement ~ (~n = -n-1), with the operators applied right to left.

```<code>...
-3  = ~-~-~0
-2  = ~-~0
-1  = ~0
 0  = 0
 1  = -~0
 2  = -~-~0
 3  = -~-~-~0
...
</code>```

Your expression must be as short as possible, which means no redundant parts of ~~, --, -0, or 00. Output or print the expression as a string or a sequence of characters.

var QUESTION_ID=92598,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/92598/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

答:
Java 7, <s>95</s> 79 bytes

79 bytes:

```<code>String s(int x){String t=x<0?"~":"";while((x<0?++x:x--)!=0)t+="-~";return t+0;}
</code>```

Ungolfed:

```<code>String s(int x) {
    String t = x<0 ? "~" : "";
    while((x<0 ? ++x : x--) != 0)
        t += "-~";
    return t+0;
}
</code>```

<s>Old version (95 bytes):</s>

```<code>String s(int x){return new String(new char[x<0?-x:x]).replace("\0","-~").substring(x<0?1:0)+0;}
</code>```

Usage:

```<code>class A {
    public static void main(String[]a) {
        System.out.println(s(-3));
        System.out.println(s(-2));
        System.out.println(s(-1));
        System.out.println(s(0));
        System.out.println(s(1));
        System.out.println(s(2));
        System.out.println(s(3));
    }
    static String s(int x){String t=x<0?"~":"";while((x<0?++x:x--)!=0)t+="-~";return t+0;}
}
</code>```

Try it here!

Output:

```<code>~-~-~0
~-~0
~0
0
-~0
-~-~0
-~-~-~0
</code>```

Title: Bitflip and negate

Body:
Java 7, <s>95</s> 79 bytes

79 bytes:

String s(int x){String t=x<0?"~":"";while((x<0?++x:x--)!=0)t+="-~";return t+0;}

Ungolfed:

String s(int x) {
    String t = x<0 ? "~" : "";
    while((x<0 ? ++x : x--) != 0)
        t += "-~";
    return t+0;
}

<s>Old version (95 bytes):</s>

String s(int x){return new String(new char[x<0?-x:x]).replace("\0","-~").substring(x<0?1:0)+0;}

Usage:

class A {
    public static void main(String[]a) {
        System.out.println(s(-3));
        System.out.println(s(-2));
        System.out.println(s(-1));
        System.out.println(s(0));
        System.out.println(s(1));
        System.out.println(s(2));
        System.out.println(s(3));
    }
    static String s(int x){String t=x<0?"~":"";while((x<0?++x:x--)!=0)t+="-~";return t+0;}
}

Try it here!

Output:

~-~-~0
~-~0
~0
0
-~0
-~-~0
-~-~-~0


问:
Sum of positive integers.

Problem:

Given a set of integers, find the sum of all positive integers in it.

Input:

t – number of test cases [t < 1000]

On each of next t lines, an integer N [-1000 ≤ N ≤ 1000]

Output

The program should output the sum of all the positive integers.

Check your code in online judge

Score

Score is equal to size of source code of your program except symbols with ASCII code ≤ 32.

Here is the best score list: Python Best Scores (Best score is 29)

答:
Ruby, 42

```<code>s=0
gets.to_i.times {
    i=gets.to_i
    s+=i if i>0
}
p s
</code>```

(based on david4dev's answer)

Best score for Ruby on spoj: http://www.spoj.com/ranks/SIZECON/lang=RUBY

Title: Sum of positive integers.

Body:
Ruby, 42

s=0
gets.to_i.times {
    i=gets.to_i
    s+=i if i>0
}
p s

(based on david4dev's answer)

Best score for Ruby on spoj: http://www.spoj.com/ranks/SIZECON/lang=RUBY


Title: Print multiplication tables by input

Body:
In this challenge you've to print multiplication tables by input, Here are some examples:

```<code>Input: 2

Output:
0 2  4 6 8  10  12  14  16  18  20

Input: 20

Output: 20 40 60 80 100 120 140 160 180 200
</code>```

Rules

The shortest code in bytes wins.

This challenge is a code-golf, It follows code-golf general rules (code-golf)

If, just if, your code can't print number, you can use letters, Here is an example:

Input: B

Output: B D F H J L N P R T

You can choose to start from 0 or your number (like 20). You can choose if put spaces or don't. The challenge is free, just take an input and print multiplication tables.

Your output must list the first 10 members of the times table for the given number. You may leave out 0*n.

Body:
PHP, 44 bytes

$a=$argv[1];for($i=0;$i<10*$a;$i+=$a)echo$i;


问:
Sample win/loss data generator based on certain criteria
Lets say we have this existing data:

```<code>Total - 10
Won   -  7
Lost  -  3
Longest Winning Streak - 5
Longest Losing Streak - 2
</code>```

Now you need to write a function which generates an array of random boolean values (true representing a win and false representing a loss) which fulfills the above criteria.

So, in this case the output can be any of the following:

```<code>0011011111
1111101100
1010011111
..........
</code>```

Rules:

Solution must be function which takes in Won, Lost, Longest Winning Streak and Longest Losing Streak and returns a boolean array or string formed of a boolean array like (110011001010). It can also display output instead of returning the generated data.

You can safely assume there are no ties/draws/no-results.

This is code-golf so shortest code wins.

Input format can be in any form (Standard Input/Command-Line,etc.). And the real input format should be - <Won> <Lost> <LWS> <LLS> where <..> are place-holders or they can be separate parameters for the function.. whatever you deem best for your code. The parameter Total is unnecessary. So you needn't use it.

As far as random is concerned, you can see that in the example, there are three (and more) possible outputs. Just output any one at random.

If you have any other question, ask in the comments below.

Important - Not any answer as of now is correct.

I provide another example (this one's real data) which is possible but not working with the codes in the current answers:

```<code>Total - 171
Won   - 111
Lost  -  60
Longest Winning Streak - 10
Longest Losing Streak  - 4
</code>```

Real Data:

```<code>1110110100111111010000101111111100110001100110111101101011111011011011011111111110110001111011010001101011100101111101001011011110101101001100001111101010110001111110111111
</code>```

Another possible output (Basically the same, just the third and fourth digits are interchanged):

```<code>1101110100111111010000101111111100110001100110111101101011111011011011011111111110110001111011010001101011100101111101001011011110101101001100001111101010110001111110111111
</code>```

答:
Java 7, <s>319</s> 317 bytes

```<code>import java.util.*String c(int a,int b,int c,int d){String r="",w="",l="";List z=new ArrayList();int i,q=a+b-c-d;for(i=;i++<c;w+=1);for(i=0;i++<d;l+=0);for(;a---c>0;z.add(1));for(;b---d>0;z.add(0));Collections.shuffle(z);for(i=0;i<q;r+=z.get(i++));return new StringBuilder(r).insert(new Random().nextInt(q),w+l)+"";}
</code>```

NOTE: The winning streak and losing streak will always be right after one-another, everything else, including their positions in the resulting string, is random.

Ungolfed & test cases:

Try it here.

```<code>import java.util.*;
class M{
  static String c(int a, int b, int c, int d){
    String r = "",
           w = "",
           l = "";
    List z = new ArrayList();
    int i,
        q = a+b-c-d;
    for(i = 0; i++ < c; w += 1);
    for(i = 0; i++ < d; l += 0);
    for( ; a-- - c > 0; z.add(1));
    for( ; b-- - d > 0; z.add(0));
    Collections.shuffle(z);
    for(i = 0; i < q; r += z.get(i++));
    return new StringBuilder(r).insert(new Random().nextInt(q), w+l)+"";
  }

  public static void main(String[] a){
    System.out.println(c(7, 3, 5, 2));
    System.out.println(c(171, 111, 10, 4));
  }
}
</code>```

Possible output:

```<code>1111100011
100100010110111111110011011100101111011010110011011101111010010010101111101111000010010000110100010111001100100110010011101100111111111111110110110101011100111111111100001011111000111011111010010001010001100111110011111011011011101010101011101011011101101001001100100101100111111101
</code>```

Body:
Java 7, <s>319</s> 317 bytes

import java.util.*String c(int a,int b,int c,int d){String r="",w="",l="";List z=new ArrayList();int i,q=a+b-c-d;for(i=;i++<c;w+=1);for(i=0;i++<d;l+=0);for(;a---c>0;z.add(1));for(;b---d>0;z.add(0));Collections.shuffle(z);for(i=0;i<q;r+=z.get(i++));return new StringBuilder(r).insert(new Random().nextInt(q),w+l)+"";}

NOTE: The winning streak and losing streak will always be right after one-another, everything else, including their positions in the resulting string, is random.

Ungolfed & test cases:

Try it here.

import java.util.*;
class M{
  static String c(int a, int b, int c, int d){
    String r = "",
           w = "",
           l = "";
    List z = new ArrayList();
    int i,
        q = a+b-c-d;
    for(i = 0; i++ < c; w += 1);
    for(i = 0; i++ < d; l += 0);
    for( ; a-- - c > 0; z.add(1));
    for( ; b-- - d > 0; z.add(0));
    Collections.shuffle(z);
    for(i = 0; i < q; r += z.get(i++));
    return new StringBuilder(r).insert(new Random().nextInt(q), w+l)+"";
  }

  public static void main(String[] a){
    System.out.println(c(7, 3, 5, 2));
    System.out.println(c(171, 111, 10, 4));
  }
}

Possible output:

1111100011
100100010110111111110011011100101111011010110011011101111010010010101111101111000010010000110100010111001100100110010011101100111111111111110110110101011100111111111100001011111000111011111010010001010001100111110011111011011011101010101011101011011101101001001100100101100111111101


答:
JavaScript (ES6), non-competing

I decided to do what the title actually asked, and counted to 100 på dansk. This is based on ETHproductions' answer. It is 292 bytes (286 if you use alert instead)

for(a="nul0en0to0tre0fire0fem0seks0syv0otte0ni0ti0elleve0tolv0tret0fjor0fem0seks0syt0at0nit".split(i=0);i<101;i++)console.log(i<13?a[i]:i<20?(a[i])+"ten":i>99?"hundrede":(i%10?a[i%10]+"og":"")+(["tyve","tredive","fyrre","halvtreds","tres","halvfjerds","firs","halvfems"][Math.floor(i/10)-2]))```

Title: Count to 100 in Danish

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

How they count

Like English, they have dedicated words for 0-20, 30, 40 and 100

Instead of saying twenty-one and twenty-two, they say one and twenty and two and twenty

Starting with fifty they say multiples of 10 as n*20

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

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

Expected output

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

Rules

You may use any separator to separate the numbers

Due to a typo in the original specification, you may use forth instead of fourth.

You may write a function or write to std-out

Standard loopholes apply

This is codegolf; shortest code in bytes win!


Title: Print multiplication tables by input

Body:
J, 8 bytes

(i.10)&*

This is the range from 0 to 9 inclusive (i.10) bonded (&) wit the multiplication function (*). This starts at zero.

Test cases

   k =: (i.10)&*
   k 2
0 2 4 6 8 10 12 14 16 18
   k 10
0 10 20 30 40 50 60 70 80 90
   k"0 i.10
0 0  0  0  0  0  0  0  0  0
0 1  2  3  4  5  6  7  8  9
0 2  4  6  8 10 12 14 16 18
0 3  6  9 12 15 18 21 24 27
0 4  8 12 16 20 24 28 32 36
0 5 10 15 20 25 30 35 40 45
0 6 12 18 24 30 36 42 48 54
0 7 14 21 28 35 42 49 56 63
0 8 16 24 32 40 48 56 64 72
0 9 18 27 36 45 54 63 72 81


问:
Invert png image
Create program or function that takes file name as an argument or reads it from standard input, and completes the following task:

Read image from a png file (name given as argument).

Reverse colors in that image, so that for example dark green (0, 75, 30) would become (255, 180, 225) (because 255-0=255, 255-75=180 and 255-30=225). You should not change alpha channel value.

Output that image to a file called a.png (in png format), or show it in GUI window.

This is code-golf. Standard loopholes apply.

答:
CSS, 19 Bytes

```<code>*{filter:invert(1)}
</code>```

http://output.jsbin.com/suqayudoyu

Title: Invert png image

Body:
CSS, 19 Bytes

*{filter:invert(1)}

http://output.jsbin.com/suqayudoyu


答:
C#, 62 bytes

```<code>void P(int x){for(int i=1;i<=10;i++){Console.WriteLine(x*i);}}
</code>```

Title: Print multiplication tables by input

Body:
C#, 62 bytes

void P(int x){for(int i=1;i<=10;i++){Console.WriteLine(x*i);}}


问:
The Letter E with E
Your task is to display the below letter "E" shaped ASCII art, given five inputs.

Examples:

Input: 7,2,+,|,- (Note: You don't have to follow this exact input format, and if you don't use it, then you must explain how your own input format works)

Explanation:

7 total width, including the left and right edge characters.

2 Number of vertical characters.

+ The character that should display at the edges.

| The character that should display vertically between the edges.

- The character that should display horizontally.

Output of the above example:

```<code>+-----+
|
|
+-----+
|
|
+-----+
</code>```

Other examples:

Input: 7,2,@,|,-

Output:

```<code>@-----@
|
|
@-----@
|
|
@-----@
</code>```

Input: 7,2,+,|,#

Output:

```<code>+#####+
|
|
+#####+
|
|
+#####+
</code>```

Input: 8,3,+,|,#

Output:

```<code>+######+
|
|
|
+######+
|
|
|
+######+
</code>```

Input: 8,3,+,@,#

Output:

```<code>+######+
@
@
@
+######+
@
@
@
+######+
</code>```

Input: 9,4,^,$,!

Output:

```<code>^!!!!!!!^
$
$
$
$
^!!!!!!!^
$
$
$
$
^!!!!!!!^
</code>```

Cheating and standard loopholes are not allowed.

Your code must not print anything to STDERR.

Your code may accept any character encoding you choose as the input, but any character encoding you choose must, as a minimum, support all the 95 printable ASCII characters.

The shortest code, in bytes, that completes this challenge successfully, is the winning code.

Leaderboard

var QUESTION_ID=92138,OVERRIDE_USER=58717;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

答:
Java 7, <s>205</s> 129 bytes

```<code>String c(int w,int h,String a,char b,char c){String r=a,n="\n",l="";for(;w-->2;r+=c);r+=a+n;for(;h-->0;l+=b+n);return r+l+r+l+r;}
</code>```

-76 bytes thanks to an anonymous stranger.

PS: Don't go edit other people's posts next time. If you have something to golf please leave it as a comment, or if it's using a completely different approach you could make your own answer. Still thanks for golfing away all these bytes, though - whoever you are..

Ungolfed & test cases:

Try it here.

```<code>class M {
    static String c(int w, int h, String a, char b, char c){
        String r = a,
               n = "\n",
               l = "";
        for(; w-- > 2; r += c);
        r += a+n;
        for( ;h-- > 0; l += b+n);
        return r+l+r+l+r;
    }

    public static void main(String[] a) {
        System.out.print(c(7, 2, "+", '|', '-'));
        System.out.print(c(9, 4, "?", '¡', '¿'));
    }
}
</code>```

Output:

```<code>+-----+
|
|
+-----+
|
|
+-----+

?¿¿¿¿¿¿¿?
¡
¡
¡
¡
?¿¿¿¿¿¿¿?
¡
¡
¡
¡
?¿¿¿¿¿¿¿?
</code>```

Title: The Letter E with E

Body:
Java 7, <s>205</s> 129 bytes

String c(int w,int h,String a,char b,char c){String r=a,n="\n",l="";for(;w-->2;r+=c);r+=a+n;for(;h-->0;l+=b+n);return r+l+r+l+r;}

-76 bytes thanks to an anonymous stranger.

PS: Don't go edit other people's posts next time. If you have something to golf please leave it as a comment, or if it's using a completely different approach you could make your own answer. Still thanks for golfing away all these bytes, though - whoever you are..

Ungolfed & test cases:

Try it here.

class M {
    static String c(int w, int h, String a, char b, char c){
        String r = a,
               n = "\n",
               l = "";
        for(; w-- > 2; r += c);
        r += a+n;
        for( ;h-- > 0; l += b+n);
        return r+l+r+l+r;
    }

    public static void main(String[] a) {
        System.out.print(c(7, 2, "+", '|', '-'));
        System.out.print(c(9, 4, "?", '¡', '¿'));
    }
}

Output:

+-----+
|
|
+-----+
|
|
+-----+

?¿¿¿¿¿¿¿?
¡
¡
¡
¡
?¿¿¿¿¿¿¿?
¡
¡
¡
¡
?¿¿¿¿¿¿¿?


答:
golfscript, partial solution only, 150 chars

```<code>:i;[0]30000*[]0 "#{File.open('f').read}"{{\(@=\''if}+['>+\\(@\\' '<@+\\)' '+1+256%' '-1- 256%' ".[0$]''+print " ',;i(\:i;' '[{.}{' ']}while']\%}%~;;;;
</code>```

i am greatly indebted to the pattern of generating your own source and then eating it, as others have already posted.

misfeatures:

only parses brainfuck code from the file 'f'.

all input you want to read with ',' must be piped in at the beginning.

runs hello world, yet dies somewhere during prime.bf. i'm not sure why. i did read somewhere that golfscript is broken for nested while loops, so that might be it.

stores a char=>string map in a way that is entertainingly horrible, at least to me.

I've tried loading arbitrary files with constructions like "#{File.open(" "some_file.bf" ").read}" + + but Ruby seems to helpfully escape the "#" for me so i dont accidentally load the file im trying to load. On the other hand, embedding "#{getc}" works okay for reading from stdin, but there's still the restriction that input is non-interactive - only stuff piped in at the start is read. Anyone know a way around one or more of these input issues?

Title: Interpret brainfuck

Body:
Write the shortest program in your favourite language to interpret a brainfuck program. The program is read from a file. Input and output are standard input and standard output.

Cell size: 8bit unsigned. Overflow is undefined.

Array size: 30000 bytes (not circled)

Bad commands are not part of the input

Comments begin with # and extend to the end of line Comments are everything not in +-.,[]<>

no EOF symbol

A very good test can be found here. It reads a number and then prints the prime numbers up to that number. To prevent link rot, here is a copy of the code:

```<code>compute prime numbers
to use type the max number then push Alt 1 0
===================================================================
======================== OUTPUT STRING ============================
===================================================================
>++++++++[<++++++++>-]<++++++++++++++++.[-]
>++++++++++[<++++++++++>-]<++++++++++++++.[-]
>++++++++++[<++++++++++>-]<+++++.[-]
>++++++++++[<++++++++++>-]<+++++++++.[-]
>++++++++++[<++++++++++>-]<+.[-]
>++++++++++[<++++++++++>-]<+++++++++++++++.[-]
>+++++[<+++++>-]<+++++++.[-]
>++++++++++[<++++++++++>-]<+++++++++++++++++.[-]
>++++++++++[<++++++++++>-]<++++++++++++.[-]
>+++++[<+++++>-]<+++++++.[-]
>++++++++++[<++++++++++>-]<++++++++++++++++.[-]
>++++++++++[<++++++++++>-]<+++++++++++.[-]
>+++++++[<+++++++>-]<+++++++++.[-]
>+++++[<+++++>-]<+++++++.[-]

===================================================================
======================== INPUT NUMBER  ============================
===================================================================
+                          cont=1
[
 -                         cont=0
 >,
 ======SUB10======
 ----------

 [                         not 10
  <+>                      cont=1
  =====SUB38======
  ----------
  ----------
  ----------
  --------

  >
  =====MUL10=======
  [>+>+<<-]>>[<<+>>-]<     dup

  >>>+++++++++
  [
   <<<
   [>+>+<<-]>>[<<+>>-]<    dup
   [<<+>>-]
   >>-
  ]
  <<<[-]<
  ======RMOVE1======
  <
  [>+<-]
 ]
 <
]
>>[<<+>>-]<<

===================================================================
======================= PROCESS NUMBER  ===========================
===================================================================

==== ==== ==== ====
numd numu teid teiu
==== ==== ==== ====

>+<-
[
 >+
 ======DUP======
 [>+>+<<-]>>[<<+>>-]<

 >+<--

 >>>>>>>>+<<<<<<<<   isprime=1

 [
  >+

  <-

  =====DUP3=====
  <[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<<<

  =====DUP2=====
  >[>>+>+<<<-]>>>[<<<+>>>-]<<< <

  >>>

  ====DIVIDES=======
  [>+>+<<-]>>[<<+>>-]<   DUP i=div

  <<
  [
    >>>>>+               bool=1
    <<<
    [>+>+<<-]>>[<<+>>-]< DUP
    [>>[-]<<-]           IF i THEN bool=0
    >>
    [                    IF i=0
      <<<<
      [>+>+<<-]>>[<<+>>-]< i=div
      >>>
      -                  bool=0
    ]
    <<<
    -                    DEC i
    <<
    -
  ]

  +>>[<<[-]>>-]<<
  >[-]<                  CLR div
  =====END DIVIDES====

  [>>>>>>[-]<<<<<<-]     if divides then isprime=0

  <<

  >>[-]>[-]<<<
 ]

 >>>>>>>>
 [
  -
  <<<<<<<[-]<<

  [>>+>+<<<-]>>>[<<<+>>>-]<<<

  >>

  ===================================================================
  ======================== OUTPUT NUMBER  ===========================
  ===================================================================
  [>+<-]>

  [
   ======DUP======
   [>+>+<<-]>>[<<+>>-]<

   ======MOD10====
   >+++++++++<
   [
    >>>+<<              bool= 1
    [>+>[-]<<-]         bool= ten==0
    >[<+>-]             ten = tmp
    >[<<++++++++++>>-]  if ten=0 ten=10
    <<-                 dec ten
    <-                  dec num
   ]
   +++++++++            num=9
   >[<->-]<             dec num by ten

   =======RROT======
      [>+<-]
   <  [>+<-]
   <  [>+<-]
   >>>[<<<+>>>-]
   <

   =======DIV10========
   >+++++++++<
   [
    >>>+<<                bool= 1
    [>+>[-]<<-]           bool= ten==0
    >[<+>-]               ten = tmp
    >[<<++++++++++>>>+<-] if ten=0 ten=10  inc div
    <<-                   dec ten
    <-                    dec num
   ]
   >>>>[<<<<+>>>>-]<<<<   copy div to num
   >[-]<                  clear ten

   =======INC1=========
   <+>
  ]

  <
  [
   =======MOVER=========
   [>+<-]

   =======ADD48========
   +++++++[<+++++++>-]<->

   =======PUTC=======
   <.[-]>

   ======MOVEL2========
   >[<<+>>-]<

   <-
  ]

  >++++[<++++++++>-]<.[-]

  ===================================================================
  =========================== END FOR ===============================
  ===================================================================

  >>>>>>>
 ]
 <<<<<<<<

 >[-]<
  [-]
 <<-
]

======LF========

++++++++++.[-]
@
</code>```

Example run:

```<code>$ python2 bf.py PRIME.BF
Primes up to: 100
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
</code>```

Body:
golfscript, partial solution only, 150 chars

:i;[0]30000*[]0 "#{File.open('f').read}"{{\(@=\''if}+['>+\\(@\\' '<@+\\)' '+1+256%' '-1- 256%' ".[0$]''+print " ',;i(\:i;' '[{.}{' ']}while']\%}%~;;;;

i am greatly indebted to the pattern of generating your own source and then eating it, as others have already posted.

misfeatures:

only parses brainfuck code from the file 'f'.

all input you want to read with ',' must be piped in at the beginning.

runs hello world, yet dies somewhere during prime.bf. i'm not sure why. i did read somewhere that golfscript is broken for nested while loops, so that might be it.

stores a char=>string map in a way that is entertainingly horrible, at least to me.

I've tried loading arbitrary files with constructions like "#{File.open(" "some_file.bf" ").read}" + + but Ruby seems to helpfully escape the "#" for me so i dont accidentally load the file im trying to load. On the other hand, embedding "#{getc}" works okay for reading from stdin, but there's still the restriction that input is non-interactive - only stuff piped in at the start is read. Anyone know a way around one or more of these input issues?

ContentLicense: CC BY-SA 2.5


问:
Emulate a 7-segment display

Task

The task is to display any of the 128 possible states of a
7-segment display.

Your program should accept a string of 7 characters ("bits") that are either 0 or 1.
First bit of input corresponds to segment A of the following illustration, the
second to B, etc (ignore dp):

How you represent the display is up to you -- a single Unicode or ASCII symbol,
ASCII art, grafically, or whatever you can come up with. However, each
input must have it's own distinct output. If you come up with something fancy I'm sure you can harvest upvotes by showing off some examples.

All 128 possible states of the display are:

Rules

Codegolf

As I said, any kind of output is allowed, but it would be nice if you specified it.

Input can be stdin or command line argument.

Examples

Input

```<code>1101101
</code>```

Output

As ASCII/Unicode:

```<code>2
</code>```

Different kinds of ASCII art (I'm not too good at this)

```<code> _   ╺┓  ╒╗   ---
 _|  ┏┛  ╔╝     |
|_   ┗╸  ╚╛   ---
              |
              ---
</code>```

答:
APL <s>101 86 73</s> 69

```<code>m←45⍴' '⋄m[¯40+⎕av⍳(⍎∊3/' ',¨⍕⍞)/')*+16;EJOQRSAFK-27=>?']←'⎕'⋄9 5⍴m
</code>```

Input is from the screen via ⍞

```<code>1101101
</code>```

Which produces a 9x5 character matrix composed of blanks and ⎕ as follows:

```<code> ⎕⎕⎕
     ⎕
     ⎕
     ⎕
 ⎕⎕⎕
⎕
⎕
⎕
 ⎕⎕⎕
</code>```

The seven digit number is converted into a partition vector to select the ⎕ co-ordinates.

Title: Emulate a 7-segment display

Body:
APL <s>101 86 73</s> 69

m←45⍴' '⋄m[¯40+⎕av⍳(⍎∊3/' ',¨⍕⍞)/')*+16;EJOQRSAFK-27=>?']←'⎕'⋄9 5⍴m

Input is from the screen via ⍞

1101101

Which produces a 9x5 character matrix composed of blanks and ⎕ as follows:

 ⎕⎕⎕
     ⎕
     ⎕
     ⎕
 ⎕⎕⎕
⎕
⎕
⎕
 ⎕⎕⎕

The seven digit number is converted into a partition vector to select the ⎕ co-ordinates.


Title: Print multiplication tables by input

Body:
jq, 15 characters

range(0;.*11;.)

Sample run:

bash-4.3$ jq 'range(0;.*11;.)' <<< 20
0
20
40
60
80
100
120
140
160
180
200

On-line test


答:
><>, 18 + 3 = 22 bytes

```<code>:?!n0$-:0):1go-
-~
</code>```

Try it online! +3 bytes for the  -v flag to initialise the stack with the input. If assuming that STDIN is empty is okay, then the following is a byte shorter:

```<code>:?!ni*:0):1go-
-~
</code>```

The program keeps flipping the input n as necessary until it reaches 0, after which it errors out.

```<code>[Loop]
:?!n      If n is 0, output it as a num. If this happens then the stack is now
          empty, and the next subtraction fails
0$-       Subtract n from 0
:0)       Push (n > 0)
:1go      Output the char at (n>0, 1) which is a char from the second line
-         Subtract, overall updating n -> -n-(n>0)
</code>```

Title: Bitflip and negate

Body:
Given an integer, make an expression that produces it from 0 using unary negation - and bitwise complement ~ (~n = -n-1), with the operators applied right to left.

```<code>...
-3  = ~-~-~0
-2  = ~-~0
-1  = ~0
 0  = 0
 1  = -~0
 2  = -~-~0
 3  = -~-~-~0
...
</code>```

Your expression must be as short as possible, which means no redundant parts of ~~, --, -0, or 00. Output or print the expression as a string or a sequence of characters.

var QUESTION_ID=92598,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/92598/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

Body:
><>, 18 + 3 = 22 bytes

:?!n0$-:0):1go-
-~

Try it online! +3 bytes for the  -v flag to initialise the stack with the input. If assuming that STDIN is empty is okay, then the following is a byte shorter:

:?!ni*:0):1go-
-~

The program keeps flipping the input n as necessary until it reaches 0, after which it errors out.

[Loop]
:?!n      If n is 0, output it as a num. If this happens then the stack is now
          empty, and the next subtraction fails
0$-       Subtract n from 0
:0)       Push (n > 0)
:1go      Output the char at (n>0, 1) which is a char from the second line
-         Subtract, overall updating n -> -n-(n>0)


答:
Java, <s>300</s> 298 bytes

```<code>import javax.swing.*;void c(String f)throws Exception{java.awt.image.BufferedImage r=javax.imageio.ImageIO.read(new java.io.File(f));for(int i=0;i++<r.getWidth();)for(int j=0;j++<r.getHeight();)r.setRGB(i,j,(0xFFFFFF-r.getRGB(i,j))|0xFF000000);JOptionPane.showMessageDialog(null,new ImageIcon(r));}
</code>```

Title: Invert png image

Body:
Create program or function that takes file name as an argument or reads it from standard input, and completes the following task:

Read image from a png file (name given as argument).

Reverse colors in that image, so that for example dark green (0, 75, 30) would become (255, 180, 225) (because 255-0=255, 255-75=180 and 255-30=225). You should not change alpha channel value.

Output that image to a file called a.png (in png format), or show it in GUI window.

This is code-golf. Standard loopholes apply.

Body:
Java, <s>300</s> 298 bytes

import javax.swing.*;void c(String f)throws Exception{java.awt.image.BufferedImage r=javax.imageio.ImageIO.read(new java.io.File(f));for(int i=0;i++<r.getWidth();)for(int j=0;j++<r.getHeight();)r.setRGB(i,j,(0xFFFFFF-r.getRGB(i,j))|0xFF000000);JOptionPane.showMessageDialog(null,new ImageIcon(r));}


答:
C (gcc), <s>445</s> <s>426</s> <s>452</s> <s>449</s> <s>444</s> 439 bytes

*t[]={0,0,"twenty","thirty","fourty",[10]="one hundred","third","fourth","fifth"},*o[101]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};i,p;main(j){for(;i<'e';i++)p=i%10,o[i]?puts(o[i]):printf("%s%s%s%s%s%s\n",p?o[p]:t,p?" and ":t,!t[j]&j%2?"half ":t,t[j]?t:j%2?t[j/2+9]:o[j/2],t[j]?t:" times ",t[j=i/10]?:t[2]);}
```

<p>Try it online!</p>

<p><s>19</s> <s>22</s> 27 bytes shaved off thanks to @ceilingcat, but 26 bytes were added again, 3 to prevent a segfault (o[] really has to have 101 entries), and upon checking the rules again I noticed we had to print out all numbers from 0 to 100, not just provide a function that printed one number.</p>

<p>Ungolfed:</p>

<pre class="lang-c prettyprint-override"><code>char *t[] = {0, 0, "twenty", "thirty", "fourty", 0, 0, 0, 0, 0, "one hundred", "third", "fourth", "fifth"};
char *o[101] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
                "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
int i = 0;
int j = 0;
int p = 0;

main()
{
  for(; i < 101; i++) {
    p = i % 10;
    if(o[i])
        puts(o[i]);
    else
        printf("%s%s%s%s%s%s\n",
               p ? o[p] : "",
               p ? " and " : "",
               !t[j] & j % 2 ? "half " : "",
               t[j] ? "" : j % 2 ? t[j / 2 + 9] : o[j / 2],
               t[j] ? "" : " times ",
               t[j = i / 10] ? : t[2]
        );
  }
}
<span class="math-container">```
```

Title: Count to 100 in Danish

Body:
C (gcc), <s>445</s> <s>426</s> <s>452</s> <s>449</s> <s>444</s> 439 bytes

*t[]={0,0,"twenty","thirty","fourty",[10]="one hundred","third","fourth","fifth"},*o[101]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};i,p;main(j){for(;i<'e';i++)p=i%10,o[i]?puts(o[i]):printf("%s%s%s%s%s%s\n",p?o[p]:t,p?" and ":t,!t[j]&j%2?"half ":t,t[j]?t:j%2?t[j/2+9]:o[j/2],t[j]?t:" times ",t[j=i/10]?:t[2]);}

Try it online!

<s>19</s> <s>22</s> 27 bytes shaved off thanks to @ceilingcat, but 26 bytes were added again, 3 to prevent a segfault (o[] really has to have 101 entries), and upon checking the rules again I noticed we had to print out all numbers from 0 to 100, not just provide a function that printed one number.

Ungolfed:

char *t[] = {0, 0, "twenty", "thirty", "fourty", 0, 0, 0, 0, 0, "one hundred", "third", "fourth", "fifth"};
char *o[101] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
                "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
int i = 0;
int j = 0;
int p = 0;

main()
{
  for(; i < 101; i++) {
    p = i % 10;
    if(o[i])
        puts(o[i]);
    else
        printf("%s%s%s%s%s%s\n",
               p ? o[p] : "",
               p ? " and " : "",
               !t[j] & j % 2 ? "half " : "",
               t[j] ? "" : j % 2 ? t[j / 2 + 9] : o[j / 2],
               t[j] ? "" : " times ",
               t[j = i / 10] ? : t[2]
        );
  }
}
```


Title: Bitflip and negate

Body:
PHP, 58 bytes

<?=((0<$a=$argv[1])?'-':'').str_pad('0',2*abs($a),'~-',0);


Title: Count to 100 in Danish

Body:
Fourier, 7028 bytes

The bounty will go to Paul Schmitz's answer

This was golfed programmatically using issacg's golfing program

[encoded data, 7028 characters]

<a href="http://fourier.tryitonline.net/#[encoded data, 9376 characters]" rel="nofollow noreferrer">Try it online!


答:
Forth, 31 bytes

Pretty simple answer. Leaves n on the stack.

```<code>: f 10 0 DO dup I 1+ * . LOOP ;
</code>```

Try it online

Title: Print multiplication tables by input

Body:
In this challenge you've to print multiplication tables by input, Here are some examples:

```<code>Input: 2

Output:
0 2  4 6 8  10  12  14  16  18  20

Input: 20

Output: 20 40 60 80 100 120 140 160 180 200
</code>```

Rules

The shortest code in bytes wins.

This challenge is a code-golf, It follows code-golf general rules (code-golf)

If, just if, your code can't print number, you can use letters, Here is an example:

Input: B

Output: B D F H J L N P R T

You can choose to start from 0 or your number (like 20). You can choose if put spaces or don't. The challenge is free, just take an input and print multiplication tables.

Your output must list the first 10 members of the times table for the given number. You may leave out 0*n.

Body:
Forth, 31 bytes

Pretty simple answer. Leaves n on the stack.

: f 10 0 DO dup I 1+ * . LOOP ;

Try it online


问:
Print a 10 by 10 grid of asterisks

Background

This is a standard textbook example to demonstrate for loops.

This is one of the first programs I learnt when I started learning programming ~10 years ago.

Task

You are to print this exact text:

```<code>**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
</code>```

Specs

You may have extra trailing newlines.

You may have extra trailing spaces (U+0020) at the end of each line, including the extra trailing newlines.

Scoring

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

答:
Groovy 46 Bytes

```<code>(1..10).collect{''.center(10,'*')}.join('\n')
</code>```

https://groovyconsole.appspot.com/script/5102912250314752

Title: Print a 10 by 10 grid of asterisks

Body:
Groovy 46 Bytes

(1..10).collect{''.center(10,'*')}.join('\n')

https://groovyconsole.appspot.com/script/5102912250314752


答:
Befunge 93 : 24 bytes

```<code>&:01+*.20g1+:"9"`#@_20p#
</code>```

Fairly straightforward. Uses get and put instructions to keep track of the iterator.

Title: Print multiplication tables by input

Body:
Befunge 93 : 24 bytes

&:01+*.20g1+:"9"`#@_20p#

Fairly straightforward. Uses get and put instructions to keep track of the iterator.


答:
Python (107)

Definitely more golfable.

```<code>a=map(int,raw_input())
for i in(0,6,3):print' .. '*a[i]+('\n'+' .'[a[5-i/6]]+'  '+' .'[a[1+i/6]])*(2*(i!=3))
</code>```

Output:

```<code>1101101
 ..
   .
   .
 ..
.
.
 ..
</code>```

Explanation:

```<code>a is a list of booleans extracted from the input.
When you multiply a string with a number, it will return the string repeated (number) times.
If that number happens to be zero, it returns an empty string.
i is iterated through 0 (pos A), 6 (pos G), and 3 (pos D).
' .. ' will print either section A, G, or D, depending on the value of i.
([string here])*(2*(i!=3)) will print [string here] twice only if i!=3.
Breaking down [string here]:
 - '\n' will print a newline for each repetition.
 - '  ' is the null space between horizontal sections.
 - ' .'[(bool)] will return either ' ' if (bool) is 0, and '.' if (bool) is 1.
 - 5-i/6 will return 5 if i=0 and 4 if i=6. a[5] is section F and a[4] is section E.
 - 1+i/6 will return 1 if i=0 and 2 if i=6. a[1] is section B and a[2] is section C.
</code>```

Title: Emulate a 7-segment display

Body:
Task

The task is to display any of the 128 possible states of a
7-segment display.

Your program should accept a string of 7 characters ("bits") that are either 0 or 1.
First bit of input corresponds to segment A of the following illustration, the
second to B, etc (ignore dp):

How you represent the display is up to you -- a single Unicode or ASCII symbol,
ASCII art, grafically, or whatever you can come up with. However, each
input must have it's own distinct output. If you come up with something fancy I'm sure you can harvest upvotes by showing off some examples.

All 128 possible states of the display are:

Rules

Codegolf

As I said, any kind of output is allowed, but it would be nice if you specified it.

Input can be stdin or command line argument.

Examples

Input

```<code>1101101
</code>```

Output

As ASCII/Unicode:

```<code>2
</code>```

Different kinds of ASCII art (I'm not too good at this)

```<code> _   ╺┓  ╒╗   ---
 _|  ┏┛  ╔╝     |
|_   ┗╸  ╚╛   ---
              |
              ---
</code>```

Body:
Python (107)

Definitely more golfable.

a=map(int,raw_input())
for i in(0,6,3):print' .. '*a[i]+('\n'+' .'[a[5-i/6]]+'  '+' .'[a[1+i/6]])*(2*(i!=3))

Output:

1101101
 ..
   .
   .
 ..
.
.
 ..

Explanation:

a is a list of booleans extracted from the input.
When you multiply a string with a number, it will return the string repeated (number) times.
If that number happens to be zero, it returns an empty string.
i is iterated through 0 (pos A), 6 (pos G), and 3 (pos D).
' .. ' will print either section A, G, or D, depending on the value of i.
([string here])*(2*(i!=3)) will print [string here] twice only if i!=3.
Breaking down [string here]:
 - '\n' will print a newline for each repetition.
 - '  ' is the null space between horizontal sections.
 - ' .'[(bool)] will return either ' ' if (bool) is 0, and '.' if (bool) is 1.
 - 5-i/6 will return 5 if i=0 and 4 if i=6. a[5] is section F and a[4] is section E.
 - 1+i/6 will return 1 if i=0 and 2 if i=6. a[1] is section B and a[2] is section C.


答:
T-SQL 61 bytes

Replace n with the number for which table needs to be populated. Demo

```<code>SELECT TOP 11 number*n FROM master..spt_values WHERE type='P'
</code>```

spt_value is a undocumented table in SQL Server, you can read more about this table in

Purpose and meaning of spt_values table

What does Spt_value means

I hope someone will come up with better TSQL solution.

Title: Print multiplication tables by input

Body:
T-SQL 61 bytes

Replace n with the number for which table needs to be populated. Demo

SELECT TOP 11 number*n FROM master..spt_values WHERE type='P'

spt_value is a undocumented table in SQL Server, you can read more about this table in

Purpose and meaning of spt_values table

What does Spt_value means

I hope someone will come up with better TSQL solution.


问:
HexaGolf: Rotatagons
See also: Wordagons

Challenge

Given a hexagon and a number n as input, output the same hexagon rotated n times.

Hexagon

The hexagon will be a string like so:

```<code>  a b c
 d d e e
f f o g g
 h h i i
  j k l
</code>```

The hexagon will always be regular and will only ever contain the printable ASCII characters:

```<code> !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
</code>```

Rotation

To find how much to rotate the hexagon by, multiply n by 60 degrees to get the angle of rotation. For example, using the above hexagon, if n is 2, we multiply that by 60 to get 120 degrees. Then, we rotate the hexagon by 120 degrees:

```<code>  j h f
 k h f d
l i o d a
 i g e b
  g e c
</code>```

Note that each side has moved two sides clockwise.

If n is positive, you should rotate the hexagon clockwise. If n is negative, you should rotate the hexagon anticlockwise.

n will always be an integer in the range -6 to 6 inclusive.

Examples

Input:

```<code>  . u .
 .  |  .
l - + - r
 .  |  .
  . d .
</code>```

n = 3

```<code>  . d .
 .  |  .
r - + - l
 .  |  .
  . u .
</code>```

Input:

```<code>  - - -
 /     \
<       >
 \     /
  - - -
</code>```

n = -1

Output:

```<code>  - \ >
 -     /
-       -
 /     -
  < \ -
</code>```

Input:

```<code>   h e x a
  g o n s a
 n d t r i a
n g l e s m a
 k e m e s a
  d l y m a
   d d e r
</code>```

n = 6

Output:

```<code>   h e x a
  g o n s a
 n d t r i a
n g l e s m a
 k e m e s a
  d l y m a
   d d e r
</code>```

Winning

The shortest program in bytes wins.

答:
JavaScript (ES6), <s>130</s> 127 bytes

```<code>f=(s,n)=>n%6?f(s.split`
`.map((s,i,a)=>s.replace(/./g,(c,j)=>(a[(i+z-j)/2+z]||c)[(i+j-z)/2+i]||c,z=a.length>>1)).join`
`,n-1):s
</code>```

Originally based on my answer to Rotate a diamond tiling although I might now be able to rewrite that answer along the lines of this answer.

Title: HexaGolf: Rotatagons

Body:
JavaScript (ES6), <s>130</s> 127 bytes

f=(s,n)=>n%6?f(s.split`
`.map((s,i,a)=>s.replace(/./g,(c,j)=>(a[(i+z-j)/2+z]||c)[(i+j-z)/2+i]||c,z=a.length>>1)).join`
`,n-1):s

Originally based on my answer to Rotate a diamond tiling although I might now be able to rewrite that answer along the lines of this answer.


问:
RGB Gradients Generation
The Challenge

Given the two uppercase hexadecimal strings (both 6 characters long, XXXXXX and YYYYYY) representing RGB values (ranging from 000000 to FFFFFF inclusive), and a positive non-zero integer N, display a linear transition of the N+2 colors generated from XXXXXX to YYYYYY that would result in a color gradient.

Example

Input

```<code>FF3762
F08800
9
</code>```

Output

Please note in our example, I've requested 9 interim steps between the two colors, therefore 11 lines will be displayed from initial color to the final color

```<code>FF3762
FD3F58
FC474E
FA4F44
F9573A
F75F31
F66727
F46F1D
F37713
F17F09
F08800
</code>```

Caveats

While I've gone with a simple linear process of deriving the integer values for the interim colors before converting them back into hexadecimal, your methods may vary. Please consider the various ways one could round up/down your numbers accordingly.

Testing

To make this interesting, I've provided a snippet to allow testing of your code, inclusive of a button to provide you with two random colors to test your code against. Displaying your results is optional, but it's encouraged!

c1=()=>('00000'+(Math.random()*(1<<24)|0).toString(16)).slice(-6);

$("#col").click(function(){
  alert("Your two colors are: "+c1()+" and "+c1()+".");
});

$("#colors").blur(function(){
  $("#test").empty();
 var colArr = $("#colors").val().split("\n");
 for(c in colArr){
   $("#test").append('
'+colArr[c]+'
')
  }

});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.tester{height: 20px;
width: 60px;padding: 4px;border: 1px solid black;}</code>```

<button id="col">Your two colors</button>

<textarea id="colors"></textarea>

```

1) You can access two random colors for your test by clicking on the "Your two colors" button.
2) The number of interim steps will be the same as the number of characters in your PPCG username inclusive of spaces, in the case of "WallyWest" it would be 9 (as per my example above).
3) Run your code with the two colors and the number and once you have your generated list, you have the option of pasting your output into the textarea and tabbing away from it to get your generated color gradient.

My example is shown here:

I must admit, that looks pretty awesome!

Please note: As I mentioned, showing your testing of your output using the snippet is optional, but it's encouraged! :)

Output

The list output must be in the form of N+2 sets of 6 digit hex numbers separated by line feeds (\n) as shown in my example above. Output can be in the form of separate lines, space/comma separated list, an array or whatever is best suited for your language... (Thanks @nimi for the heads up) Please remember, that if you plan on testing your code with the snippet, however you separate each "color" is up to you.

Rules

This is code-golf, so the shortest solution in bytes will be crowned the winner. No loopholes, naturally. Input must accept the two strings and a number (which as I said will be equivalent to the number of letters in your username on PPCG, thus your resulting output will always be a minimum of three lines long.

答:
R, 68 bytes

There is a built-in function that interpolates two colours:

```<code>a=scan(,'')
colorRampPalette(paste0("#",a[1:2]))(as.numeric(a[3])+2)
</code>```

Input:

```<code>d9e7a5
3ef951
15
</code>```

Output: a vector with values

```<code>"#D9E7A5" "#CFE89F" "#C5E99A" "#BBEA95" "#B2EB90" "#A8EC8A" "#9EED85" "#95EE80"
"#8BF07B" "#81F175" "#78F270" "#6EF36B" "#64F466" "#5BF560" "#51F65B" "#47F756"
"#3EF951"
</code>```

Colour specification in R requires a hash symbol.

Let’s plot something, like a function:

```<code>filled.contour(outer(1:20, 1:20, function(x,y) sin(sqrt(x*y)/3)),
    col = colorRampPalette(paste0("#",a[1:2]))(as.numeric(a[3])+2))
</code>```

Title: RGB Gradients Generation

Body:
R, 68 bytes

There is a built-in function that interpolates two colours:

a=scan(,'')
colorRampPalette(paste0("#",a[1:2]))(as.numeric(a[3])+2)

Input:

d9e7a5
3ef951
15

Output: a vector with values

"#D9E7A5" "#CFE89F" "#C5E99A" "#BBEA95" "#B2EB90" "#A8EC8A" "#9EED85" "#95EE80"
"#8BF07B" "#81F175" "#78F270" "#6EF36B" "#64F466" "#5BF560" "#51F65B" "#47F756"
"#3EF951"

Colour specification in R requires a hash symbol.

Let’s plot something, like a function:

filled.contour(outer(1:20, 1:20, function(x,y) sin(sqrt(x*y)/3)),
    col = colorRampPalette(paste0("#",a[1:2]))(as.numeric(a[3])+2))


问:
Slowly turn a string into another

The Challenge

Given two strings/an array of strings, output the first string slowly shrinking and expanding back into the second string.

You can assume the strings will always start with the same character.

Example

```<code>Input:
"Test", "Testing"

Output:
Test
Tes
Te
T
Te
Tes
Test
Testi
Testin
Testing
</code>```

First you output the first word:

```<code>Test
</code>```

Then you keep removing one letter until the string is one character long:

```<code>Tes
Te
T
</code>```

Then keep adding one letter of the second word until it's done:

```<code>Te
Tes
Test
Testi
Testin
Testing
</code>```

(if both strings are one character long, then just output one of them once.)

Test Cases

```<code>"Hello!", "Hi."
Hello!
Hello
Hell
Hel
He
H
Hi
Hi.

"O", "O"

O

"z", "zz"

z
zz

".vimrc", ".minecraft"

.vimrc
.vimr
.vim
.vi
.v
.
.m
.mi
.min
.mine
.minec
.minecr
.minecra
.minecraf
.minecraft

"     ", "   "

SSSSS
SSSS
SSS
SS
S
SS
SSS

"0123456789", "02468"

0123456789
012345678
01234567
0123456
012345
01234
0123
012
01
0
02
024
0246
02468
</code>```

(note: on the space/fourth test case, replace the S with spaces)

Rules

This is code-golf, so shortest answer in bytes wins! Tiebreaker is most upvoted post. Winner will be chosen on 09/10/2016.

Standard loopholes are forbidden.

答:
I guess I can beat a few with Groovy here...

Groovy (96 Bytes)

```<code>def x(a,b,c){(a..b).each{println c.substring(0,it)}};{y,z->x(y.length(),1,y);x(1,z.length(),z);}
</code>```

Try it:
https://groovyconsole.appspot.com/script/5190971159478272

Explanation:

X is a closure to print the substring from 0 to x from (a to b) for all integers from a to b.

The second closure passes the first word from it's length to 1 then does the second word in reverse order.

Title: Slowly turn a string into another

Body:
I guess I can beat a few with Groovy here...

Groovy (96 Bytes)

def x(a,b,c){(a..b).each{println c.substring(0,it)}};{y,z->x(y.length(),1,y);x(1,z.length(),z);}

Try it:
https://groovyconsole.appspot.com/script/5190971159478272

Explanation:

X is a closure to print the substring from 0 to x from (a to b) for all integers from a to b.

The second closure passes the first word from it's length to 1 then does the second word in reverse order.


问:
Faux Source Code
Output one random character for each character of source code (as illustrated below). The probability of each character is its frequency in the original source code. Thus the output will be fake source code resembling a quine.

Specification

Restrictions

Standard quine constrains apply. No empty programs or functions. Also no reading your own source.

Output

The number of characters output should be exactly the number of characters in the source code

Each output character should be randomly choosen

The probability of choosing any character is equal to (occurrences in source) / (length of source)

This means that even a unary solution needs to 'randomly' choose 1 with probability 1. Which is to say that the output can't be hard coded.

Winning

This is code golf, so fewest bytes wins

Example

```<code>Program           Frequency           Probability           Possible Output
-------           ---------           -----------           ---------------
 a@!@              a - 1               a - 25%               @@a@
                   ! - 1               ! - 25%
                   @ - 2               @ - 50%
</code>```

```<code>Program           Frequency           Probability           Possible Output
-------           ---------           -----------           ---------------
caBaDBcDaBDB       a - 3               a - 25%               aaaBBBBccDDD
                   B - 4               B - 33%
                   c - 2               c - 17%
                   D - 3               D - 25%
</code>```

答:
CJam, 14 bytes

```<code>{{E*`mR}`mR}E*
</code>```

Try it online!

Explanation

Each character appears exactly twice, so the probabilities of the characters should all be the same.

```<code>{           e# Repeat this block 14 times.
  {E*`mR}   e# Push this (nonsensical) block.
  `         e# Stringify it, giving the string "{E*`mR}", which contains each of the
            e# seven characters once.
  mR        e# Select one of the characters at random.
}E*
</code>```

Title: Faux Source Code

Body:
CJam, 14 bytes

{{E*`mR}`mR}E*

Try it online!

Explanation

Each character appears exactly twice, so the probabilities of the characters should all be the same.

{           e# Repeat this block 14 times.
  {E*`mR}   e# Push this (nonsensical) block.
  `         e# Stringify it, giving the string "{E*`mR}", which contains each of the
            e# seven characters once.
  mR        e# Select one of the characters at random.
}E*


答:
Java <s>8</s> 7, <s>512</s> 490 + 19(import) bytes

Needs an import import java.util.*;

<T>void y(List<T>l,T...a){for(T t:a)l.add(t);}List x(){String b="teen",c="twenty",d="half ",e=" times "+c;String[]a={"zero","one","two","three","four","five","six","seven","eight","nine"},f={c,"thirty","fourty",d+"third"+e,a[3]+e,d+"fourth"+e,a[4]+e,d+"fifth"+e};List<String>g=new ArrayList<>(Arrays.asList(a));y(g,"ten","eleven","twelve","thir"+b,a[4]+b,"fif"+b,a[6]+b,a[7]+b,"eigh"+b,a[9]+b);for(String h:f){y(g,h);for(int i=1;i<=9;i++)y(g,(a[i]+" and "+h));}y(g,"one hundred");return g;}
```

<p><strong>Ungolfed:</strong></p>

<pre class="lang-java prettyprint-override"><code><T> void y(List<T> l, T... a) {
    for (T t : a) {
        l.add(t);
    }
}

List x() {
    String b = "teen", c = "twenty", d = "half ", e = " times " + c;
    String[] a = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"},
        f = {c, "thirty", "fourty", d + "third" + e, a[3] + e, d + "fourth" + e, a[4] + e, d + "fifth" + e};
    List<String> g = new ArrayList<>(Arrays.asList(a));
    y(g, "ten", "eleven", "twelve", "thir" + b, a[4] + b, "fif" + b, a[6] + b, a[7] + b, "eigh" + b, a[9] + b);

    for (String h : f) {
        y(g, h);
        for (int i = 1; i <= 9; i++) {
            y(g, (a[i] + " and " + h));
        }
    }

    y(g, "one hundred");
    return g;
}
</code>```

To run this, simply call <instance>.x();. This now returns the list containing all numbers.

Try it here!

Title: Count to 100 in Danish

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

How they count

Like English, they have dedicated words for 0-20, 30, 40 and 100

Instead of saying twenty-one and twenty-two, they say one and twenty and two and twenty

Starting with fifty they say multiples of 10 as n*20

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

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

Expected output

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

Rules

You may use any separator to separate the numbers

Due to a typo in the original specification, you may use forth instead of fourth.

You may write a function or write to std-out

Standard loopholes apply

This is codegolf; shortest code in bytes win!

Body:
Java <s>8</s> 7, <s>512</s> 490 + 19(import) bytes

Needs an import import java.util.*;

<T>void y(List<T>l,T...a){for(T t:a)l.add(t);}List x(){String b="teen",c="twenty",d="half ",e=" times "+c;String[]a={"zero","one","two","three","four","five","six","seven","eight","nine"},f={c,"thirty","fourty",d+"third"+e,a[3]+e,d+"fourth"+e,a[4]+e,d+"fifth"+e};List<String>g=new ArrayList<>(Arrays.asList(a));y(g,"ten","eleven","twelve","thir"+b,a[4]+b,"fif"+b,a[6]+b,a[7]+b,"eigh"+b,a[9]+b);for(String h:f){y(g,h);for(int i=1;i<=9;i++)y(g,(a[i]+" and "+h));}y(g,"one hundred");return g;}

Ungolfed:

<T> void y(List<T> l, T... a) {
    for (T t : a) {
        l.add(t);
    }
}

List x() {
    String b = "teen", c = "twenty", d = "half ", e = " times " + c;
    String[] a = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"},
        f = {c, "thirty", "fourty", d + "third" + e, a[3] + e, d + "fourth" + e, a[4] + e, d + "fifth" + e};
    List<String> g = new ArrayList<>(Arrays.asList(a));
    y(g, "ten", "eleven", "twelve", "thir" + b, a[4] + b, "fif" + b, a[6] + b, a[7] + b, "eigh" + b, a[9] + b);

    for (String h : f) {
        y(g, h);
        for (int i = 1; i <= 9; i++) {
            y(g, (a[i] + " and " + h));
        }
    }

    y(g, "one hundred");
    return g;
}

To run this, simply call <instance>.x();. This now returns the list containing all numbers.

Try it here!


答:
PseudoD, <s>688</s> <s>579</s> 521 bytes

```<code>utilizar mate.pseudo
utilizar entsal.pseudo
adquirir n
adquirir a
adquirir r
adquirir i
fijar n a llamar LeerPalabra finargs
si son iguales n y CERO
escribir {0}
salir
fin
fijar a a llamar ValorAbsoluto n finargs
fijar i a CERO
si comparar Importar.Ent.Comparar n < CERO
fijar r a {~}
sino
fijar r a {-}
fin
mientras comparar Importar.Ent.Comparar i < a
escribir r finargs
si son iguales r y {~}
fijar r a {-}
Importar.Ent.Sumar i UNO i
sino
fijar r a {~}
fin
finbucle
si son iguales r y {~}
escribir {~}
fin
escribir {0}
</code>```

Explain:

```<code>Read a number from STDIN;
If the number is zero (0); Then:
    Writes 0 to STDOUT and exits;
End If;
If the number is less than zero (0); Then:
    Set the fill character to "~";
Else:
    Set the fill character to "-";
End If;
For i = 0; While i is less than abs(number); do:
    Write the fill character to STDOUT;
    If the fill character is "~":
        Set the fill character to "-"
        Increment i by one
    Else:
        Set the fill character to "~"
    End if;
End for;
If the fill character is "~"; Then:
    Write "~" to STDOUT;
End If;
Write "0" to STDOUT
</code>```

Title: Bitflip and negate

Body:
Given an integer, make an expression that produces it from 0 using unary negation - and bitwise complement ~ (~n = -n-1), with the operators applied right to left.

```<code>...
-3  = ~-~-~0
-2  = ~-~0
-1  = ~0
 0  = 0
 1  = -~0
 2  = -~-~0
 3  = -~-~-~0
...
</code>```

Your expression must be as short as possible, which means no redundant parts of ~~, --, -0, or 00. Output or print the expression as a string or a sequence of characters.

var QUESTION_ID=92598,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/92598/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

Body:
PseudoD, <s>688</s> <s>579</s> 521 bytes

utilizar mate.pseudo
utilizar entsal.pseudo
adquirir n
adquirir a
adquirir r
adquirir i
fijar n a llamar LeerPalabra finargs
si son iguales n y CERO
escribir {0}
salir
fin
fijar a a llamar ValorAbsoluto n finargs
fijar i a CERO
si comparar Importar.Ent.Comparar n < CERO
fijar r a {~}
sino
fijar r a {-}
fin
mientras comparar Importar.Ent.Comparar i < a
escribir r finargs
si son iguales r y {~}
fijar r a {-}
Importar.Ent.Sumar i UNO i
sino
fijar r a {~}
fin
finbucle
si son iguales r y {~}
escribir {~}
fin
escribir {0}

Explain:

Read a number from STDIN;
If the number is zero (0); Then:
    Writes 0 to STDOUT and exits;
End If;
If the number is less than zero (0); Then:
    Set the fill character to "~";
Else:
    Set the fill character to "-";
End If;
For i = 0; While i is less than abs(number); do:
    Write the fill character to STDOUT;
    If the fill character is "~":
        Set the fill character to "-"
        Increment i by one
    Else:
        Set the fill character to "~"
    End if;
End for;
If the fill character is "~"; Then:
    Write "~" to STDOUT;
End If;
Write "0" to STDOUT


问:
Invalid Invali Inval
This idea is loosely based upon @TùxCräftîñg's chat message.

Take a look at the below example sequence:

INVALID0, INVALID1, INVALID2 INVALID3, INVALID4... INVALID9

After INVALID9, it goes on like this:

INVALI0, INVALI1, INVALI2, INVALI3... INVALI9

And after INVALI9, it's like this:

INVAL0,INVAL1, INVAL2, INVAL3... INVAL9

After, INVAL9, it's like this:

INVA0, INVA1, INVA2, INVA3, ... INVA9

Notice how we we kept removing a letter from the word INVALID each time.

You'll keep repeating this until you reach a single letter, that is, the letter I:

I0, I1, I2, I3, I4 ... I9

Now, your task is, to take an input of a word, and produce a sequence from it like the above example. Your code must also work with single letters, and in that case the resulting sequence will be shorter.

You may choose any input and output format that you prefer (with or without a separator, as you wish), but you must specify which one you have chosen.

The sequence needs to be in the exact specified order.

The shortest code, in bytes, that successfully completes this challenge, wins the challenge.

Full sequence in the above example:

```<code>INVALID0, INVALID1, INVALID2, INVALID3, INVALID4, INVALID5, INVALID6, INVALID7, INVALID8, INVALID9, INVALI0, INVALI1, INVALI2, INVALI3, INVALI4, INVALI5, INVALI6, INVALI7, INVALI8, INVALI9, INVAL0, INVAL1, INVAL2, INVAL3, INVAL4, INVAL5, INVAL6, INVAL7, INVAL8, INVAL9, INVA0, INVA1, INVA2, INVA3, INVA4, INVA5, INVA6, INVA7, INVA8, INVA9, INV0, INV1, INV2, INV3, INV4, INV5, INV6, INV7, INV8, INV9, IN0, IN1, IN2, IN3, IN4, IN5, IN6, IN7, IN8, IN9, I0, I1, I2, I3, I4, I5, I6, I7, I8, I9
</code>```

Other examples:

Input: MAYBE (Uppercase and lowercase don't matter)

Output:

```<code>MAYBE0, MAYBE1, MAYBE2, MAYBE3, MAYBE4, MAYBE5, MAYBE6, MAYBE7, MAYBE8, MAYBE9, MAYB0, MAYB1, MAYB2, MAYB3, MAYB4, MAYB5, MAYB6, MAYB7, MAYB8, MAYB9, MAY0, MAY1, MAY2, MAY3, MAY4, MAY5, MAY6, MAY7, MAY8, MAY9, MA0, MA1, MA2, MA3, MA4, MA5, MA6, MA7, MA8, MA9, M0, M1, M2, M3, M4, M5, M6, M7, M8, M9
</code>```

Input: AFTER

Output:

```<code>AFTER0, AFTER1, AFTER2, AFTER3, AFTER4, AFTER5, AFTER6, AFTER7, AFTER8, AFTER9, AFTE0, AFTE1, AFTE2, AFTE3, AFTE4, AFTE5, AFTE6, AFTE7, AFTE8, AFTE9, AFT0, AFT1, AFT2, AFT3, AFT4, AFT5, AFT6, AFT7, AFT8, AFT9, AF0, AF1, AF2, AF3, AF4, AF5, AF6, AF7, AF8, AF9, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9
</code>```

Input: WHAT ARE YOU DOING

```<code>WHAT ARE YOU DOING0, WHAT ARE YOU DOING1, WHAT ARE YOU DOING2, WHAT ARE YOU DOING3, WHAT ARE YOU DOING4, WHAT ARE YOU DOING5, WHAT ARE YOU DOING6, WHAT ARE YOU DOING7, WHAT ARE YOU DOING8, WHAT ARE YOU DOING9, WHAT ARE YOU DOIN0, WHAT ARE YOU DOIN1, WHAT ARE YOU DOIN2, WHAT ARE YOU DOIN3, WHAT ARE YOU DOIN4, WHAT ARE YOU DOIN5, WHAT ARE YOU DOIN6, WHAT ARE YOU DOIN7, WHAT ARE YOU DOIN8, WHAT ARE YOU DOIN9, WHAT ARE YOU DOI0, WHAT ARE YOU DOI1, WHAT ARE YOU DOI2, WHAT ARE YOU DOI3, WHAT ARE YOU DOI4, WHAT ARE YOU DOI5, WHAT ARE YOU DOI6, WHAT ARE YOU DOI7, WHAT ARE YOU DOI8, WHAT ARE YOU DOI9, WHAT ARE YOU DO0, WHAT ARE YOU DO1, WHAT ARE YOU DO2, WHAT ARE YOU DO3, WHAT ARE YOU DO4, WHAT ARE YOU DO5, WHAT ARE YOU DO6, WHAT ARE YOU DO7, WHAT ARE YOU DO8, WHAT ARE YOU DO9, WHAT ARE YOU D0, WHAT ARE YOU D1, WHAT ARE YOU D2, WHAT ARE YOU D3, WHAT ARE YOU D4, WHAT ARE YOU D5, WHAT ARE YOU D6, WHAT ARE YOU D7, WHAT ARE YOU D8, WHAT ARE YOU D9, WHAT ARE YOU 0, WHAT ARE YOU 1, WHAT ARE YOU 2, WHAT ARE YOU 3, WHAT ARE YOU 4, WHAT ARE YOU 5, WHAT ARE YOU 6, WHAT ARE YOU 7, WHAT ARE YOU 8, WHAT ARE YOU 9, WHAT ARE YOU0, WHAT ARE YOU1, WHAT ARE YOU2, WHAT ARE YOU3, WHAT ARE YOU4, WHAT ARE YOU5, WHAT ARE YOU6, WHAT ARE YOU7, WHAT ARE YOU8, WHAT ARE YOU9, WHAT ARE YO0, WHAT ARE YO1, WHAT ARE YO2, WHAT ARE YO3, WHAT ARE YO4, WHAT ARE YO5, WHAT ARE YO6, WHAT ARE YO7, WHAT ARE YO8, WHAT ARE YO9, WHAT ARE Y0, WHAT ARE Y1, WHAT ARE Y2, WHAT ARE Y3, WHAT ARE Y4, WHAT ARE Y5, WHAT ARE Y6, WHAT ARE Y7, WHAT ARE Y8, WHAT ARE Y9, WHAT ARE 0, WHAT ARE 1, WHAT ARE 2, WHAT ARE 3, WHAT ARE 4, WHAT ARE 5, WHAT ARE 6, WHAT ARE 7, WHAT ARE 8, WHAT ARE 9, WHAT ARE0, WHAT ARE1, WHAT ARE2, WHAT ARE3, WHAT ARE4, WHAT ARE5, WHAT ARE6, WHAT ARE7, WHAT ARE8, WHAT ARE9, WHAT AR0, WHAT AR1, WHAT AR2, WHAT AR3, WHAT AR4, WHAT AR5, WHAT AR6, WHAT AR7, WHAT AR8, WHAT AR9, WHAT A0, WHAT A1, WHAT A2, WHAT A3, WHAT A4, WHAT A5, WHAT A6, WHAT A7, WHAT A8, WHAT A9, WHAT 0, WHAT 1, WHAT 2, WHAT 3, WHAT 4, WHAT 5, WHAT 6, WHAT 7, WHAT 8, WHAT 9, WHAT0, WHAT1, WHAT2, WHAT3, WHAT4, WHAT5, WHAT6, WHAT7, WHAT8, WHAT9, WHA0, WHA1, WHA2, WHA3, WHA4, WHA5, WHA6, WHA7, WHA8, WHA9, WH0, WH1, WH2, WH3, WH4, WH5, WH6, WH7, WH8, WH9, W0, W1, W2, W3, W4, W5, W6, W7, W8, W9
</code>```

Leaderboard

var QUESTION_ID=92156,OVERRIDE_USER=58717;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

Title: Invalid Invali Inval

Body:
sed 107

s/$/HH/;:;s/..$/0/p;s/.$/1/p;s/.$/2/p;s/.$/3/p;s/.$/4/p
s/.$/5/p;s/.$/6/p;s/.$/7/p;s/.$/8/p;s/.$/9/p;/.../b


答:
C, 106

Size is 74 chars if allowed to rename program "W00WG5WW1GW66WG4WW2GW33WG"

```<code>main(int i,char**s){
    for(s[0]="W00WG5WW1GW66WG4WW2GW33WG";i=*s[0]++;putchar(s[1][i&7]-49?i==71?10:32:42));
}
</code>```

running:

```<code>./a.out 1101101
 **
   *
 **
*
 **
</code>```

notes:

'W' and 'G' (0x47 and 0x57) are chosen such that the value & 7 = 7, i.e they safely index the null character that terminates the input string.

Title: Emulate a 7-segment display

Body:
C, 106

Size is 74 chars if allowed to rename program "W00WG5WW1GW66WG4WW2GW33WG"

main(int i,char**s){
    for(s[0]="W00WG5WW1GW66WG4WW2GW33WG";i=*s[0]++;putchar(s[1][i&7]-49?i==71?10:32:42));
}

running:

./a.out 1101101
 **
   *
 **
*
 **

notes:

'W' and 'G' (0x47 and 0x57) are chosen such that the value & 7 = 7, i.e they safely index the null character that terminates the input string.


答:
Python 2, 88 bytes

```<code>s='''from random import*; print "".join(choice(s) for c in "s='"+s+"';exec s")''';exec s
</code>```

All actual merit in getting this far goes to mbomb007 - thanks for your help (and the pointer about backslashes)

Title: Faux Source Code

Body:
Output one random character for each character of source code (as illustrated below). The probability of each character is its frequency in the original source code. Thus the output will be fake source code resembling a quine.

Specification

Restrictions

Standard quine constrains apply. No empty programs or functions. Also no reading your own source.

Output

The number of characters output should be exactly the number of characters in the source code

Each output character should be randomly choosen

The probability of choosing any character is equal to (occurrences in source) / (length of source)

This means that even a unary solution needs to 'randomly' choose 1 with probability 1. Which is to say that the output can't be hard coded.

Winning

This is code golf, so fewest bytes wins

Example

```<code>Program           Frequency           Probability           Possible Output
-------           ---------           -----------           ---------------
 a@!@              a - 1               a - 25%               @@a@
                   ! - 1               ! - 25%
                   @ - 2               @ - 50%
</code>```

```<code>Program           Frequency           Probability           Possible Output
-------           ---------           -----------           ---------------
caBaDBcDaBDB       a - 3               a - 25%               aaaBBBBccDDD
                   B - 4               B - 33%
                   c - 2               c - 17%
                   D - 3               D - 25%
</code>```

Body:
Python 2, 88 bytes

s='''from random import*; print "".join(choice(s) for c in "s='"+s+"';exec s")''';exec s

All actual merit in getting this far goes to mbomb007 - thanks for your help (and the pointer about backslashes)