答:
R, <s>433</s> 399 bytes

```<code>y=scan(,'',sep="\n")
h=nchar(y[1])
v=length(y)
p=function(x)paste(x,collapse="")
if(h%%2){y=sapply(y,function(x)paste0(x," "));h=h+1}
if(v%%2){y=c(y,p(rep(" ",h)));v=v+1}
z=matrix(unlist(lapply(y,function(x)strtoi(charToRaw(x),16))),ncol=h,byrow=T)
a=array(,c(v,h))
for(i in 1:(v/2)){for(j in 1:(h/2)){r=2*i-1:0;s=2*j-1:0;a[r,s]=rawToChar(as.raw(floor(mean(z[r,s])+.5)))}}
cat(apply(a,1,p),sep="\n")
</code>```

I am getting desperate because this thing seems to be non-competing as heck. It prints

```<code>$$>>II99######
$$>>II99######
$$##88KKGG####
$$##88KKGG####
</code>```

for the test case.

If you feed in the 7×3

```<code>%%%%%%%
Example
%%%%%%%
</code>```

the output will be

```<code>BBFFJJ33
BBFFJJ33
######!!
######!!
</code>```

because of the divisibility by 2 etc. etc.

Ungolfed:

```<code>y <- scan(, '', sep="\n") # Read STDIN and make it a character vector
h <- nchar(y[1]) # Get line width: how many chars per line
v <- length(y)   # Get array height: how many lines
p <- function(x) paste(x, collapse="") # A function that merges a vector of strings
if (h%%2) {y <- sapply(y, function(x) paste0(x, " ")); h=h+1} # If height is odd, add an empty line
if (v%%2) {y <- c(y, p(rep(" ", h))); v=v+1} # If width is odd, add an empty column
z <- matrix(unlist(lapply(y, function(x) strtoi(charToRaw(x), 16))), ncol=h, byrow=T)
# z now stores ASCII codes in a matrix; analogous to C strtol
a <- array(, dim=c(v,h)) # Reserve an array for the final result
for (i in 1:(v/2)) {
  for(j in 1:(h/2)) {
    r <- 2*i - 1:0 # Range of rows to average
    s <- 2*j - 1:0 # Range of columns to average
    a[r, s] <- rawToChar(as.raw(floor(mean(z[r, s]) + .5))) # Average, round, convert the ASCII codes
  } # and write them to the same place as in the original array
}
cat(apply(a, 1 , p), sep="\n") # Prints the array row-wise (index 1 for rows)
</code>```

Just look how it handles this one gorgeous example (courtesy of chris.com):

```<code>                                                M$$$$$$$$$$$$$$$$RMMMMM8MMX
                                               <$$$$$$$$$$$$R????!!?MMMR$RMMh.
                                              :M$$$$$$$R?!!~~~~!!!!!!!MMM$$$$X
                                             :M$$$$$$$X!~~~   ~~~~~!!MM8$MM$$M!
                                           :!XM$$$$$$R!~~~~~  ~~~~~!!M$$$$$$$R!
                                          <!XM$$$$$$MR!~~~~ ~~ ~:!!<:!M$$$$$$$!
                                         '<!XMBQQRMMMMX:::~~~<!?!!~~!!!!$$$M!$X
                                         ~!!MM$$$$$M8R!!!?!:~!!M$f?!~~~!M$8HXX?
                                       <!!!XMM$$$$$MMRM$$!~!~~~~~~~~~~~!XM?!!M!
                                      <!!!!XMM$$M$$MM$M!!~~~ ~~~ ~  :~!!!X!~~R!
                                      !!!!XMMM$MMMMMMMM!!~~~ ~~~~  ~~~!!!X~~X!~
                                      '~~!!MMMM@MMMX!!MM!:~!!!~~  `~~~~!!XXXX~
                                        ~!!!XMMMMMMMM!MMM!~~~~:: <<~~~~!!$$R!
                                        '!!!!MM888M$MXMMM!!!!()!!~~~~~<!X$$$>
                                         ~!!!M???M$MRRMM$X<~!!!!~~~~~:!XN$$M
                                          ~!!!!!M$$$$@$@$$!!~~'  ~~:XH8$$$WR
                                          !!!!MM$RM$RRMMMM?t!:::XX8$$$$$$$$>
                                         ~~!!MMM$$$$$WX!!!!!!$$$$$$$RR$$$R"
                                       '  <!!MT!!!~~~!#BX!!!~~?T#?!!!M$$$X.
                                         <!!!!~~~~~~~~~?$!!!~~~~~~:!M$$$$MXH:
                                         ~~~~~~~~~~~ ~~!M&!!!~~~<!!X$$$$$$$R$W>
                                        <~~~~~~~~    '~~!$!!!!!!!!MMRM$R?#!!$N!
                                       x~~~~~~~~~    ~~~!MX!!!!!!?!M!M!~~:!!$B!
                                      M!~~~~~~~~~~  <~~:!$R!!!!!!!X!!!~~!!~!RR!
                                    :M!~~~~~~~~~~~ `~~~!X$R!!!!!!!!~~~:!!~~tMM!
                                   dR!!~~~~~~~~~~~~~~~~!M$R!!!!!!!~!!!!!!~~@$@~
                                  tR!!!~~~~~~~~~~~~~~~!!M$R!!!!!!!!!!!!!~~!$$E~
                                 d!~~~~~~~~~~~~~~~~~~~!!$$X!!!!!!!!!!!!~~~X$$!~
                                8R~~~~~~~~~~~~~~~~~~~<!X$$!!!!!!!!!!!<~~~!MR$~~
                               8$~~~~~~~!~~~~~~~~~~~<!!$$R!!!MX!!!!~~~~~<XR$!~<
                             :$$!~~~~~~!!~~~~~~~~~~~!!M$$!!!!MM!!!~~~~~<!8$F~<!
                          .x8$$$!~~~~::!~~~~~~~~~~~!!X$$$!!!!MM!!~~~~~!!M$R~~~!
               .::xxxnHW8$$$$$$$$$$$$$$!!~~~~~~~~~~<!@$$X!!!!MM~~~~~<!!X$E~~~~!
          :t$$$$$$$$$$$$$$$$$$$$$$$$$$$!!~~~~~~~~~~!X$$$X~!!!MX~~~~~!!X$$~~~~!!
       ~~~~#R$$$$$RR8$$$$$$$$$$$$$$$$$$!!~~~~~~~~~<!M$$$B~!!!M!~~~~~!X$$!~~~~!!
     ~~~~~~~~?$$$$$$$$$$$$$$$$$$$$$$$$$!!~~~~~~~~~!!$$$$$X!!X$!~~~~!X$$R~~~~<!f
  :~~~~~~~~~`~?$$$$$$$$$$$$$$$$$$$$$$$$!!~~~~~~~~!!X$$$$$$X!M$~~~<!W$$R~~~~~!!
 ~~~~~~~~~~  ~~M$$$$$$$$$$$$$$$$$$$$$$$!!~~~~~~~~!!M$$$$$$$$$Bid$$$$$$!~~~~~!!
!~~~~~~~~~~~~~~~$$$$$$$$$$$$$$$$$$$$$$$!~~~~~~~~~!!$$$$$$$$$$$$$$$$$$!~~~~~~!~
!~~~~~~~~~~~~~~~M$$$$$$$$$$$$$$$$$$$$$$!:~~~~~~~<!X$$$$$$$$$$$$$$$$$!~~~~~~!!
~~~~~~~~~~~~~~!!!$$$$$$$$$$$$$$$$$$$$$R!!:~~~~~~!!M$$$$$$$$$$$$$$"XR~~~~~~~!!
~~~~~~~~~~~~~!!!!$$$$$$$$$$$$$$$$$$$$$R!<!~~~~~!!!X$$$$$$$$$$$P~  !~~~~~~~!!
~~~~~~~~~~~<!!!!!$$$$$$$$$$$$$$$$$$$$$X!!~~~~~<!!!@#""`           ~~~~~~~~!!
~~~~~~~~~~~!!!!!X$$$$$$$$$$$$$$$$$$$$$X!~~~~~~!!!                '~~~~~~~!!
~~~~~~~~~~~<!!!!M$$$$$$$$$$$$$$$$$$$$$X!~~~~~!!!f                '~~~~~~<!!
~~~~~~~~~~~~~!!!$$$$$$$$$$$$$$$$$$$$$R!~~~~~~!!!                 '~~~~~<!!>
~~~~~~~~~~~~~~!!M$$$$$$$$$$$$$$$$$$$" !~~~~~!!!!                 ~~~~~~!!!
~~~~~~~~~~~~~~!!!$$$$$$$$$$$$$$$$$R~ .!~~~~~!!!                  ~~~~~!!!!
~~~~~~~~~~~~~~~!!!$$$$$$$$$$$$$*?!!!~!!~~~~<!!~                  ~~~~!!!!!
~~~~~~~~~~~~~~~~!!!$$$$$$$$*"~!!!!!!!!!~~~~!!!                  <~~~:!!!!!
!~~~~~~~~~~~~~~~~!!M$$$$#~~~~~~~~~~~!!~~~~~!!                   ~~~~~~~!!!
!<~~~~~~~~~~~~~~~!!!R"~~~~~~~~~~~~~!!!~~~~<!!                  '~~~~~~<!!
!<~~~~~~~~~~~~~~~~!!!~~~~~~~~~~~~~~!!~~~~~!!!X:                ~~~~~~~!!~
!!~~~~~~~~~~~~~~~~!!!!~~~~~~~~~~~~<!!~~~~!!!9$MX:              ~~~~~~<!!
!!!!!~~~~~~~~~~~~~!!!!:~~~~~~~~~~~!!~~~~~!!X$$$X!~            '~~~~~~!!~
!!!!!!~~~~~~~~~~~<!!!!!!~~~~~~~~~~!!~~~~!!!M$$R!~~~~          ~~~~~~!!!
!!!!!!!<~~~~~~~~~~~!!!!!!!:<:~~~~~!!~~~~!!X$$R!~~~~~~         ~~~~~~!!
!!!!!!!!~~~~~~~~~~<!!!!!!!!!!!!!<!!!~~~~!!@$$!~~~~~~~~        ~~~~~!!~
!!!!!!!!!~~~~~~~~:<!!!!X!!!!!!!!!!!!~~~!!X$$!~~~~~~~~~~~~:   '~~~~~!!
'!!!!!!!!!!~~~~~~~!!!!!!?!!!!!!!!!!!~~<!!M$M!~~~~~~~~~~~~~~~ '~~~~~!~
 !!!!!!!!!!\~~~~~~~>!!!!  `"MMMHX!!~~~<!!$R!~~~~~~~~~~~~~~~~~<~~~~!!
  !!!!!!!!!!<~~~~~<!!!!!   .::<!!!!<~~!!X8X!~~~~~~~~~~~~~~~~~~~~~~!!
  `X!!!!!!!!~~~~~!<!!!!!!!!!!!!~~!!\~~!!M$MX!:~~~~~~~~~~~~~~~~<!~~!>
  !X!!!!!!!!~!!:!!!!!!!!!!~!!!:~~!!~~~!!$M!~~!!<~~~~~~~~~~~~~~~!!!!
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:!!~~:!9R!~~~~~~!~~~~~~~~~~~~~~<!!f
 'CHAT!!!!!!!!!!!!!!!!!!!!!!!!!!!!~~~!!MX~~~~~~~~~~~~~~~~~~~~~~!!X
</code>```

After:

```<code>                                              ''..$$$$$$$$$$662266??MMIIDDEE66
                                              ''..$$$$$$$$$$662266??MMIIDDEE66
                                            ''>>$$$$$$<<WWOOOOggPP88,,HH99..;;
                                            ''>>$$$$$$<<WWOOOOggPP88,,HH99..;;
                                          ..HH..$$$$EEPP~~ggOOggVV??22..$$$$00!!
                                          ..HH..$$$$EEPP~~ggOOggVV??22..$$$$00!!
                                        99((PP77;;CCII5555VVVV4433WWPP88..<<==66
                                        99((PP77;;CCII5555VVVV4433WWPP88..<<==66
                                      ..!!==MM$$..99DD8899gggg~~ggOOmm88HH@@PP!!
                                      ..!!==MM$$..99DD8899gggg~~ggOOmm88HH@@PP!!
                                      ::88EEMM@@MMPP77BB??gg88~~88__~~88==kkTT88
                                      ::88EEMM@@MMPP77BB??gg88~~88__~~88==kkTT88
                                        ::!!EEHHCCCCEEMM77PPQQ00??nn~~??0000((
                                        ::!!EEHHCCCCEEMM77PPQQ00??nn~~??0000((
                                        8888,,00??..BB@@11??PP""ggmmVV55//GG
                                        8888,,00??..BB@@11??PP""ggmmVV55//GG
                                        8888,,MM00..HHEE77==((//>>));;$$00))
                                        8888,,MM00..HHEE77==((//>>));;$$00))
                                      ""''((,,\\PP~~ggII00!!~~ddXX''88$$;;<<''
                                      ""''((,,\\PP~~ggII00!!~~ddXX''88$$;;<<''
                                        VV~~~~~~ggOO99gg..!!88PP((EE::00++..;;((
                                        VV~~~~~~ggOO99gg..!!88PP((EE::00++..;;((
                                      BB~~~~~~~~gg  VVmm--;;!!!!))::,,gg??88CC!!
                                      BB~~~~~~~~gg  VVmm--;;!!!!))::,,gg??88CC!!
                                  11??PP~~~~~~~~~~__~~PP;;::!!!!!!PPPP''PPll@@88
                                  11??PP~~~~~~~~~~__~~PP;;::!!!!!!PPPP''PPll@@88
                                11YYPPgg~~~~~~~~~~~~~~!!..;;!!!!!!!!!!88~~00,,OO
                                11YYPPgg~~~~~~~~~~~~~~!!..;;!!!!!!!!!!88~~00,,OO
                              &&KK~~~~~~gg~~~~~~~~~~FF0000!!,,//!!88VV~~MMEEPP??
                              &&KK~~~~~~gg~~~~~~~~~~FF0000!!,,//!!88VV~~MMEEPP??
                          ::..$$PP~~mm??gg~~~~~~~~gg//..##!!777788~~~~??33OOnn!!
                          ::..$$PP~~mm??gg~~~~~~~~gg//..##!!777788~~~~??33OOnn!!
          <<""&&//NNLL::))$$$$$$$$$$$$##PP~~~~~~~~VV77$$TT!!77hh~~~~((==CC~~gg!!
          <<""&&//NNLL::))$$$$$$$$$$$$##PP~~~~~~~~VV77$$TT!!77hh~~~~((==CC~~gg!!
    88gg~~ggMM$$$$;;))$$$$$$$$$$$$$$$$##PP~~~~~~~~((..$$OO!!;;PP~~gg==00gg~~??22
    88gg~~ggMM$$$$;;))$$$$$$$$$$$$$$$$##PP~~~~~~~~((..$$OO!!;;PP~~gg==00gg~~??22
88mm~~~~~~gg__LL$$$$$$$$$$$$$$$$$$$$$$##PP~~~~~~PP::$$$$$$0066rrAA00$$\\~~~~!!
88mm~~~~~~gg__LL$$$$$$$$$$$$$$$$$$$$$$##PP~~~~~~PP::$$$$$$0066rrAA00$$\\~~~~!!
PP~~~~~~~~~~~~~~..$$$$$$$$$$$$$$$$$$$$##mm~~~~~~??00$$$$$$$$$$$$$$$$99~~~~gg88
PP~~~~~~~~~~~~~~..$$$$$$$$$$$$$$$$$$$$##mm~~~~~~??00$$$$$$$$$$$$$$$$99~~~~gg88
~~~~~~~~~~~~gg!!##$$$$$$$$$$$$$$$$$$$$::..~~~~gg!!;;$$$$$$$$$$FF""RR~~~~~~88
~~~~~~~~~~~~gg!!##$$$$$$$$$$$$$$$$$$$$::..~~~~gg!!;;$$$$$$$$$$FF""RR~~~~~~88
~~~~~~~~~~VV!!!!00$$$$$$$$$$$$$$$$$$$$==gg~~~~((!!))!!00        ""~~~~~~gg!!
~~~~~~~~~~VV!!!!00$$$$$$$$$$$$$$$$$$$$==gg~~~~((!!))!!00        ""~~~~~~gg!!
~~~~~~~~~~nn88!!..$$$$$$$$$$$$$$$$$$00FF~~~~PP!!22              $$~~~~nn((((
~~~~~~~~~~nn88!!..$$$$$$$$$$$$$$$$$$00FF~~~~PP!!22              $$~~~~nn((((
~~~~~~~~~~~~~~!!..$$$$$$$$$$$$$$$$FF$$PP~~~~!!!!                OO~~~~88!!
~~~~~~~~~~~~~~!!..$$$$$$$$$$$$$$$$FF$$PP~~~~!!!!                OO~~~~88!!
~~~~~~~~~~~~~~gg!!##$$$$$$&&::$$))!!88PP~~VV!!88                VV~~??!!!!
~~~~~~~~~~~~~~gg!!##$$$$$$&&::$$))!!88PP~~VV!!88                VV~~??!!!!
??~~~~~~~~~~~~~~PP,,//QQgg~~~~~~~~gg!!~~~~??!!                ""~~~~~~??!!
??~~~~~~~~~~~~~~PP,,//QQgg~~~~~~~~gg!!~~~~??!!                ""~~~~~~??!!
((~~~~~~~~~~~~~~~~!!88~~~~~~~~~~~~??PP~~gg!!66@@''            OO~~~~nn!!88
((~~~~~~~~~~~~~~~~!!88~~~~~~~~~~~~??PP~~gg!!66@@''            OO~~~~nn!!88
!!!!88~~~~~~~~~~nn!!!!??~~~~~~~~~~!!~~~~88::$$<<ggOO          hh~~~~8888
!!!!88~~~~~~~~~~nn!!!!??~~~~~~~~~~!!~~~~88::$$<<ggOO          hh~~~~8888
!!!!!!((~~~~~~~~~~??!!!!!!..??PPVV!!~~~~!!88//gg~~~~gg        ~~~~gg88
!!!!!!((~~~~~~~~~~??!!!!!!..??PPVV!!~~~~!!88//gg~~~~gg        ~~~~gg88
##!!!!!!88gg~~~~mm((!!//))!!!!!!!!!!~~??::..PP~~~~~~~~~~mmOO$$~~~~PP88
##!!!!!!88gg~~~~mm((!!//))!!!!!!!!!!~~??::..PP~~~~~~~~~~mmOO$$~~~~PP88
  !!!!!!!!00nn~~~~FF!!!!  44DD==//??~~((55;;~~~~~~~~~~~~~~~~nn~~~~!!
  !!!!!!!!00nn~~~~FF!!!!  44DD==//??~~((55;;~~~~~~~~~~~~~~~~nn~~~~!!
  LL!!!!!!!!ggVV88((!!!!!!88!!VVPPGG~~!!99QQ??VV~~~~~~~~~~~~~~??PP((
  LL!!!!!!!!ggVV88((!!!!!!88!!VVPPGG~~!!99QQ??VV~~~~~~~~~~~~~~??PP((
""3366!!!!!!!!!!!!!!!!!!!!!!!!!!''ggVV22RR~~~~~~gg~~~~~~~~~~~~VV//22
""3366!!!!!!!!!!!!!!!!!!!!!!!!!!''ggVV22RR~~~~~~gg~~~~~~~~~~~~VV//22
</code>```

Title: Average an image

Body:
R, <s>433</s> 399 bytes

y=scan(,'',sep="\n")
h=nchar(y[1])
v=length(y)
p=function(x)paste(x,collapse="")
if(h%%2){y=sapply(y,function(x)paste0(x," "));h=h+1}
if(v%%2){y=c(y,p(rep(" ",h)));v=v+1}
z=matrix(unlist(lapply(y,function(x)strtoi(charToRaw(x),16))),ncol=h,byrow=T)
a=array(,c(v,h))
for(i in 1:(v/2)){for(j in 1:(h/2)){r=2*i-1:0;s=2*j-1:0;a[r,s]=rawToChar(as.raw(floor(mean(z[r,s])+.5)))}}
cat(apply(a,1,p),sep="\n")

I am getting desperate because this thing seems to be non-competing as heck. It prints

$$>>II99######
$$>>II99######
$$##88KKGG####
$$##88KKGG####

for the test case.

If you feed in the 7×3

%%%%%%%
Example
%%%%%%%

the output will be

BBFFJJ33
BBFFJJ33
######!!
######!!

because of the divisibility by 2 etc. etc.

Ungolfed:

y <- scan(, '', sep="\n") # Read STDIN and make it a character vector
h <- nchar(y[1]) # Get line width: how many chars per line
v <- length(y)   # Get array height: how many lines
p <- function(x) paste(x, collapse="") # A function that merges a vector of strings
if (h%%2) {y <- sapply(y, function(x) paste0(x, " ")); h=h+1} # If height is odd, add an empty line
if (v%%2) {y <- c(y, p(rep(" ", h))); v=v+1} # If width is odd, add an empty column
z <- matrix(unlist(lapply(y, function(x) strtoi(charToRaw(x), 16))), ncol=h, byrow=T)
# z now stores ASCII codes in a matrix; analogous to C strtol
a <- array(, dim=c(v,h)) # Reserve an array for the final result
for (i in 1:(v/2)) {
  for(j in 1:(h/2)) {
    r <- 2*i - 1:0 # Range of rows to average
    s <- 2*j - 1:0 # Range of columns to average
    a[r, s] <- rawToChar(as.raw(floor(mean(z[r, s]) + .5))) # Average, round, convert the ASCII codes
  } # and write them to the same place as in the original array
}
cat(apply(a, 1 , p), sep="\n") # Prints the array row-wise (index 1 for rows)

Just look how it handles this one gorgeous example (courtesy of chris.com):

                                                M$$$$$$$$$$$$$$$$RMMMMM8MMX
                                               <$$$$$$$$$$$$R????!!?MMMR$RMMh.
                                              :M$$$$$$$R?!!~~~~!!!!!!!MMM$$$$X
                                             :M$$$$$$$X!~~~   ~~~~~!!MM8$MM$$M!
                                           :!XM$$$$$$R!~~~~~  ~~~~~!!M$$$$$$$R!
                                          <!XM$$$$$$MR!~~~~ ~~ ~:!!<:!M$$$$$$$!
                                         '<!XMBQQRMMMMX:::~~~<!?!!~~!!!!$$$M!$X
                                         ~!!MM$$$$$M8R!!!?!:~!!M$f?!~~~!M$8HXX?
                                       <!!!XMM$$$$$MMRM$$!~!~~~~~~~~~~~!XM?!!M!
                                      <!!!!XMM$$M$$MM$M!!~~~ ~~~ ~  :~!!!X!~~R!
                                      !!!!XMMM$MMMMMMMM!!~~~ ~~~~  ~~~!!!X~~X!~
                                      '~~!!MMMM@MMMX!!MM!:~!!!~~  `~~~~!!XXXX~
                                        ~!!!XMMMMMMMM!MMM!~~~~:: <<~~~~!!$$R!
                                        '!!!!MM888M$MXMMM!!!!()!!~~~~~<!X$$$>
                                         ~!!!M???M$MRRMM$X<~!!!!~~~~~:!XN$$M
                                          ~!!!!!M$$$$@$@$$!!~~'  ~~:XH8$$$WR
                                          !!!!MM$RM$RRMMMM?t!:::XX8$$$$$$$$>
                                         ~~!!MMM$$$$$WX!!!!!!$$$$$$$RR$$$R"
                                       '  <!!MT!!!~~~!#BX!!!~~?T#?!!!M$$$X.
                                         <!!!!~~~~~~~~~?$!!!~~~~~~:!M$$$$MXH:
                                         ~~~~~~~~~~~ ~~!M&!!!~~~<!!X$$$$$$$R$W>
                                        <~~~~~~~~    '~~!$!!!!!!!!MMRM$R?#!!$N!
                                       x~~~~~~~~~    ~~~!MX!!!!!!?!M!M!~~:!!$B!
                                      M!~~~~~~~~~~  <~~:!$R!!!!!!!X!!!~~!!~!RR!
                                    :M!~~~~~~~~~~~ `~~~!X$R!!!!!!!!~~~:!!~~tMM!
                                   dR!!~~~~~~~~~~~~~~~~!M$R!!!!!!!~!!!!!!~~@$@~
                                  tR!!!~~~~~~~~~~~~~~~!!M$R!!!!!!!!!!!!!~~!$$E~
                                 d!~~~~~~~~~~~~~~~~~~~!!$$X!!!!!!!!!!!!~~~X$$!~
                                8R~~~~~~~~~~~~~~~~~~~<!X$$!!!!!!!!!!!<~~~!MR$~~
                               8$~~~~~~~!~~~~~~~~~~~<!!$$R!!!MX!!!!~~~~~<XR$!~<
                             :$$!~~~~~~!!~~~~~~~~~~~!!M$$!!!!MM!!!~~~~~<!8$F~<!
                          .x8$$$!~~~~::!~~~~~~~~~~~!!X$$$!!!!MM!!~~~~~!!M$R~~~!
               .::xxxnHW8$$$$$$$$$$$$$$!!~~~~~~~~~~<!@$$X!!!!MM~~~~~<!!X$E~~~~!
          :t$$$$$$$$$$$$$$$$$$$$$$$$$$$!!~~~~~~~~~~!X$$$X~!!!MX~~~~~!!X$$~~~~!!
       ~~~~#R$$$$$RR8$$$$$$$$$$$$$$$$$$!!~~~~~~~~~<!M$$$B~!!!M!~~~~~!X$$!~~~~!!
     ~~~~~~~~?$$$$$$$$$$$$$$$$$$$$$$$$$!!~~~~~~~~~!!$$$$$X!!X$!~~~~!X$$R~~~~<!f
  :~~~~~~~~~`~?$$$$$$$$$$$$$$$$$$$$$$$$!!~~~~~~~~!!X$$$$$$X!M$~~~<!W$$R~~~~~!!
 ~~~~~~~~~~  ~~M$$$$$$$$$$$$$$$$$$$$$$$!!~~~~~~~~!!M$$$$$$$$$Bid$$$$$$!~~~~~!!
!~~~~~~~~~~~~~~~$$$$$$$$$$$$$$$$$$$$$$$!~~~~~~~~~!!$$$$$$$$$$$$$$$$$$!~~~~~~!~
!~~~~~~~~~~~~~~~M$$$$$$$$$$$$$$$$$$$$$$!:~~~~~~~<!X$$$$$$$$$$$$$$$$$!~~~~~~!!
~~~~~~~~~~~~~~!!!$$$$$$$$$$$$$$$$$$$$$R!!:~~~~~~!!M$$$$$$$$$$$$$$"XR~~~~~~~!!
~~~~~~~~~~~~~!!!!$$$$$$$$$$$$$$$$$$$$$R!<!~~~~~!!!X$$$$$$$$$$$P~  !~~~~~~~!!
~~~~~~~~~~~<!!!!!$$$$$$$$$$$$$$$$$$$$$X!!~~~~~<!!!@#""`           ~~~~~~~~!!
~~~~~~~~~~~!!!!!X$$$$$$$$$$$$$$$$$$$$$X!~~~~~~!!!                '~~~~~~~!!
~~~~~~~~~~~<!!!!M$$$$$$$$$$$$$$$$$$$$$X!~~~~~!!!f                '~~~~~~<!!
~~~~~~~~~~~~~!!!$$$$$$$$$$$$$$$$$$$$$R!~~~~~~!!!                 '~~~~~<!!>
~~~~~~~~~~~~~~!!M$$$$$$$$$$$$$$$$$$$" !~~~~~!!!!                 ~~~~~~!!!
~~~~~~~~~~~~~~!!!$$$$$$$$$$$$$$$$$R~ .!~~~~~!!!                  ~~~~~!!!!
~~~~~~~~~~~~~~~!!!$$$$$$$$$$$$$*?!!!~!!~~~~<!!~                  ~~~~!!!!!
~~~~~~~~~~~~~~~~!!!$$$$$$$$*"~!!!!!!!!!~~~~!!!                  <~~~:!!!!!
!~~~~~~~~~~~~~~~~!!M$$$$#~~~~~~~~~~~!!~~~~~!!                   ~~~~~~~!!!
!<~~~~~~~~~~~~~~~!!!R"~~~~~~~~~~~~~!!!~~~~<!!                  '~~~~~~<!!
!<~~~~~~~~~~~~~~~~!!!~~~~~~~~~~~~~~!!~~~~~!!!X:                ~~~~~~~!!~
!!~~~~~~~~~~~~~~~~!!!!~~~~~~~~~~~~<!!~~~~!!!9$MX:              ~~~~~~<!!
!!!!!~~~~~~~~~~~~~!!!!:~~~~~~~~~~~!!~~~~~!!X$$$X!~            '~~~~~~!!~
!!!!!!~~~~~~~~~~~<!!!!!!~~~~~~~~~~!!~~~~!!!M$$R!~~~~          ~~~~~~!!!
!!!!!!!<~~~~~~~~~~~!!!!!!!:<:~~~~~!!~~~~!!X$$R!~~~~~~         ~~~~~~!!
!!!!!!!!~~~~~~~~~~<!!!!!!!!!!!!!<!!!~~~~!!@$$!~~~~~~~~        ~~~~~!!~
!!!!!!!!!~~~~~~~~:<!!!!X!!!!!!!!!!!!~~~!!X$$!~~~~~~~~~~~~:   '~~~~~!!
'!!!!!!!!!!~~~~~~~!!!!!!?!!!!!!!!!!!~~<!!M$M!~~~~~~~~~~~~~~~ '~~~~~!~
 !!!!!!!!!!\~~~~~~~>!!!!  `"MMMHX!!~~~<!!$R!~~~~~~~~~~~~~~~~~<~~~~!!
  !!!!!!!!!!<~~~~~<!!!!!   .::<!!!!<~~!!X8X!~~~~~~~~~~~~~~~~~~~~~~!!
  `X!!!!!!!!~~~~~!<!!!!!!!!!!!!~~!!\~~!!M$MX!:~~~~~~~~~~~~~~~~<!~~!>
  !X!!!!!!!!~!!:!!!!!!!!!!~!!!:~~!!~~~!!$M!~~!!<~~~~~~~~~~~~~~~!!!!
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:!!~~:!9R!~~~~~~!~~~~~~~~~~~~~~<!!f
 'CHAT!!!!!!!!!!!!!!!!!!!!!!!!!!!!~~~!!MX~~~~~~~~~~~~~~~~~~~~~~!!X

After:

                                              ''..$$$$$$$$$$662266??MMIIDDEE66
                                              ''..$$$$$$$$$$662266??MMIIDDEE66
                                            ''>>$$$$$$<<WWOOOOggPP88,,HH99..;;
                                            ''>>$$$$$$<<WWOOOOggPP88,,HH99..;;
                                          ..HH..$$$$EEPP~~ggOOggVV??22..$$$$00!!
                                          ..HH..$$$$EEPP~~ggOOggVV??22..$$$$00!!
                                        99((PP77;;CCII5555VVVV4433WWPP88..<<==66
                                        99((PP77;;CCII5555VVVV4433WWPP88..<<==66
                                      ..!!==MM$$..99DD8899gggg~~ggOOmm88HH@@PP!!
                                      ..!!==MM$$..99DD8899gggg~~ggOOmm88HH@@PP!!
                                      ::88EEMM@@MMPP77BB??gg88~~88__~~88==kkTT88
                                      ::88EEMM@@MMPP77BB??gg88~~88__~~88==kkTT88
                                        ::!!EEHHCCCCEEMM77PPQQ00??nn~~??0000((
                                        ::!!EEHHCCCCEEMM77PPQQ00??nn~~??0000((
                                        8888,,00??..BB@@11??PP""ggmmVV55//GG
                                        8888,,00??..BB@@11??PP""ggmmVV55//GG
                                        8888,,MM00..HHEE77==((//>>));;$$00))
                                        8888,,MM00..HHEE77==((//>>));;$$00))
                                      ""''((,,\\PP~~ggII00!!~~ddXX''88$$;;<<''
                                      ""''((,,\\PP~~ggII00!!~~ddXX''88$$;;<<''
                                        VV~~~~~~ggOO99gg..!!88PP((EE::00++..;;((
                                        VV~~~~~~ggOO99gg..!!88PP((EE::00++..;;((
                                      BB~~~~~~~~gg  VVmm--;;!!!!))::,,gg??88CC!!
                                      BB~~~~~~~~gg  VVmm--;;!!!!))::,,gg??88CC!!
                                  11??PP~~~~~~~~~~__~~PP;;::!!!!!!PPPP''PPll@@88
                                  11??PP~~~~~~~~~~__~~PP;;::!!!!!!PPPP''PPll@@88
                                11YYPPgg~~~~~~~~~~~~~~!!..;;!!!!!!!!!!88~~00,,OO
                                11YYPPgg~~~~~~~~~~~~~~!!..;;!!!!!!!!!!88~~00,,OO
                              &&KK~~~~~~gg~~~~~~~~~~FF0000!!,,//!!88VV~~MMEEPP??
                              &&KK~~~~~~gg~~~~~~~~~~FF0000!!,,//!!88VV~~MMEEPP??
                          ::..$$PP~~mm??gg~~~~~~~~gg//..##!!777788~~~~??33OOnn!!
                          ::..$$PP~~mm??gg~~~~~~~~gg//..##!!777788~~~~??33OOnn!!
          <<""&&//NNLL::))$$$$$$$$$$$$##PP~~~~~~~~VV77$$TT!!77hh~~~~((==CC~~gg!!
          <<""&&//NNLL::))$$$$$$$$$$$$##PP~~~~~~~~VV77$$TT!!77hh~~~~((==CC~~gg!!
    88gg~~ggMM$$$$;;))$$$$$$$$$$$$$$$$##PP~~~~~~~~((..$$OO!!;;PP~~gg==00gg~~??22
    88gg~~ggMM$$$$;;))$$$$$$$$$$$$$$$$##PP~~~~~~~~((..$$OO!!;;PP~~gg==00gg~~??22
88mm~~~~~~gg__LL$$$$$$$$$$$$$$$$$$$$$$##PP~~~~~~PP::$$$$$$0066rrAA00$$\\~~~~!!
88mm~~~~~~gg__LL$$$$$$$$$$$$$$$$$$$$$$##PP~~~~~~PP::$$$$$$0066rrAA00$$\\~~~~!!
PP~~~~~~~~~~~~~~..$$$$$$$$$$$$$$$$$$$$##mm~~~~~~??00$$$$$$$$$$$$$$$$99~~~~gg88
PP~~~~~~~~~~~~~~..$$$$$$$$$$$$$$$$$$$$##mm~~~~~~??00$$$$$$$$$$$$$$$$99~~~~gg88
~~~~~~~~~~~~gg!!##$$$$$$$$$$$$$$$$$$$$::..~~~~gg!!;;$$$$$$$$$$FF""RR~~~~~~88
~~~~~~~~~~~~gg!!##$$$$$$$$$$$$$$$$$$$$::..~~~~gg!!;;$$$$$$$$$$FF""RR~~~~~~88
~~~~~~~~~~VV!!!!00$$$$$$$$$$$$$$$$$$$$==gg~~~~((!!))!!00        ""~~~~~~gg!!
~~~~~~~~~~VV!!!!00$$$$$$$$$$$$$$$$$$$$==gg~~~~((!!))!!00        ""~~~~~~gg!!
~~~~~~~~~~nn88!!..$$$$$$$$$$$$$$$$$$00FF~~~~PP!!22              $$~~~~nn((((
~~~~~~~~~~nn88!!..$$$$$$$$$$$$$$$$$$00FF~~~~PP!!22              $$~~~~nn((((
~~~~~~~~~~~~~~!!..$$$$$$$$$$$$$$$$FF$$PP~~~~!!!!                OO~~~~88!!
~~~~~~~~~~~~~~!!..$$$$$$$$$$$$$$$$FF$$PP~~~~!!!!                OO~~~~88!!
~~~~~~~~~~~~~~gg!!##$$$$$$&&::$$))!!88PP~~VV!!88                VV~~??!!!!
~~~~~~~~~~~~~~gg!!##$$$$$$&&::$$))!!88PP~~VV!!88                VV~~??!!!!
??~~~~~~~~~~~~~~PP,,//QQgg~~~~~~~~gg!!~~~~??!!                ""~~~~~~??!!
??~~~~~~~~~~~~~~PP,,//QQgg~~~~~~~~gg!!~~~~??!!                ""~~~~~~??!!
((~~~~~~~~~~~~~~~~!!88~~~~~~~~~~~~??PP~~gg!!66@@''            OO~~~~nn!!88
((~~~~~~~~~~~~~~~~!!88~~~~~~~~~~~~??PP~~gg!!66@@''            OO~~~~nn!!88
!!!!88~~~~~~~~~~nn!!!!??~~~~~~~~~~!!~~~~88::$$<<ggOO          hh~~~~8888
!!!!88~~~~~~~~~~nn!!!!??~~~~~~~~~~!!~~~~88::$$<<ggOO          hh~~~~8888
!!!!!!((~~~~~~~~~~??!!!!!!..??PPVV!!~~~~!!88//gg~~~~gg        ~~~~gg88
!!!!!!((~~~~~~~~~~??!!!!!!..??PPVV!!~~~~!!88//gg~~~~gg        ~~~~gg88
##!!!!!!88gg~~~~mm((!!//))!!!!!!!!!!~~??::..PP~~~~~~~~~~mmOO$$~~~~PP88
##!!!!!!88gg~~~~mm((!!//))!!!!!!!!!!~~??::..PP~~~~~~~~~~mmOO$$~~~~PP88
  !!!!!!!!00nn~~~~FF!!!!  44DD==//??~~((55;;~~~~~~~~~~~~~~~~nn~~~~!!
  !!!!!!!!00nn~~~~FF!!!!  44DD==//??~~((55;;~~~~~~~~~~~~~~~~nn~~~~!!
  LL!!!!!!!!ggVV88((!!!!!!88!!VVPPGG~~!!99QQ??VV~~~~~~~~~~~~~~??PP((
  LL!!!!!!!!ggVV88((!!!!!!88!!VVPPGG~~!!99QQ??VV~~~~~~~~~~~~~~??PP((
""3366!!!!!!!!!!!!!!!!!!!!!!!!!!''ggVV22RR~~~~~~gg~~~~~~~~~~~~VV//22
""3366!!!!!!!!!!!!!!!!!!!!!!!!!!''ggVV22RR~~~~~~gg~~~~~~~~~~~~VV//22


问:
Reverse stdin and place on stdout
Requirements:

Take an input on stdin including new lines / carriage returns of unlimited length (only bounded by system memory; that is, there is no inherent limit in the program.)

Output the reverse of the input on stdout.

Example:

Input:

```<code>Quick brown fox
He jumped over the lazy dog
</code>```

Output:

```<code>god yzal eht revo depmuj eH
xof nworb kciuQ
</code>```

Shortest wins.

Leaderboard:

var QUESTION_ID=242,OVERRIDE_USER=61563;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

```

答:
MarioLANG, <s>35</s> <s>31</s> 27 bytes

```<code>,)<.-<
+=">="
>[!([!
==#==#
</code>```

Try it online!

I'm not sure if a MarioLANG interpreter existed prior to this challenge, but the esolangs page has been around since 2009 with information describing the language.

There are 2 main loops here. The first one, consisting of the first 3 columns, loads all the characters into memory (incrememnted by 1 for properly handing eof) The second loop, consisting of the last 3 columns, prints the data on the tape from right to left (along with decrementing the values so they display properly). I did some clever trickery to have these loops directly next to each other.

ContentLicense: CC BY-SA 3.0

Title: Reverse stdin and place on stdout

Body:
MarioLANG, <s>35</s> <s>31</s> 27 bytes

,)<.-<
+=">="
>[!([!
==#==#

Try it online!

I'm not sure if a MarioLANG interpreter existed prior to this challenge, but the esolangs page has been around since 2009 with information describing the language.

There are 2 main loops here. The first one, consisting of the first 3 columns, loads all the characters into memory (incrememnted by 1 for properly handing eof) The second loop, consisting of the last 3 columns, prints the data on the tape from right to left (along with decrementing the values so they display properly). I did some clever trickery to have these loops directly next to each other.


问:
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.

答:
Pip, 7 bytes

```<code>LtP'*Xt
</code>```

Straightforward: Loop 10 times. Print string of 10 asterisks each time. Kinda disappointed that the simple way was the shortest...

Title: Print a 10 by 10 grid of asterisks

Body:
Pip, 7 bytes

LtP'*Xt

Straightforward: Loop 10 times. Print string of 10 asterisks each time. Kinda disappointed that the simple way was the shortest...


问:
Numbers of purity
Today we'll look at a sequence \$a\$, related to the Collatz function \$f\$:

$$f = \begin{cases}
n/2  & \text{if } n \equiv 0 \text{ (mod }2) \\
3n+1 & \text{if } n \equiv 1 \text{ (mod }2) \\
\end{cases}$$

We call a sequence of the form \$z, f(z), f(f(z)), …\$ a Collatz sequence.

The first number in our sequence, \$a(1)\$, is \$0\$. Under repeated application of \$f\$, it falls into a cycle \$0\to0\to0\to\:\cdots\$

The smallest number we haven't seen yet is 1, making \$a(2)=1\$. Under repeated application of \$f\$, it falls into a cycle \$1\to4\to2\to1\to\cdots\$

Now we have seen the number \$2\$ in the cycle above, so the next smallest number is \$a(3) = 3\$, falling into the cycle \$3\to10\to5\to16\to8\to4\to2\to1\to4\to\cdots\$

In all above cycles we've seen \$4\$ and \$5\$ already, so the next number is \$a(4) = 6\$.

By now you should get the idea. \$a(n)\$ is the smallest number that was not part of any Collatz sequences for all \$a(1), ..., a(n-1)\$

Write a program or function that, given an positive integer \$n\$, returns \$a(n)\$. Shortest code in bytes wins.

Testcases:

```<code>1  -> 0
2  -> 1
3  -> 3
4  -> 6
5  -> 7
6  -> 9
7  -> 12
8  -> 15
9  -> 18
10 -> 19
50 -> 114
</code>```

(This is OEIS sequence A061641.)

答:
Haskell, <s>93</s> 92 bytes

```<code>c x|x<2=[[0,2]!!x]|odd x=x:c(3*x+1)|1<2=x:c(div x 2)
([y|y<-[-1..],all(/=y)$c=<<[0..y-1]]!!)
</code>```

Usage example: ([y|y<-[-1..],all(/=y)$c=<<[0..y-1]]!!) 10 -> 19.

c x is the Collatz cycle for x with a little bit of cheating for x == 1. The main functions loops through all integers and keeps those that are not in c x for x in [0..y-1]. Pretty much a direct implementation of the definition. As Haskell index operator !! is 0-based, I start at -1 to prepend a (otherwise useless) number to get the index fixed.

ContentLicense: CC BY-SA 4.0

Title: Numbers of purity

Body:
Haskell, <s>93</s> 92 bytes

c x|x<2=[[0,2]!!x]|odd x=x:c(3*x+1)|1<2=x:c(div x 2)
([y|y<-[-1..],all(/=y)$c=<<[0..y-1]]!!)

Usage example: ([y|y<-[-1..],all(/=y)$c=<<[0..y-1]]!!) 10 -> 19.

c x is the Collatz cycle for x with a little bit of cheating for x == 1. The main functions loops through all integers and keeps those that are not in c x for x in [0..y-1]. Pretty much a direct implementation of the definition. As Haskell index operator !! is 0-based, I start at -1 to prepend a (otherwise useless) number to get the index fixed.


问:
Automatic box expander

Introduction

Sometimes, my boxes are too small to fit anything in it. I need you to make a box expander! So, what makes a box a box in this challenge.

```<code> OOOO
O    O
O    O
O    O
 OOOO
</code>```

The corners of the box are always spaces. The box itself can be made out of the same character. That character can be any printable ASCII character, except a space. So, that's these characters:

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

The side lengths of the box above are 4, 3. You may assume that the side length is always positive. That means that this is the smallest box you need to handle:

```<code> #
# #
 #
</code>```

In order to expand a box, you need to increment each side length. Let's go through this, step by step, with the above example. We first take the upper side of the box, which is:

```<code> OOOO
</code>```

We expand this by one, so we get:

```<code> OOOOO
</code>```

This is the upper and lower part of the box now. After that, we do the same with the sides on the left and right:

```<code>O
O
O
</code>```

Becomes:

```<code>O
O
O
O
</code>```

Now we reassemble the box, which results into:

```<code> OOOOO
O     O
O     O
O     O
O     O
 OOOOO
</code>```

The task

Given a box, expand it by 1. The box can be given in multiple lines, or in an array.

Test cases

```<code> OOOO          OOOOO
O    O    >   O     O
 OOOO         O     O
               OOOOO

 XXXXXX        XXXXXXX
X      X  >   X       X
X      X      X       X
 XXXXXX       X       X
               XXXXXXX

 ~             ~~
~ ~       >   ~  ~
 ~            ~  ~
               ~~
</code>```

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

答:
MATL, 12 bytes

```<code>tZy"@:2hSY)!
</code>```

Input is a 2D char array, with semicolon as row separator. For example, the first test case has input

```<code>[' OOOO ';'O    O';' OOOO ']
</code>```

Try it online! Test cases 1, 2, 3.

Explanation

The code does the following twice: repeat the second row of the array and transpose.

To repeat the second row of an m×n array, the vector [1 2 2 3 ... m] is used as row index. This vector is generated as follows: range [1 2 3 ... m], attach another 2, sort.

```<code>t       % Take input implicitly. Duplicate
Zy      % Size of input as a two-element array [r, c]
"       % For each of r and c
  @     %   Push r in first iteration (or c in the second)
  :     %   Generate range [1 2 3 ... r] (or [1 2 3 ... c])
  2hS   %   Append another 2 and sort
  Y)    %   Apply as row index
  !     %   Transpose
        % End for. Display implicitly
</code>```

Title: Automatic box expander

Body:
MATL, 12 bytes

tZy"@:2hSY)!

Input is a 2D char array, with semicolon as row separator. For example, the first test case has input

[' OOOO ';'O    O';' OOOO ']

Try it online! Test cases 1, 2, 3.

Explanation

The code does the following twice: repeat the second row of the array and transpose.

To repeat the second row of an m×n array, the vector [1 2 2 3 ... m] is used as row index. This vector is generated as follows: range [1 2 3 ... m], attach another 2, sort.

t       % Take input implicitly. Duplicate
Zy      % Size of input as a two-element array [r, c]
"       % For each of r and c
  @     %   Push r in first iteration (or c in the second)
  :     %   Generate range [1 2 3 ... r] (or [1 2 3 ... c])
  2hS   %   Append another 2 and sort
  Y)    %   Apply as row index
  !     %   Transpose
        % End for. Display implicitly


Title: Automatic box expander

Body:
Introduction

Sometimes, my boxes are too small to fit anything in it. I need you to make a box expander! So, what makes a box a box in this challenge.

```<code> OOOO
O    O
O    O
O    O
 OOOO
</code>```

The corners of the box are always spaces. The box itself can be made out of the same character. That character can be any printable ASCII character, except a space. So, that's these characters:

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

The side lengths of the box above are 4, 3. You may assume that the side length is always positive. That means that this is the smallest box you need to handle:

```<code> #
# #
 #
</code>```

In order to expand a box, you need to increment each side length. Let's go through this, step by step, with the above example. We first take the upper side of the box, which is:

```<code> OOOO
</code>```

We expand this by one, so we get:

```<code> OOOOO
</code>```

This is the upper and lower part of the box now. After that, we do the same with the sides on the left and right:

```<code>O
O
O
</code>```

Becomes:

```<code>O
O
O
O
</code>```

Now we reassemble the box, which results into:

```<code> OOOOO
O     O
O     O
O     O
O     O
 OOOOO
</code>```

The task

Given a box, expand it by 1. The box can be given in multiple lines, or in an array.

Test cases

```<code> OOOO          OOOOO
O    O    >   O     O
 OOOO         O     O
               OOOOO

 XXXXXX        XXXXXXX
X      X  >   X       X
X      X      X       X
 XXXXXX       X       X
               XXXXXXX

 ~             ~~
~ ~       >   ~  ~
 ~            ~  ~
               ~~
</code>```

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

Body:
SED 69 19 (14 + 1 for -r) 15

s/.(.)/&\1/;2p


问:
List of possible birth years of living humans
The Challenge

Output a list of years that starts with the current year and ends 120 years ago. The birth year of every living human would be included in this list.

Details

The list should be in descending order.

Every built-in function to manipulate arrays and/or lists is allowed.

Shortest code in bytes wins.

When run this year 2016, the output would be

2016, 2015, ..., 1897, 1896

When run next year 2017, the output would be

2017, 2016, ..., 1898, 1897

Etc.

Update

Some have asked about the format of the list. As most have guessed, it doesn't matter. Insert any separator between the numbers. Intuitively most inserted a comma or space or both, newline or output an array.

Quasi superhumans like Jeanne Calment are an exception to the rule stated in my question.

答:
JavaScript, <s>60</s> <s>53</s> 48 Bytes

```<code>f=x=>x>Date().split` `[3]-121&&(alert(x),f(x-1))
</code>```

I used a recursive solution.

Body:
JavaScript, <s>60</s> <s>53</s> 48 Bytes

f=x=>x>Date().split` `[3]-121&&(alert(x),f(x-1))

I used a recursive solution.


Title: List of possible birth years of living humans

Body:
The Challenge

Output a list of years that starts with the current year and ends 120 years ago. The birth year of every living human would be included in this list.

Details

The list should be in descending order.

Every built-in function to manipulate arrays and/or lists is allowed.

Shortest code in bytes wins.

When run this year 2016, the output would be

2016, 2015, ..., 1897, 1896

When run next year 2017, the output would be

2017, 2016, ..., 1898, 1897

Etc.

Update

Some have asked about the format of the list. As most have guessed, it doesn't matter. Insert any separator between the numbers. Intuitively most inserted a comma or space or both, newline or output an array.

Quasi superhumans like Jeanne Calment are an exception to the rule stated in my question.

Body:
Coffeescript, 29 bytes

->a=Date()[11..14];[a..a-120]


答:
MATL, <s>46</s> 40 bytes

```<code>Oiq:"tX>Q:yX-X<`t0)to?3*Q}2/]h5M1>]Pv]0)
</code>```

Try it online!

Explanation

The code has an outer for loop that generates n Collatz sequences, one in each iteration. Each sequence is generated by an inner do...while loop that computes new values and stores them in a sequence vector until a 1 or 0 is obtained. When we are done with the sequence, the vector is reversed and concatenated to a global vector that contains the values from all previous sequences. This vector may contain repeated values. The reversing of the sequence vector ensures that at the end of the outer loop the desired result (the starting value of the last sequence) will be at the end of the global vector.

Pseudo-code:

```<code>1  Initiallization
2  Generate n sequences (for loop):
3    Compute initial value for the k-th sequence
4    Generate the k-th sequence (do...while loop)
5      Starting from latest value so far, apply the Collatz algorithm to get next value
6      Update sequence with new value
7      Check if we are done. If so, exit loop. We have the k-th sequence
8    Update vector of seen values
9  We now have the n sequences. Get final result
</code>```

Commented code:

```<code>O           % Push 0                                                          1
iq:         % Input n. Generate [1 2 ... n-1]                                 ·
"           % For loop: repeat n-1 times. Let k denote each iteration         2
  t         %   Duplicate vector of all seen values                           · 3
  X>Q       %   Take maximum, add 1                                           · ·
  :         %   Range from 1 to that: these are potential initial values      · ·
  y         %   Duplicate vector of all seen values                           · ·
  X-X<      %   Set difference, minimum: first value not seen                 · ·
  `         %   Do...while: this generates the k-th Collatz sequence          · 4
    t0)     %     Duplicate, push last value of the sequence so far           · · 5
    to      %     Duplicate, parity: 1 if odd, 0 if even                      · · ·
    ?       %     If odd                                                      · · ·
      3*Q   %       Times 3, plus 1                                           · · ·
    }       %     Else                                                        · · ·
      2/    %       Half                                                      · · ·
    ]       %     End if                                                      · · ·
    h       %     Concatenate new value of the sequence                       · · 6
    5M      %     Push the new value again                                    · · 7
    1>      %     Does it exceed 1? This is the loop condition                · · ·
  ]         %   End do...while. The loops ends when we have reached 0 or 1    · ·
  P         %   Reverse the k-th Collatz sequence                             · 8
  v         %   Concatenate with vector of previously seen values             · ·
]           % End for                                                         ·
0)          % Take last value. Implicitly display.                            9
</code>```

Title: Numbers of purity

Body:
Today we'll look at a sequence \$a\$, related to the Collatz function \$f\$:

$$f = \begin{cases}
n/2  & \text{if } n \equiv 0 \text{ (mod }2) \\
3n+1 & \text{if } n \equiv 1 \text{ (mod }2) \\
\end{cases}$$

We call a sequence of the form \$z, f(z), f(f(z)), …\$ a Collatz sequence.

The first number in our sequence, \$a(1)\$, is \$0\$. Under repeated application of \$f\$, it falls into a cycle \$0\to0\to0\to\:\cdots\$

The smallest number we haven't seen yet is 1, making \$a(2)=1\$. Under repeated application of \$f\$, it falls into a cycle \$1\to4\to2\to1\to\cdots\$

Now we have seen the number \$2\$ in the cycle above, so the next smallest number is \$a(3) = 3\$, falling into the cycle \$3\to10\to5\to16\to8\to4\to2\to1\to4\to\cdots\$

In all above cycles we've seen \$4\$ and \$5\$ already, so the next number is \$a(4) = 6\$.

By now you should get the idea. \$a(n)\$ is the smallest number that was not part of any Collatz sequences for all \$a(1), ..., a(n-1)\$

Write a program or function that, given an positive integer \$n\$, returns \$a(n)\$. Shortest code in bytes wins.

Testcases:

```<code>1  -> 0
2  -> 1
3  -> 3
4  -> 6
5  -> 7
6  -> 9
7  -> 12
8  -> 15
9  -> 18
10 -> 19
50 -> 114
</code>```

(This is OEIS sequence A061641.)

Body:
MATL, <s>46</s> 40 bytes

Oiq:"tX>Q:yX-X<`t0)to?3*Q}2/]h5M1>]Pv]0)

Try it online!

Explanation

The code has an outer for loop that generates n Collatz sequences, one in each iteration. Each sequence is generated by an inner do...while loop that computes new values and stores them in a sequence vector until a 1 or 0 is obtained. When we are done with the sequence, the vector is reversed and concatenated to a global vector that contains the values from all previous sequences. This vector may contain repeated values. The reversing of the sequence vector ensures that at the end of the outer loop the desired result (the starting value of the last sequence) will be at the end of the global vector.

Pseudo-code:

1  Initiallization
2  Generate n sequences (for loop):
3    Compute initial value for the k-th sequence
4    Generate the k-th sequence (do...while loop)
5      Starting from latest value so far, apply the Collatz algorithm to get next value
6      Update sequence with new value
7      Check if we are done. If so, exit loop. We have the k-th sequence
8    Update vector of seen values
9  We now have the n sequences. Get final result

Commented code:

O           % Push 0                                                          1
iq:         % Input n. Generate [1 2 ... n-1]                                 ·
"           % For loop: repeat n-1 times. Let k denote each iteration         2
  t         %   Duplicate vector of all seen values                           · 3
  X>Q       %   Take maximum, add 1                                           · ·
  :         %   Range from 1 to that: these are potential initial values      · ·
  y         %   Duplicate vector of all seen values                           · ·
  X-X<      %   Set difference, minimum: first value not seen                 · ·
  `         %   Do...while: this generates the k-th Collatz sequence          · 4
    t0)     %     Duplicate, push last value of the sequence so far           · · 5
    to      %     Duplicate, parity: 1 if odd, 0 if even                      · · ·
    ?       %     If odd                                                      · · ·
      3*Q   %       Times 3, plus 1                                           · · ·
    }       %     Else                                                        · · ·
      2/    %       Half                                                      · · ·
    ]       %     End if                                                      · · ·
    h       %     Concatenate new value of the sequence                       · · 6
    5M      %     Push the new value again                                    · · 7
    1>      %     Does it exceed 1? This is the loop condition                · · ·
  ]         %   End do...while. The loops ends when we have reached 0 or 1    · ·
  P         %   Reverse the k-th Collatz sequence                             · 8
  v         %   Concatenate with vector of previously seen values             · ·
]           % End for                                                         ·
0)          % Take last value. Implicitly display.                            9


问:
Write a program that uses all printable non-alphanumeric ASCII symbols
In particular, use each of these symbols at least once in your source code:

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

Symbols inside comments, string literals, regexps (or any other kinds of literals etc.) don't count (but their delimiters such as /**/ or "" do count).

The program should not perform any action. It just has to compile and do nothing when run.

If for some reason some of the symbols cannot be used in the language of your choice, explain that rigorously (what and why must be excluded).

Update: A few answers used symbols withing regular expressions. I'd consider this a bit problematic, it's the same thing as putting them into string literals or comments (that's why I put etc. in that requirement). Please try without this. I also updated the requirement above.

Update: Shortest code wins (tagged as code-golf). As suggested, we'll most likely need some tie-breaker criteria. I suggest that if there is a tie, the winning one is the one in which the ASCII symbols appear as much ordered as possible. Formally: Filter out the first occurrence of each of the listed symbols from a program. This will result in a permutation on the listed symbols. The program with less inversion number of its permutation wins.

Update: I'd be happy to see some/more solutions in regular/mainstream languages, such as C(++), Java, Scala, Haskell, etc.

答:
Postscript - 32 chars

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

Results in an object on the stack, but otherwise has no effects. Postscript allows almost any char in an identifier except for <>()[]{}/ which are special syntax forms and % which introduces a comment. The program is tokenized as

```<code>{                  % start a procedure object
!"#$&'             % an identifier
()                 % an empty string
*+,-.              % an identifier
/:;=               % a symbol
<>                 % an empty hex string
?@                 % an identifier
[\]                % an array
^_`~|              % an identifier
}                  % close the procedure object
%                  % a comment
</code>```

Body:
Postscript - 32 chars

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

Results in an object on the stack, but otherwise has no effects. Postscript allows almost any char in an identifier except for <>()[]{}/ which are special syntax forms and % which introduces a comment. The program is tokenized as

{                  % start a procedure object
!"#$&'             % an identifier
()                 % an empty string
*+,-.              % an identifier
/:;=               % a symbol
<>                 % an empty hex string
?@                 % an identifier
[\]                % an array
^_`~|              % an identifier
}                  % close the procedure object
%                  % a comment


问:
Make a (somewhat) self-referential string
You want to make a string where the (1-indexed) character at index n is n. When n is less than 10, this is easy: "123456789". When n is 12, for example, it becomes impossible, since numbers greater than 9 (in base 10) take up more than one character. We can compromise by dividing the string into two-character substrings: "020406081012". Now the index of the end of each substring n is n.

This can be generalized for any d-digit number. Here's an explanation for the "0991021" part of the string for a three-digit number:

```<code>Index:     ... * 97  98  99*100 101 102*103 ...
               *           *           *
               *---+---+---*---+---+---*---+
Character: ... * 0 | 9 | 9 * 1 | 0 | 2 * 1 | ...
               *---+---+---*---+---+---*---+
</code>```

If you haven't figured it out yet, you are to write a program/function that takes a string or integer and output its self-referential string as specified above. You can also output an array of single-digit numbers, chars, or single-character strings.

The given integer will always be positive and divisible by its length (e.g. 126 is divisible by 3; 4928 is divisible by 4). Your program should theoretically work for an arbitrarily large input, but you can assume it is smaller than your language's maximum integer and/or string length.

Some observations if you still don't get it: The length of the output will always be the input itself, and the numbers that appear in the output will be divisible by the number of digits in the input.

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

Test cases

```<code>1    => 1
9    => 123456789
10   => 0204060810
105  => 003006009012015018021024027030033036039042045048051054057060063066069072075078081084087090093096099102105
1004 => 00040008001200160020002400280032003600400044004800520056006000640068007200760080008400880092009601000104010801120116012001240128013201360140014401480152015601600164016801720176018001840188019201960200020402080212021602200224022802320236024002440248025202560260026402680272027602800284028802920296030003040308031203160320032403280332033603400344034803520356036003640368037203760380038403880392039604000404040804120416042004240428043204360440044404480452045604600464046804720476048004840488049204960500050405080512051605200524052805320536054005440548055205560560056405680572057605800584058805920596060006040608061206160620062406280632063606400644064806520656066006640668067206760680068406880692069607000704070807120716072007240728073207360740074407480752075607600764076807720776078007840788079207960800080408080812081608200824082808320836084008440848085208560860086408680872087608800884088808920896090009040908091209160920092409280932093609400944094809520956096009640968097209760980098409880992099610001004
</code>```

答:
PowerShell, 77 bytes

```<code>$x="$($args[0])";$l=$x.Length;-join(1..($x/$l)|%{"$($_*$l)".PadLeft($l,'0')})
</code>```

Uses string interpolation to shorten string casts. The parts before the second semicolon shorten the names of reused things. Then, every integer up to the input - and only those that are multiples of the input's length - are padded to be as long as the input string and finally joined into one.

Body:
PowerShell, 77 bytes

$x="$($args[0])";$l=$x.Length;-join(1..($x/$l)|%{"$($_*$l)".PadLeft($l,'0')})

Uses string interpolation to shorten string casts. The parts before the second semicolon shorten the names of reused things. Then, every integer up to the input - and only those that are multiples of the input's length - are padded to be as long as the input string and finally joined into one.


问:
Random Golf of the Day #7: A distinctly random character

About the Series

This is a guest entry for the Random Golf of the Day series.

First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You can find the leaderboard along with some more information about the series in the first post.

Input

No input is taken.

Output

A single letter of the alphabet (case irrelevant), with an optional trailing newline. Each letter must have non-zero probability of being chosen, and all 26 probabilities must be distinct. To remove all ambiguity: Distinct means that there must not be two probabilities that are equal to each other.

Scoring

This is code golf. Shortest code in bytes wins.

A valid entry is a full program or function that has zero probability of not terminating.

Alphabet

To avoid confusion, the particular alphabet to be used is the Latin alphabet:

Either

```<code>ABCDEFGHIJKLMNOPQRSTUVWXYZ
</code>```

or

```<code>abcdefghijklmnopqrstuvwxyz
</code>```

You may choose to output upper case or lower case. Alternatively, you may choose to output different cases on different runs if that helps. The probability for a given letter is the probability of that letter appearing in either case (upper or lower).

Explanation

As it won't be at all obvious from the output, please include a clear explanation of how you achieved the 26 distinct probabilities.

Leaderboard

(from here)

var QUESTION_ID=89621,OVERRIDE_USER=20283;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

```
</div>
</div>
</p>

<p><strong>The first post of the series also generates an overall leaderboard.</strong></p>

<p>To make sure that your answers show up, please start every answer with a headline, using the following Markdown template:</p>

```## Language Name, N bytes
```

<p>where <code>N</code> is the size of your submission. If you improve your score, you <em>can</em> keep old scores in the headline, by striking them through. For instance:</p>

```## Ruby, <s>104</s> <s>101</s> 96 bytes
```

(The language is not currently shown, but the snippet does require and parse it, and I may add a by-language leaderboard in the future.)

答:
Python 3, 58 bytes

```<code>from random import*;print(chr(randint(65,randint(65,91))))
</code>```

it is like that perl answer.

Body:
Python 3, 58 bytes

from random import*;print(chr(randint(65,randint(65,91))))

it is like that perl answer.


答:
ForceLang, 64 bytes

Noncompeting, uses language features (the string.char method) that postdate the question.

```<code>set s math.sqrt 676.mult random.rand()
io.write string.char 65+s
</code>```

Title: Random Golf of the Day #7: A distinctly random character

Body:
About the Series

This is a guest entry for the Random Golf of the Day series.

First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You can find the leaderboard along with some more information about the series in the first post.

Input

No input is taken.

Output

A single letter of the alphabet (case irrelevant), with an optional trailing newline. Each letter must have non-zero probability of being chosen, and all 26 probabilities must be distinct. To remove all ambiguity: Distinct means that there must not be two probabilities that are equal to each other.

Scoring

This is code golf. Shortest code in bytes wins.

A valid entry is a full program or function that has zero probability of not terminating.

Alphabet

To avoid confusion, the particular alphabet to be used is the Latin alphabet:

Either

```<code>ABCDEFGHIJKLMNOPQRSTUVWXYZ
</code>```

or

```<code>abcdefghijklmnopqrstuvwxyz
</code>```

You may choose to output upper case or lower case. Alternatively, you may choose to output different cases on different runs if that helps. The probability for a given letter is the probability of that letter appearing in either case (upper or lower).

Explanation

As it won't be at all obvious from the output, please include a clear explanation of how you achieved the 26 distinct probabilities.

Leaderboard

(from here)

var QUESTION_ID=89621,OVERRIDE_USER=20283;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

```
</div>
</div>
</p>

<p><strong>The first post of the series also generates an overall leaderboard.</strong></p>

<p>To make sure that your answers show up, please start every answer with a headline, using the following Markdown template:</p>

```## Language Name, N bytes
```

<p>where <code>N</code> is the size of your submission. If you improve your score, you <em>can</em> keep old scores in the headline, by striking them through. For instance:</p>

```## Ruby, <s>104</s> <s>101</s> 96 bytes
```

(The language is not currently shown, but the snippet does require and parse it, and I may add a by-language leaderboard in the future.)

Body:
ForceLang, 64 bytes

Noncompeting, uses language features (the string.char method) that postdate the question.

set s math.sqrt 676.mult random.rand()
io.write string.char 65+s


答:
Jelly, 5 bytes

```<code>ØAxJX
</code>```

(Equal score, but a different method, to an existing Jelly solution by Dennis.)

The probability of yielding each letter is it's 1-based index in the alphabet divided by 351 - the 26th triangular number:

P(A) = 1 / 351, P(B) = 2 / 351, ..., P(Z) = 26 / 351.

Since 1+2+...+26 = 351, P(letter) = 1.

Implementation:

```<code>ØAxJX    - no input taken
ØA       - yield the alphabet: 'ABC...Z'
   J     - yield [1,...,len(Left)]: [1,2,3,...26]
  x      - Left times Right: 'abbccc...zzzzzzzzzzzzzzzzzzzzzzzzzz'
    X    - choose random element from Left
</code>```

Test it on TryItOnline or get the distribution of 100K runs (code credit to Dennis)

Body:
Jelly, 5 bytes

ØAxJX

(Equal score, but a different method, to an existing Jelly solution by Dennis.)

The probability of yielding each letter is it's 1-based index in the alphabet divided by 351 - the 26th triangular number:

P(A) = 1 / 351, P(B) = 2 / 351, ..., P(Z) = 26 / 351.

Since 1+2+...+26 = 351, P(letter) = 1.

Implementation:

ØAxJX    - no input taken
ØA       - yield the alphabet: 'ABC...Z'
   J     - yield [1,...,len(Left)]: [1,2,3,...26]
  x      - Left times Right: 'abbccc...zzzzzzzzzzzzzzzzzzzzzzzzzz'
    X    - choose random element from Left

Test it on TryItOnline or get the distribution of 100K runs (code credit to Dennis)


答:
Python, <s>49</s> 42 bytes

Anonymous lambda:

-7 from xnor

lambda s:[t[:2]+t[1:]for t in s[:2]+s[1:]]
```

<p>Previous version:</p>

<pre class="lang-py prettyprint-override"><code>D=lambda s:s[:2]+s[1:]
lambda s:D(list(map(D,s)))
</code>```

D is a function that duplicates the second item of a sequence.

Title: Automatic box expander

Body:
Python, <s>49</s> 42 bytes

Anonymous lambda:

-7 from xnor

lambda s:[t[:2]+t[1:]for t in s[:2]+s[1:]]

Previous version:

D=lambda s:s[:2]+s[1:]
lambda s:D(list(map(D,s)))

D is a function that duplicates the second item of a sequence.


答:
Hexagony, 28 bytes (Non-competitive)

Compressed:

```<code>.$@.>;<..\'"/$\$/}{,<..>.../
</code>```

Try it Online!

Title: Reverse stdin and place on stdout

Body:
Requirements:

Take an input on stdin including new lines / carriage returns of unlimited length (only bounded by system memory; that is, there is no inherent limit in the program.)

Output the reverse of the input on stdout.

Example:

Input:

```<code>Quick brown fox
He jumped over the lazy dog
</code>```

Output:

```<code>god yzal eht revo depmuj eH
xof nworb kciuQ
</code>```

Shortest wins.

Leaderboard:

var QUESTION_ID=242,OVERRIDE_USER=61563;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

```

Body:
Hexagony, 28 bytes (Non-competitive)

Compressed:

.$@.>;<..\'"/$\$/}{,<..>.../

Try it Online!


答:
C, 35 bytes

This program assumes RAND_MAX is (2^32 / 2) - 1 as it is on gcc by default. Compile with the -lm flag to link the sqrt function. The output is written to stdout as capital letters without trailing newlines.

f(){putchar(sqrt(rand())/1783+65);}
```

<p>Optionally, if <code>RAND_MAX</code> is (2^16 / 2) - 1, a shorter 32 byte version can be used:</p>

<pre class="lang-c prettyprint-override"><code>f(){putchar(sqrt(rand())/7+65);}
</code>```

Just for fun, I also made a version that does not use the sqrt function or require the math library included (this one must have RAND_MAX as (2^32 / 2) - 1), but it ended up being longer even though I thought it was pretty cool:

f(){float r=rand()/64+1;putchar((*(int*)&r>>23)-62);}
```

<h2>Explanation</h2>

<h3>[First Program]</h3>

<p>For the first two using <code>sqrt</code>, the function simply maps the range <code>[0, RAND_MAX)</code> to <code>[0, 25]</code> through division, and then adds 65 (ASCII <code>A</code>) to the value to shift it into the ASCII alphabet before outputting it.</p>

<h3>[Second Program]</h3>

<p>The second program is a bit more complex as it does a similar strategy, but without the <code>sqrt</code> operator. Since a floating point's exponent bits are automatically calculated upon assigning an integer, they can effectively be used as a crude way to get the base 2 logarithm of a number.</p>

<p>Since we only want the range up to <code>RAND_MAX</code> to reach an encoded exponent value of 25, the calculation (2^32 / 2 - 1) / (2 ^ 25) gives us just about 64, which is used during the division of <code>rand</code> to map it to this new range. I also added 1 to the value as 0's floating point representation is rather odd and would break this algorithm.</p>

<p>Next, the float is type-punned to an integer to allow for bitshifting and other such operations. Since in IEEE 754 floating point numbers the exponent bits are bits 30-23, the number is then shifted right 23 bits, cutting off the mantissa and allowing the raw exponent value to be read as an integer. Do note that the sign bit is also beyond the exponent bits, but since there are never any negatives it does not have to be masked out.</p>

<p>Rather than adding 65 to this result like we did before however, floating point exponents are represented as an unsigned 8 bit integer from 0 to 255, where the exponent value of 0 is 127 (Simply subtract 127 to get the actual "signed" exponent value). Since 127 - 65 is 62, we instead simply subtract 62 to both shift it out of this floating point exponent range and into the ASCII alphabet range all in one operation.</p>

<h2>Distribution</h2>

<p>I'm not math expert so I cannot say for sure the exact formula for these distributions, but I can (and did) test every value on the range <code>[0, RAND_MAX)</code> to show that the distance between where one letter's range ends and the other begins are never the same. (Note these tests assume the (2^32 / 2) - 1) random maximum)</p>

<h3>[First Program]</h3>

<pre class="lang-none prettyprint-override"><code>Letter - Starting Location
A - 0
B - 3179089
C - 12716356
D - 28611801
E - 50865424
F - 79477225
G - 114447204
H - 155775361
I - 203461696
J - 257506209
K - 317908900
L - 384669769
M - 457788816
N - 537266041
O - 623101444
P - 715295025
Q - 813846784
R - 918756721
S - 1030024836
T - 1147651129
U - 1271635600
V - 1401978249
W - 1538679076
X - 1681738081
Y - 1831155264
Z - 1986930625
</code>```

[Second Program]

Letter - Starting Location
A - 0
B - 64
C - 192
D - 448
E - 960
F - 1984
G - 4032
H - 8128
I - 16320
J - 32704
K - 65472
L - 131008
M - 262080
N - 524224
O - 1048512
P - 2097088
Q - 4194240
R - 8388544
S - 16777152
T - 33554368
U - 67108800
V - 134217664
W - 268435392
X - 536870848
Y - 1073741760
Z - 2147483520
```

Body:
C, 35 bytes

This program assumes RAND_MAX is (2^32 / 2) - 1 as it is on gcc by default. Compile with the -lm flag to link the sqrt function. The output is written to stdout as capital letters without trailing newlines.

f(){putchar(sqrt(rand())/1783+65);}

Optionally, if RAND_MAX is (2^16 / 2) - 1, a shorter 32 byte version can be used:

f(){putchar(sqrt(rand())/7+65);}

Just for fun, I also made a version that does not use the sqrt function or require the math library included (this one must have RAND_MAX as (2^32 / 2) - 1), but it ended up being longer even though I thought it was pretty cool:

f(){float r=rand()/64+1;putchar((*(int*)&r>>23)-62);}

Explanation

[First Program]

For the first two using sqrt, the function simply maps the range [0, RAND_MAX) to [0, 25] through division, and then adds 65 (ASCII A) to the value to shift it into the ASCII alphabet before outputting it.

[Second Program]

The second program is a bit more complex as it does a similar strategy, but without the sqrt operator. Since a floating point's exponent bits are automatically calculated upon assigning an integer, they can effectively be used as a crude way to get the base 2 logarithm of a number.

Since we only want the range up to RAND_MAX to reach an encoded exponent value of 25, the calculation (2^32 / 2 - 1) / (2 ^ 25) gives us just about 64, which is used during the division of rand to map it to this new range. I also added 1 to the value as 0's floating point representation is rather odd and would break this algorithm.

Next, the float is type-punned to an integer to allow for bitshifting and other such operations. Since in IEEE 754 floating point numbers the exponent bits are bits 30-23, the number is then shifted right 23 bits, cutting off the mantissa and allowing the raw exponent value to be read as an integer. Do note that the sign bit is also beyond the exponent bits, but since there are never any negatives it does not have to be masked out.

Rather than adding 65 to this result like we did before however, floating point exponents are represented as an unsigned 8 bit integer from 0 to 255, where the exponent value of 0 is 127 (Simply subtract 127 to get the actual "signed" exponent value). Since 127 - 65 is 62, we instead simply subtract 62 to both shift it out of this floating point exponent range and into the ASCII alphabet range all in one operation.

Distribution

I'm not math expert so I cannot say for sure the exact formula for these distributions, but I can (and did) test every value on the range [0, RAND_MAX) to show that the distance between where one letter's range ends and the other begins are never the same. (Note these tests assume the (2^32 / 2) - 1) random maximum)

[First Program]

Letter - Starting Location
A - 0
B - 3179089
C - 12716356
D - 28611801
E - 50865424
F - 79477225
G - 114447204
H - 155775361
I - 203461696
J - 257506209
K - 317908900
L - 384669769
M - 457788816
N - 537266041
O - 623101444
P - 715295025
Q - 813846784
R - 918756721
S - 1030024836
T - 1147651129
U - 1271635600
V - 1401978249
W - 1538679076
X - 1681738081
Y - 1831155264
Z - 1986930625

[Second Program]

Letter - Starting Location
A - 0
B - 64
C - 192
D - 448
E - 960
F - 1984
G - 4032
H - 8128
I - 16320
J - 32704
K - 65472
L - 131008
M - 262080
N - 524224
O - 1048512
P - 2097088
Q - 4194240
R - 8388544
S - 16777152
T - 33554368
U - 67108800
V - 134217664
W - 268435392
X - 536870848
Y - 1073741760
Z - 2147483520


答:
Mathematica, 34 bytes

```<code>RandomChoice[Range@26->Alphabet[]]
</code>```

RandomChoice[wlist -> elist] gives a random choice of elist weighted by wlist.

Body:
Mathematica, 34 bytes

RandomChoice[Range@26->Alphabet[]]

RandomChoice[wlist -> elist] gives a random choice of elist weighted by wlist.


答:
Ruby, 42 bytes

```<code>$><<(?A..?Z).flat_map{|c|[c]*c.ord}.sample
</code>```

Quite straightforward: Generate 65 A's; 66 B's; ...  90 Z's, and randomly pick one of the letters generated.

Body:
Ruby, 42 bytes

$><<(?A..?Z).flat_map{|c|[c]*c.ord}.sample

Quite straightforward: Generate 65 A's; 66 B's; ...  90 Z's, and randomly pick one of the letters generated.


答:
Befunge, <s>168</s> 164 bytes

More compact than the first one, with a little different probabilities: The first ? have a 1/4 chance of printing an A on "first try", 2/4 chance to come back to the same ?, and 1/4 to move to the next. The rest of the ?s each have 1/4 chance of printing the letter underneath them, 1/4 to try again, 1/4 moving to the next letter, 1/4 moving to the previous. Again, the probability of printing an A is a lot higher than printing a Z.

```<code>??????????????????????????>
""""""""""""""""""""""""""
ABCDEFGHIJKLMNOPQRSTUVWXYZ
""""""""""""""""""""""""""
>>>>>>>>>>>>>>>>>>>>>>>>>>,@
##########################
</code>```

Befunge, 186 bytes

Obviously not gonna win with this, but I think it's an interesting answer nonetheless :)

v and > steers the cursor respectively downwards and to the right.
The ? operator sends the cursor off in one of four directions randomly. The first ? is "blocked" by v and > in two directions, so it only has two way to go: Either to print the A, or down to the next ?. So from the first ? alone there is a 50% chance of printing an A.

The next ? has a 1/3 chance of printing a B, 1/3 of going back up, and 1/3 of going further down. Etc etc.

It should be quite obvious that the higher letters have a much larger chance of being printed than the lower ones, but I'm not exactly sure what each letter's chances are.

Some help with the exact math would be appreciated :)

At least there's a 1/2 * 1/3^25 chance that the cursor moves all the way down to the Z on the first try, but I'm uncertain how the chances of the cursor moving up and down affects each letter.

,@ prints and quits.

```<code> v
>?"A"v
>?"B"v
>?"C"v
>?"D"v
>?"E"v
>?"F"v
>?"G"v
>?"H"v
>?"I"v
>?"J"v
>?"K"v
>?"L"v
>?"M"v
>?"N"v
>?"O"v
>?"P"v
>?"Q"v
>?"R"v
>?"S"v
>?"T"v
>?"U"v
>?"V"v
>?"W"v
>?"X"v
>?"Y"v
>?"Z">,@
</code>```

Body:
Befunge, <s>168</s> 164 bytes

More compact than the first one, with a little different probabilities: The first ? have a 1/4 chance of printing an A on "first try", 2/4 chance to come back to the same ?, and 1/4 to move to the next. The rest of the ?s each have 1/4 chance of printing the letter underneath them, 1/4 to try again, 1/4 moving to the next letter, 1/4 moving to the previous. Again, the probability of printing an A is a lot higher than printing a Z.

??????????????????????????>
""""""""""""""""""""""""""
ABCDEFGHIJKLMNOPQRSTUVWXYZ
""""""""""""""""""""""""""
>>>>>>>>>>>>>>>>>>>>>>>>>>,@
##########################

Befunge, 186 bytes

Obviously not gonna win with this, but I think it's an interesting answer nonetheless :)

v and > steers the cursor respectively downwards and to the right.
The ? operator sends the cursor off in one of four directions randomly. The first ? is "blocked" by v and > in two directions, so it only has two way to go: Either to print the A, or down to the next ?. So from the first ? alone there is a 50% chance of printing an A.

The next ? has a 1/3 chance of printing a B, 1/3 of going back up, and 1/3 of going further down. Etc etc.

It should be quite obvious that the higher letters have a much larger chance of being printed than the lower ones, but I'm not exactly sure what each letter's chances are.

Some help with the exact math would be appreciated :)

At least there's a 1/2 * 1/3^25 chance that the cursor moves all the way down to the Z on the first try, but I'm uncertain how the chances of the cursor moving up and down affects each letter.

,@ prints and quits.

 v
>?"A"v
>?"B"v
>?"C"v
>?"D"v
>?"E"v
>?"F"v
>?"G"v
>?"H"v
>?"I"v
>?"J"v
>?"K"v
>?"L"v
>?"M"v
>?"N"v
>?"O"v
>?"P"v
>?"Q"v
>?"R"v
>?"S"v
>?"T"v
>?"U"v
>?"V"v
>?"W"v
>?"X"v
>?"Y"v
>?"Z">,@


问:
Square free Numbers
Given a number N, write the shortest complete program to find the number of square-free integers below N.

```<code>Sample Input
100000
Sample Output
60794
</code>```

Constraints:

Should work for all positive N below 1,000,000

Should not take more than 10 secs.

Please do not use built in functions, please.

答:
Java Solution

```<code>import java.io.*;
    public class Main{
            public static void main(String[] args)throws Exception {
              int N=Integer.parseInt(new BufferedReader(new InputStreamReader(System.in)).readLine());
              int list[]=new int[N];
    for (int i=0;i<N;i++){
    list[i]=(i+1);
    }
    for (int i=1;i<N;i++){
    if (Math.sqrt(list[i])-Math.floor(Math.sqrt(list[i]))==0){
    for(int j=i;j<N;j+=(i+1)){
    list[j]=-1;
    }}}
    int c=0;
    for (int i=0;i<N;i++){
    if (list[i]!=-1){
    c++;
    }}System.out.println(c);}}
</code>```

IDEONE  http://ideone.com/Yf467

ContentLicense: CC BY-SA 2.5

Title: Square free Numbers

Body:
Java Solution

import java.io.*;
    public class Main{
            public static void main(String[] args)throws Exception {
              int N=Integer.parseInt(new BufferedReader(new InputStreamReader(System.in)).readLine());
              int list[]=new int[N];
    for (int i=0;i<N;i++){
    list[i]=(i+1);
    }
    for (int i=1;i<N;i++){
    if (Math.sqrt(list[i])-Math.floor(Math.sqrt(list[i]))==0){
    for(int j=i;j<N;j+=(i+1)){
    list[j]=-1;
    }}}
    int c=0;
    for (int i=0;i<N;i++){
    if (list[i]!=-1){
    c++;
    }}System.out.println(c);}}

IDEONE  http://ideone.com/Yf467


问:
Smile! Just smile
It's well known that Brainf*ck is very bad at Kolmogorov-complexity problems, for example, it requires around 100 characters just to print "Hello world".

However, there might be texts where Brainf*ck is just very good at.

Your task is now to write a program that takes no input, and it displays the following:

```<code>☺
</code>```

That is, a smiley face (ASCII 1, if you browser does not render it).

Brainf*ck can do it in 2 characters.

```<code>+.
</code>```

Try to find a language that beats it!

We assume your console can actually display that character (or your font has it, etc.).

Shortest code wins. If there are more of the same length, the first wins, but I'll upvote the others as well.

EDIT: I'm very sorry, I did not think the first post arrives this soon. A quick edit: the language has to be Turing-complete!

答:
LaTeX (51/77 characters)

Short solution

```<code>\documentclass{book}
\begin{document}
☺
\end{document}
</code>```

Good solution (Compile with latex main.tex):

```<code>\documentclass{book}
\usepackage{wasysym}
\begin{document}
\smiley
\end{document}
</code>```

Title: Smile! Just smile

Body:
LaTeX (51/77 characters)

Short solution

\documentclass{book}
\begin{document}
☺
\end{document}

Good solution (Compile with latex main.tex):

\documentclass{book}
\usepackage{wasysym}
\begin{document}
\smiley
\end{document}


问:
Input ∩ Source Code

Intro

The challenge is to create a program/function that prints the intersection of its own source code and a given string input. This is code golf and to be more precise:

Let I be the input set

{"a","b","c"}

Let S be the source code set

{"b","f"}

Then the intersection is what they share

I ∩ S = {"b"}

Input

Input is flexible. It should be able to handle the character encoding used for the source code.

Output

Output is flexible. It should be the set of characters that the input and source code share. Also, sets are unordered collections of distinct objects. In summary:

Output is flexible:

Could be any data structure (string or otherwise)

Could unordered

Could have a trailing \n

Should be distinct

Restriction

Similar to quine challenges, the program/function may not read its own source code and 0-byte solutions are not allowed.

Examples

#1

```<code>functor x(I){ return I ∩ self; }

Inputs                                Outputs
------                                -------
enter preformatted text here      ->  {"e","n","t","r","f","o","x"}

["Albrt"," Einstin"]              ->  {"l","r","t","n","s"}
</code>```

#2

```<code>(_)->_&"(_)->&\"\\"

Inputs                                Outputs
------                                -------
"Security at the expense of       ->  "
usability comes at the expense
of security."

(0____0)                          ->  (_)
</code>```

#3

```<code>ಠa益длф

Inputs                                Outputs
------                                -------
Far out in the uncharted backwaters ->"a"
of the unfashionable end of the
Western Spiral arm of the Galaxy lies
a small unregarded yellow sun.
Orbiting this at a distance of roughly
ninety-eight million miles is an
utterly insignificant little blue-green
planet whose ape-descended life forms
are so amazingly primitive that they
still think digital watches are a pretty
neat idea.

(ノಠ益ಠ)ノ彡┻━┻                      ->"ಠ益"
</code>```

Test Cases

```<code>Albert Einstein

\__( O__O)_/

!@#$%^&*()_+{}|:"<>?

1234567890-=[]\;',./

(ノಠ益ಠ)ノ彡┻━┻

“¤>%,oỊȤʠ“ØụĊ5D³ṃṠɼQ»j;Ç;“;}¶”

┬──┬ ノ( ゜-゜ノ)

Far out in the uncharted backwaters of the unfashionable end of the Western Spiral arm of the Galaxy lies a small unregarded yellow sun. Orbiting this at a distance of roughly ninety-eight million miles is an utterly insignificant little blue-green planet whose ape-descended life forms are so amazingly primitive that they still think digital watches are a pretty neat idea.
</code>```

Update

[16-08-10]: sets are unordered collections of distinct objects

[16-08-10]: trailing newline is acceptable

答:
C#, 36 bytes

```<code>s=>s.Intersect("s=>.Interc(\"\\);");
</code>```

Intended cast is Func<string, IEnumerable<char>> (string input, IEnumerable<char> output).

Title: Input ∩ Source Code

Body:
C#, 36 bytes

s=>s.Intersect("s=>.Interc(\"\\);");

Intended cast is Func<string, IEnumerable<char>> (string input, IEnumerable<char> output).


问:
Sort the months of the year
Write a function or program that takes string inputs, fully-spelled, English month names in title case: January, February, March, etc. (null/CR/LF terminated OK, delimited with some non-alpha character if you so choose) and either

compares two inputs, returning a Truthy value if the second input is greater (in month order) than the first. Equal values result in a Falsey value

or sorts an arbitrary sequence (list, delimited string, etc.) of them in chronological order

(The crux of the challenge is defining a method/expression that gives the correct lexicographical sort. Some languages might have a shorter answer with one or the other)

You cannot use any internal time parsing methods (e.g. strptime) to translate the month name into a number or a pre-canned mapping of month names. Use properties of the strings themselves, a parsimonious look-up table you define, or something clever.

Example

Functioning examples, though the first is prohibited by the rules...

```<code>import datetime
def is_later_month(a, b):
    '''
    Example of prohibited code because it relies on language
    features about how to parse month names
    '''
    return datetime.strptime(a, '%B') < datetime.strptime(b, '%B')
</code>```

The below versions are OK though, because we code that info

```<code>months = {
    'January':  1, 'February':  2, 'March':      3,
    'April':    4, 'May':       5, 'June':       6,
    'July':     7, 'August':    8, 'September':  9,
    'October': 10, 'November': 11, 'December':  12,
}
def is_later_month(a, b):
    """
    Returns True/False when comparing two months.
    """
    return months[a] < months[b]
</code>```

Or you could do a sorting function

```<code>months = {'as above...'}
def sort_months(l):
    """
    Sorts list and returns it. Different input and output than the above,
    but equally valid. Sorting versus comparing might be shorter in your
    favorite language.
    """
    return sorted(l, key=lambda x: months[x])
</code>```

Example tests

```<code>assert is_later_month('January', 'February')
assert is_later_month('January', 'December')
assert is_later_month('November', 'December')
assert not is_later_month('July', 'July')
assert not is_later_month('October', 'September')
</code>```

答:
k4, 29

```<code>{x@<"ubMAanlseovc"?(*|11#)'x}
</code>```

A port of @Dennis's Jelly answer.

This is the sorter, not the comparator; interestingly, the comparator is trivially implementable by the same algorithm, and only one byte longer:

```<code>{(<)."ubMAanlseovc"?(*|11#)'x}
</code>```

Title: Sort the months of the year

Body:
k4, 29

{x@<"ubMAanlseovc"?(*|11#)'x}

A port of @Dennis's Jelly answer.

This is the sorter, not the comparator; interestingly, the comparator is trivially implementable by the same algorithm, and only one byte longer:

{(<)."ubMAanlseovc"?(*|11#)'x}


答:
k4, 27

```<code>{,/"0"^(-c)$$c*1+!_x%c:#$x}
</code>```

Not really golfed at all, just a straight-forward implementation of the spec.

```<code>                        $ / string
                       #  / count
                     c:   / assign to c
                   x%     / divide x by
                  _       / floor
                 !        / range (0-based)
               1+         / convert to 1-based
             c*           / multiply by count
            $             / string
       (-c)               / negative count
           $              / pad (negative width -> right-aligned)
   "0"^                   / fill blanks with zeros
 ,/                       / raze (list of string -> string)
</code>```

Title: Make a (somewhat) self-referential string

Body:
You want to make a string where the (1-indexed) character at index n is n. When n is less than 10, this is easy: "123456789". When n is 12, for example, it becomes impossible, since numbers greater than 9 (in base 10) take up more than one character. We can compromise by dividing the string into two-character substrings: "020406081012". Now the index of the end of each substring n is n.

This can be generalized for any d-digit number. Here's an explanation for the "0991021" part of the string for a three-digit number:

```<code>Index:     ... * 97  98  99*100 101 102*103 ...
               *           *           *
               *---+---+---*---+---+---*---+
Character: ... * 0 | 9 | 9 * 1 | 0 | 2 * 1 | ...
               *---+---+---*---+---+---*---+
</code>```

If you haven't figured it out yet, you are to write a program/function that takes a string or integer and output its self-referential string as specified above. You can also output an array of single-digit numbers, chars, or single-character strings.

The given integer will always be positive and divisible by its length (e.g. 126 is divisible by 3; 4928 is divisible by 4). Your program should theoretically work for an arbitrarily large input, but you can assume it is smaller than your language's maximum integer and/or string length.

Some observations if you still don't get it: The length of the output will always be the input itself, and the numbers that appear in the output will be divisible by the number of digits in the input.

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

Test cases

```<code>1    => 1
9    => 123456789
10   => 0204060810
105  => 003006009012015018021024027030033036039042045048051054057060063066069072075078081084087090093096099102105
1004 => 00040008001200160020002400280032003600400044004800520056006000640068007200760080008400880092009601000104010801120116012001240128013201360140014401480152015601600164016801720176018001840188019201960200020402080212021602200224022802320236024002440248025202560260026402680272027602800284028802920296030003040308031203160320032403280332033603400344034803520356036003640368037203760380038403880392039604000404040804120416042004240428043204360440044404480452045604600464046804720476048004840488049204960500050405080512051605200524052805320536054005440548055205560560056405680572057605800584058805920596060006040608061206160620062406280632063606400644064806520656066006640668067206760680068406880692069607000704070807120716072007240728073207360740074407480752075607600764076807720776078007840788079207960800080408080812081608200824082808320836084008440848085208560860086408680872087608800884088808920896090009040908091209160920092409280932093609400944094809520956096009640968097209760980098409880992099610001004
</code>```

Body:
k4, 27

{,/"0"^(-c)$$c*1+!_x%c:#$x}

Not really golfed at all, just a straight-forward implementation of the spec.

                        $ / string
                       #  / count
                     c:   / assign to c
                   x%     / divide x by
                  _       / floor
                 !        / range (0-based)
               1+         / convert to 1-based
             c*           / multiply by count
            $             / string
       (-c)               / negative count
           $              / pad (negative width -> right-aligned)
   "0"^                   / fill blanks with zeros
 ,/                       / raze (list of string -> string)


答:
V, <s>6</s> 5 bytes

```<code>yêpjÄ
</code>```

Try it online!

This is actually a byte longer than it should be. It should have been:

```<code>äêjÄ
</code>```

But this has an unknown bug. :(

Explanation:

```<code>yê     "yank this colum
  p    "paste what we just yanked
   j   "move down to line 2
    Ä  "and duplicate this line
</code>```

Title: Automatic box expander

Body:
Introduction

Sometimes, my boxes are too small to fit anything in it. I need you to make a box expander! So, what makes a box a box in this challenge.

```<code> OOOO
O    O
O    O
O    O
 OOOO
</code>```

The corners of the box are always spaces. The box itself can be made out of the same character. That character can be any printable ASCII character, except a space. So, that's these characters:

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

The side lengths of the box above are 4, 3. You may assume that the side length is always positive. That means that this is the smallest box you need to handle:

```<code> #
# #
 #
</code>```

In order to expand a box, you need to increment each side length. Let's go through this, step by step, with the above example. We first take the upper side of the box, which is:

```<code> OOOO
</code>```

We expand this by one, so we get:

```<code> OOOOO
</code>```

This is the upper and lower part of the box now. After that, we do the same with the sides on the left and right:

```<code>O
O
O
</code>```

Becomes:

```<code>O
O
O
O
</code>```

Now we reassemble the box, which results into:

```<code> OOOOO
O     O
O     O
O     O
O     O
 OOOOO
</code>```

The task

Given a box, expand it by 1. The box can be given in multiple lines, or in an array.

Test cases

```<code> OOOO          OOOOO
O    O    >   O     O
 OOOO         O     O
               OOOOO

 XXXXXX        XXXXXXX
X      X  >   X       X
X      X      X       X
 XXXXXX       X       X
               XXXXXXX

 ~             ~~
~ ~       >   ~  ~
 ~            ~  ~
               ~~
</code>```

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

Body:
V, <s>6</s> 5 bytes

yêpjÄ

Try it online!

This is actually a byte longer than it should be. It should have been:

äêjÄ

But this has an unknown bug. :(

Explanation:

yê     "yank this colum
  p    "paste what we just yanked
   j   "move down to line 2
    Ä  "and duplicate this line