# Let's get the gang back together! [closed]

A narcissist program is a program that only accepts its own source code. A bigotous program is a program that only accepts the source code of programs semantically equivalent to itself. A gang member is somewhere in between.

In particular, we will define a gang as set of programs G, which may or may not be in the same programming language, such that each program, when executed, will only accept members of its gang, and reject everything else (since they all do the same thing, this means that are semantically equivalent). A gang member is a program that is part of a gang, and the set of programs that it accepts is its gang.

So, a narcissist program is a gang of size 1, and a class of bigots is a maximally sized gang (every equivalent program gets to be part of the gang).

Your job is to create a gang of programs. It must be of size at least 2, and can have programs in different languages (you can even count the same program multiple times if it's a polyglot).

Your score is (average length of gang member)/(# of unique programming languages), which you are trying to minimize (so you are rewarded for using different languages). It is considered cheating to use built in language features that allow a program to access its own code.

Note: We'll define acceptance v.s. rejection via https://codegolf.meta.stackexchange.com/a/12685/16842 or https://codegolf.meta.stackexchange.com/a/12684/16842, your choice.

## closed as unclear what you're asking by Mego♦, Timtech, ETHproductions, R. Kap, mbomb007Jun 2 '17 at 2:43

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• What does "accept" mean? Can acceptance and rejection be the output of two different values? – L3viathan Jun 1 '17 at 20:57
• Full programs only, or are functions allowed? – Stephen Jun 1 '17 at 20:58
• @L3viathan I think using this criteria would be best. – PyRulez Jun 1 '17 at 22:13
• @StephenS functions are fine – PyRulez Jun 1 '17 at 22:13
• IMHO, you should explicitly define exactly what "accept"/"reject" mean in the question; it's unclear as it currently stands. – ETHproductions Jun 1 '17 at 23:44

# 0 points (average length 0 bytes, 2 unique language)

I'm assuming we can define acceptance and rejection as the output of two different values.

The gang size is 2 (the languages are 05AB1E and 2sable), and the program is the empty program.

For some reason, both an empty 05AB1E program and an empty 2sable program appear to outputs 2 (plus a newline in the case of 2sable) when the input is not empty (i.e. a different program; rejection). They output nothing if there is no input (i.e. the same program; acceptance).

Since I "can even count the same program multiple times if its a polygot", these are two programs.

(I know neither 05AB1E nor 2sable at all and just tried golfing languages in TIO until I found some that seemed to work, so this answer might be wrong if they output something else for some specific inputs.)

• I'm assuming OP will edit in a restriction of "no empty programs" - it is quine after all – Stephen Jun 1 '17 at 21:13
• @totallyhuman It's not clear to me whether that refers to the gang size or the program size. – L3viathan Jun 1 '17 at 21:13
• Clever abuse of the rules... – Neil A. Jun 1 '17 at 21:37
• @StephenS I think its already implied due to codegolf.meta.stackexchange.com/a/5337/16842. – PyRulez Jun 1 '17 at 22:18
• The empty Charcoal program outputs Parsing failed whether or not the input is empty—it does not get as far as reading the input. – Anders Kaseorg Jun 1 '17 at 22:20

# 140.75 points (average length 281.5 bytes, 2 unique languages)

These programs use cryptographic hashing to identify the gang members, and the first line of each program is identical and encodes the hash of the remainder of each program. Each program then compares the first line to the given list and the hash of the remainder, and returns true/True if it's accepted and false/False if it's rejected.

JavaScript (Node.js), 338 bytes

x=["69fa7652b24a3aa2a56122db2f3ce27395a3be0a6e6eed00b01592b9","604e0bb526a9af96f90a964c3849be96862bb3d31b9fcfbc83d6c7aa"]
c=[]
process.stdin.on('data',d=>c.push(d)).on('end',_=>console.log((d=Buffer.concat(c)).slice(0,121)=='x='+JSON.stringify(x)&&x.some(y=>y==require('crypto').createHash('sha224').update(d.slice(121)).digest('hex'))));


Python 2, 225 bytes

x=["69fa7652b24a3aa2a56122db2f3ce27395a3be0a6e6eed00b01592b9","604e0bb526a9af96f90a964c3849be96862bb3d31b9fcfbc83d6c7aa"]
import hashlib,sys,json
I=sys.stdin

• What about hash collisions? – PyRulez Jun 2 '17 at 19:26

# ∞ points (Average length ∞, 1 unique language)

I might not win the challenge, but I sure have the biggest gang. (Watch out!)

main=interact$\x->if length(lines x)==1&&take 279x==quine q++"--"then"Yarr!"else"It's one of them PyRulez guys!";quine s=s++show s;q="main=interact$ \\x->if length(lines x)==1&&take 279x==quine q++\"--\"then\"Yarr!\"else\"It's one of them PyRulez guys!\";quine s=s++show s;q="--


The language is Haskell. You can keep adding any letter to the end of the program except newlines. Outputs Yarr! for gang members and It's one of them PyRulez guys! for everything else.

# 141.9 points (Average length 141.9 bytes, 1 unique language, 255 gang members)

f x=elem '\n'x||take 141x/=k q++"--"||length x>142;k s=s++show s;q="f x=elem '\\n'x||take 141x/=k q++\"--\"||length x>142;k s=s++show s;q="--

• +1 for having the worst possible entry. (I was wondering whether I needed to put in a rule about infinitely large gangs, but then I realized I didn't need to.) – PyRulez Jun 1 '17 at 22:31
• Also, you can decrease your score substantially if you remove some of the longer gang members. – PyRulez Jun 1 '17 at 22:47

## 0 points (Average length 24 bytes, ∞ unique languages)

This is noncompeting since the MetaGolfScript family is banned, but I thought it would be fun to post it anyways.

The languages are MetaGolfScript-N, for every natural number N. There is one program in each language, which all have the following source code:

{s ":p:s;p" + =}:p:s;p

• The real question is which infinitely large gang would win in a gang fight, mine or the @BlackCap gang. – PyRulez Jun 1 '17 at 23:47