# 匿名命名-有点

16

“ evil_company_that_makes_me_shiver”

``````"ev**************************"
``````

``````"**il************************"
``````

``````"****_c**********************"
``````

``````~\$ ./whistle NSA 3
> "N**"
> "**A"
> "*S*"
``````

``````~\$ ./whistle nuclear 3
> "nu*****"
> "***lea*"
> "**c***r"
``````

``````~\$ ./whistle nuclear 2
> "nuc****"
> "***lear"
``````

1

Bill Woodger

german_guy 2014年

Bill Woodger

1

ɐɔıʇǝɥʇuʎs

12

### GolfScript，26个字符

``````:f,\`{{\)f%.!@42if}%\;n}+%
``````

``````> "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 7
******G******N******U*****
*****F******M******T******
****E******L******S******Z
***D******K******R******Y*
**C******J******Q******X**
*B******I******P******W***
A******H******O******V****
``````

``````:f           # Save the second input to variable f
,            # Makes the array [0 1 2 .... f-1]
\`{          # \´{}+% builds a code block where
# first the input string is pushed (done
# via the + operator and afterwards the whole
# block is applied to above array, i.e.
# For each line 0, 1, ...
#   Here, the stack contains the line number (counter)
#   and the string
{          #   {}% -> map to each character of the string
#     Stack contains counter and current character
\)f%     #     Increase the counter by one and calculate modulo f
.        #     Duplicate counter (will be used for the if below)
!        #     and test for zero
#     I.e. if counter==0
@        #       Then Current character
42       #       Else 42 (which is '*')
if       #
}%         #   The mapping operation masked most of the characters
}+%
``````

9

Evpok

@JohnOdom尽管如此，我还是在代码中添加了一些注释。

Cruncher 2014年

7

## PHP-80字节

``````<?for(;(\$c=\$argv[1][~-\$i+=1])?:\$k^++\$j;)echo\$c?\$i%\$k=&\$argv[2]^\$j?'*':\$c:\$i='
';
``````

``````\$ php whistle-blower.php ABCDEFGHIJKLMNOPQRSTUVWXYZ 7
******G******N******U*****
A******H******O******V****
*B******I******P******W***
**C******J******Q******X**
***D******K******R******Y*
****E******L******S******Z
*****F******M******T******
``````

7

# 蟒（157 149 139 138-20 = 118）：

``````def f(a,b):
from random import*;c=[["*"]*len(a) for i in range(b)]
for d in range(len(a)):choice(c)[d]=a[d]
for e in c:print "".join(e)
``````

# 俗气的python（55 35）：

``````g=lambda a,b:["*"*len(a)]*(b-1)+[a]
``````

# 均匀蟒（129 123 122）：

``````def h(a,b):
c=[["*"]*len(a)for i in range(b)]
for d in range(len(a)):c=c[1:]+c[:1];c[0][d]=a[d]
for e in c:print"".join(e)
``````

# 输出：

``````a="Synthetica 'Evil' the Second"
b=7
f(a,b)
print
for i in g(a,b): print i
print
h(a,b)
``````

``````***t***i***'***** *********d
******************t** ******
******t*** ***********Se**n*
S**************l****e*******
*y******c***E************o**
**n*h****a**************c***
*****e*******vi*'**h********

****************************
****************************
****************************
****************************
****************************
****************************
Synthetica 'Evil' the Second

******t******v******e******d
S******i******i****** ******
*y******c******l******S*****
**n******a******'******e****
***t****** ****** ******c***
****h******'******t******o**
*****e******E******h******n*
``````

cjfaure

@Trimsty我知道了，谢谢:)
ɐɔıʇǝɥʇuʎs

3

2014年

@Howard我知道这是在扩展规则，但`disclose the letters bit by bit`也可以表示`first, disclose the first bit (that just happens to be the entire thing), repeat until the b is met`。第一个答案也可能发生这种情况，因此只需声明您使用了那个答案，它就恰好产生了这个结果。（我刚刚意识到，您也可以将其写为`["*"*len(a)]*(b-1)+[a]`，以便从公开刚好包含0字节实际信息的位开始，然后在最后一行公开另一位。）但是，我确实意识到，这正在伸展到最大。
ɐɔıʇǝɥʇuʎs

3

# Bash，80个字节

``````m=\${1//?/*}
for((i=1;d=i*\${#1}/\$2,i++<=\$2;c=d)){
echo "\${m:0:c}\${1:c:d-c}\${m:d}"
}
``````

```\$ ./anon.sh stackoverflow.com 6

** ack ************
***** ove *********
******** rfl ******
***********现在。***
************** com
\$
```

2

## C＃，226

``````private void F(string n, int i)
{
var l = n.Length;
var r = new Random();
var a = new string[i];

for (var p = 0; p < l; p++)
{
var x = r.Next(0, i);
for (var j = 0; j < i; j++)
{
a[j] += j == x ? n.Substring(p, 1) : "*";
}
}

for (var j = 0; j < i; j++)
{
Console.WriteLine(a[j]);
}
}
``````

``````Anonymize.exe ABCDEFGHIJKLMNOPQRSTUVWXYZ 7
*****F**I**********T**W***
A*****************S****X**
**CDE**H*JKL**************
*************N************
**************O*****U****Z
*B****G*****M***QR********
***************P*****V**Y*
``````

deroby 2014年

2

# Perl，24岁

``````\$_ x=<>;s/(.|
)./\1*/g
``````

### 怎么运行的

• 由于`-p`切换，Perl读取第一个输入lie并将其内容存储在中`\$_`

• 该命令`\$_ x=<>;`将第二条输入行（`<>`）指定的次数复制第一条输入行。

• 该命令使用`s/(.|\n)./\1*/g;`两个字符，并用星号替换第二个字符（不能是换行符）。它将执行此操作，直到耗尽了的全部内容`\$_`

由于换行符是第一个字符，因此这将混淆第一行中的所有偶数字符和其余行中的所有奇数字符。

• 由于`-p`切换，Perl将打印的内容`\$_`

### 输入示例

``````codegolf
4
``````

### 输出示例

``````c*d*g*l*
*o*e*o*f
*o*e*o*f
*o*e*o*f
``````

CSᵠ

@BillWoodger：该问题未指定输入形式。

Bill Woodger

`Since newlines count as the first character, this will obfuscate all even characters on the first line and all odd characters on the remaining lines.`听起来像是失败了`codegolf\n1`
Cruncher

1

# Java-490

``````import java.util.ArrayList;public class Anonymise {public static void  main(String[] args){ArrayList[] c=new ArrayList[Integer.parseInt(args[1])];for(int i=0;i<c.length;i++)c[i]=new ArrayList();for(char a:args[0].toCharArray()){int f=new java.util.Random().nextInt(c.length);c[f].add(a);for(int i=0;i<c.length;i++)if(i!=f)c[i].add('*');}ArrayList<String> b = new ArrayList<String>();for(ArrayList a:c){String s = "";for(Object o : a)s += o;b.add(s);}for(String s : b)System.out.println(s);}}
``````

``````import java.util.ArrayList;

public class Anonymise {

public static void main(String[] args){
ArrayList[] c = new ArrayList[Integer.parseInt(args[1])];
for(int i=0;i<c.length;i++)
c[i]=new ArrayList();
for(char a:args[0].toCharArray()){
int f = new java.util.Random().nextInt(c.length);
for(int i=0;i<c.length;i++)
}
ArrayList<String> b = new ArrayList<String>();
for(ArrayList a:c){
String s = "";
for(Object o : a)
}
for(String s : b)
System.out.println(s);
}
}
``````

``````> java Anonymise OnlinePerson 3
*n****P***o*
O*li***e****
****ne**rs*n
``````

Bill Woodger

Ypnypn 2014年

1

# Python 3-187（-20 = 167）

``````import sys,random as a
b=sys.argv
x=[""for i in' '*int(b[2])]
for i in range(len(b[1])):n=a.randrange(len(x));x=[c+["*",b[1][len(c)]][j==n]for j,c in enumerate(x)]
for i in x:print(i)
``````

``````\$ python tx.py super_anonymous_user 3
s******n**y*ou****e*
**p***a**n*m**s_us*r
*u*er_**o***********
``````

## 作为功​​能-161（-20 = 141）

``````from random import*
def f(c,n):
x=[""for i in' '*n]
for i in range(len(c)):n=randrange(len(x));x=[v+["*",c[len(v)]][j==n]for j,v in enumerate(x)]
return x
``````

Bill Woodger 2014年

@BillWoodger号
cjfaure

2

user2357112支持Monica 2014年

2

1

# C＃184

``````namespace System.Linq{class P{static void Main(string[] a){int n=int.Parse(a[1]);for(int i=0;i<n;i++)Console.WriteLine(new String(a[0].Select((c,x)=>(i+x)%n==0?c:'*').ToArray()));}}}
``````

``````namespace System.Linq
{
class P
{
static void Main(string[] a)
{
int n = int.Parse(a[1]);
for (int i = 0; i < n; i++)
Console.WriteLine(new String(a[0].Select((c, x) => (i + x) % n == 0 ? c : '*').ToArray()));
}
}
}
``````

``````> Anonymize.exe "qwertyuio" 4
q***t***o
***r***i*
**e***u**
*w***y***
``````

1

# Perl 6（77个字节）

``````(\$_,\$!)=@*ARGS;.say for .chop~"*","*"x.chars-1~.substr(*-1),"*"x.chars xx\$!-2
``````

``````> ./script.p6 ultimately_awesome 6
ultimately_awesom*
*****************e
******************
******************
******************
******************
``````

1

# JavaScript-170

``````function s(a,e){o="",b=a.length,x=b/e|0,y=b-x*e;for(c=1;c<=e;c++){r="*";o+=Array((c-1)*x+1).join(r)+a.substr(c*x-x,c==e?x+y:x)+Array(c<e?b-c*x+1:0).join(r)+"\n"}return o}
``````

`function s(d,a){o="";b=d.length;x=Math.floor(b/a);y=b-x*a;for(c=1;c<=a;c++)r="*",o+=Array((c-1)*x+1).join(r)+d.substr(c*x-x,c==a?x+y:x)+Array(c<a?b-c*x+1:0).join(r)+"\n";return o};` Closure-compiler.appspot.com/home能够削减 8个字符；）
ɐɔıʇǝɥʇuʎs2014年

@BillWoodger他说，使用闭包编译器，他从代码的总长度中减少了8个字符。
Eduard Florinescu 2014年

@EduardFlorinescu，对不起，我不清楚，我的意思是`breaks if you supply a name and ask for more pieces than characters`
Bill Woodger

1

1

# R，（120-20）= 100字节（2个相同长度的不同解决方案）

``````function(s,n){
c=strsplit(s,"")[[1]]
e=sample(n,nchar(s),T)
sapply(1:n,function(i)paste(ifelse(e==i,c,"*"),collapse=""))
}``````

``````> f("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 7)
"******GH*****************Z"
"ABCD*********N************"
"***********L**O***********"
"*********J**M**P*RS*U**X**"
"**********K***********W***"
"*****F**I*******Q*********"
"****E**************T*V**Y*"
``````

``````function(s,n){
x=matrix("*",n,(m=nchar(s)))
x[cbind(sample(n,m,T),1:m)]=strsplit(s,"")[[1]]
apply(x,1,paste,collapse="")
}``````

0

# Scala（1）177字节

``````def f(s:String, n:Int)={
def c=s map (z=>z.toString)
def r=(1 to s.length) map (v=>v%n+1)
(for (i<-1 to n) yield s zip r map (t=>if(t._2==i) t._1 else "*") mkString "") map println
}``````

# Scala（2）129字节

``````def f(s:String, n:Int)={
(for (i<-0 until n) yield s.zipWithIndex.map (t=>if(t._2 % n==i) t._1 else "*") mkString "") map println
}``````

``````f("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 4)
***D***H***L***P***T***X**
A***E***I***M***Q***U***Y*
*B***F***J***N***R***V***Z
**C***G***K***O***S***W***
``````

0

# Javascript-166

``````function s(b,a){o="";k=Array(a).join("*");t=k+b+k;for(i=a;0<i;i--)o+=t.replace(RegExp(".{"+(a-1)+"}(.)","g"),k+"\$1").substr(i-1,b.length)+"\n",t=t.substr(1);return o}
``````

``````> s("four",5)
f***
*o**
**u*
***r
****

> s("evil_company_that_makes_me_shiver",3)
e**l**o**a**_**a**m**e**m**s**v**
*v**_**m**n**t**t**a**s**e**h**e*
**i**c**p**y**h**_**k**_**_**i**r
``````

0

# k [50-20 = 30个字符]

``````{.{@[y#"*";z;:;x z]}[x;c]'=_d*y%#d:<<(-d)?!d:c:#x}
``````

### 说明

1. 输入：x =需要屏蔽的字符串，y =行数
2. 计算字符串中字符c的数量，并创建y个存储桶。
3. 在每个存储桶中放置c个mod字符。
4. 对于每个存储桶，请为该存储桶中没有的其余数字打印“ *”。

### 例

``````{.{@[y#"*";z;:;x z]}[x;c]'=_d*y%#d:<<(-d)?!d:c:#x}["abcdefghijklmnopqrstuvwxyz";4]
``````

### 输出量

``````"ab*d*f***j**********u*w***"
"**c*e*gh**k*****q*s*******"
"********i***mn*****t*v**y*"
"***********l**op*r*****x*z"
``````

0

## JavaScript-139-20 = 119

``````function e(s,c){r=[];for(i=c;i--;)r[i]='';for(i=0;i<s.length*c;i++)x=i%c,n=(x<1?Math.random()*c|0:n),r[x]+=(n!=x?'*':s[(i/c)|0]);return r}
``````

``````console.log(e("evil_company_that_makes_me_shiver", 3));

["**i*_**mp*****h**_ma**********v**",
"*****co**a***t*a******s*me_*hi*e*",
"ev*l******ny_***t***ke*_***s****r"]
``````

``````console.log(e("evil_company_that_makes_me_shiver", 2));

["evil_company_that_makes_me_shiver",
"*********************************"]
``````

0

# 朱莉娅56-20 = 36（经常工作）

``````f(s,n)=[join([rand()<1.9/n?c:"*" for c in s]) for r=1:n]

julia> f("evilcompany!!!",4)
4-element Array{Union(UTF8String,ASCIIString),1}:
"e**l**mp*ny*!*"
"***lco********"
"e*il**m*a*y!*!"
"evil**m*an***!"
``````

0

# F＃-81 80 75

``````let a s n=[for i in 0..n-1->String.mapi(fun j c->[c;'*'].[min((j+i)%n)1])s]
``````

``````a "evil_company_that_makes_me_shiver" 7

e******m******h******e******h****
******o******t******k******s*****
*****c******_******a******_******
****_******y******m******e******r
***l******n******_******m******e*
**i******a******t******_******v**
*v******p******a******s******i***
``````

``````[<EntryPoint>]let m (a:string array)=
let n=System.Int32.Parse a.[1]
for i in 0..n-1 do printfn"%s"(String.mapi(fun j c->[c;'*'].[min((j+i)%n)1])a.[0])
0
``````