text:
Anagram Quines (Robbers' Thread)
This is a cops-and-robbers challenge the Cops' Thread can be found here
Your challenge, as robbers is to take outputs from the cops' thread and find anagrams of the output that when run as a program output the original output provided.
The winner will be the person with the most valid cracks on this question.
Rules

You may not crack answers marked as safe with a provided program.

If a cop provides a language that the intended solution is in you must crack it in that particular language, if they choose not to you may crack it in any competing language.

Standard rules for Quines apply.

Cracks must not be perfect Quines. i.e. they must not output their exact source but a reordering of it (the order is provided by the cop).

CLosely related

Unspecified language (CJam), 254 bytes, DJMcMayhem
0000000: 3235 362c 583e 3130 2d5b 445d 2f41 612a  256,X>10-[D]/Aa*
0000010: 3a63 6523 0102 0304 0506 0708 090b 0c0e  :ce#............
0000020: 0f10 1112 1314 1516 1718 191a 1b1c 1d1e  ................
0000030: 1f20 2122 2425 2627 2829 2b2e 3334 3738  . !"$%&'()+.3478
0000040: 393b 3c3d 3f40 4243 4546 4748 494a 4b4c  9;<=?@BCEFGHIJKL
0000050: 4d4e 4f50 5152 5354 5556 5759 5a5c 5e5f  MNOPQRSTUVWYZ\^_
0000060: 6062 6466 6768 696a 6b6c 6d6e 6f70 7172  `bdfghijklmnopqr
0000070: 7374 7576 7778 797a 7b7c 7d7e 7f80 8182  stuvwxyz{|}~....
0000080: 8384 8586 8788 898a 8b8c 8d8e 8f90 9192  ................
0000090: 9394 9596 9798 999a 9b9c 9d9e 9fa0 a1a2  ................
00000a0: a3a4 a5a6 a7a8 a9aa abac adae afb0 b1b2  ................
00000b0: b3b4 b5b6 b7b8 b9ba bbbc bdbe bfc0 c1c2  ................
00000c0: c3c4 c5c6 c7c8 c9ca cbcc cdce cfd0 d1d2  ................
00000d0: d3d4 d5d6 d7d8 d9da dbdc ddde dfe0 e1e2  ................
00000e0: e3e4 e5e6 e7e8 e9ea ebec edee eff0 f1f2  ................
00000f0: f3f4 f5f6 f7f8 f9fa fbfc fdfe ff0a       ..............

Try it online!
How it works
256,                Push the range [0 ... 255].
    X>              Remove the first item (0).
      10-           Remove 10 (0x0a).
         [D]/       Split at occurrences of 13 (0x0d).
             Aa*    Join, separating by 10 (0x0a).
                :c  Cast all integers to character.
                e#  Begins a comment, terminated by the linefeed at the very end.

Brain-Flak, Riley
()((((((()()()){}){}){})()){}{}){({}[()][((((((()()()()()){}){}){})()))]{})}{}((()()()){}()){({}[()][((((((()()()){}){}()){({}[()])}{})()()))]{})}{}((((()()()()){}){}()){}){({}[()][((((((((()()()()()){}){}){}())){}{})()()))]{})}{}

Try it online!
Explanation
This was a bit easier than I had expected.
I wrote 3 separate loops to print each type of brace:
(((((()()()){}){}){})()){}{}){({}[()][((((((()()()()()){}){}){})()))]{})}{}
((()()()){}()){({}[()][((((((()()()){}){}()){({}[()])}{})()()))]{})}{}
((((()()()()){}){}()){}){({}[()][((((((((()()()()()){}){}){}())){}{})()()))]{})}{}

I used standard Mini-Flak technique to avoid using <...> monad and to be honest I never really felt the need to use the <> nilad.
This must have been extremely similar to what Riley did in the first place because when I was done I had an extra () left over. This is not a problem because () is essentially a no-op at the top level so I stuck it at the front of my program.

That's exactly what/how I wrote it. I needed the extra () to get everything to match up. Well done!

Haskell, 107 bytes, Laikoni
main=print$id=<<['|':[d]>>[d|i<-"$$'''',--..:<<<<====>>[[[[]]]]addddddiiiiiimnnprt|||",i==d]|d<-id['$'..]]

Plus a trailing newline.
Try it online! (needs a few seconds to run, because it loops through all unicode characters).
The program has an id (right before ['$'..]) which is not needed for the program logic, but somehow I have to spend the i and d.

The output is no in the same order.

@Laikoni: I misread the challenge. Now it's fixed.

Python, 96 bytes, Agargara
f= 'B7ofx)wdr0o{1{6{{r){1x0sD00qF1{{24}wr2wlo)y))xm2'; print''.join([r+chr(ord(r)-9)for r in f])

Try it online!
Once I noticed that some characters repeated in pairs, it was just a matter of finding a suitable ascii map between characters.

Congratulations! That's exactly how I wrote it.

Pyth, 32 bytes, Rod
J+"J+J=JJ 1-2#pTN%"N #%2J=T-1pJJ

Try it online!
I don't really know Pyth that well, but I started with printing the required output and went from there.
 +"J+J=JJ 1-2#pTN%"N             # Add a '"' to the string in quotes
J                                # Assign result of above step to J
                     #           # Start an infinite loop
                      %2J=T-1    # Loops one iteration, then breaks
                                 # (I have no idea why this works)
                             pJ  # Explicitly print J
                               J # Implicitly print J

CJam, 46 bytes, Business Cat
93]_:c58]99]95]93]e__:c36]95]95]101]101]e_$_:c

Try it online!
93]                                             # Push [93] onto the stack
   _                                            # Copy
    :c                                          # Push ascii char 93 ']'
      58 99 95 93                               # Push these numbers...
        ]  ]  ]  ]                              # Push entire stack as array
                  e__                           # Flatten and copy
                     :c                         # Map ascii values to all elements
                       36]95]95]101]101]        # Same as above
                                        e_      # Flatten
                                          $     # Sort
                                           _    # Copy, implicitly print
                                            :c  # Map ascii values to all elements
                                                # Implicitly print

Octave, 91 bytes, drolex
a=['111111111123666667eeegggkkknnszEEGn};:;:'];
disp(['a=[''',a,'''];',10,[a-10,']);']]);dd

Try it online!
Very similar to the python solution in that it abuses ascii values to print the characters it needs.

Cracked indeed. Well done.


text:
The Imperial Ruler
Given a ruler length in inches and fractions of an inch, and a granularity in fractions of an inch, output the values of all marks on the ruler, starting from 0, in ascending order.
Input ruler length will be a mixed fraction (integer and proper fraction)
Input granularity will be a proper fraction in the form 1/(2ⁿ), where 1 ≤ n ≤ 6.
Output numbers will all be expressed similarly to the input.  For values where the number of inches is a whole number, no fractional part will be expressed.  For values where the number of inches is 0 < n < 1, only the fractional part will be expressed.
If the input granularity is not fine enough to represent the ruler length, then the final number will be the closest representable number below the ruler length.
Examples
Input 1 1/2 would output:
0
1/2
1

Input 2 3/4 1/8 would output:
0
1/8
1/4
3/8
1/2
5/8
3/4
7/8
1
1 1/8
1 1/4
1 3/8
1 1/2
1 5/8
1 3/4
1 7/8
2
2 1/8
2 1/4
2 3/8
2 1/2
2 5/8
2 3/4

Input 2 3/4 1/2 would output:
0
1/2
1
1 1/2
2
2 1/2

Can we take decimals instead of fractions?

@Okx  No - decimals are not allowed.

Can I take input as 11/4 instead of 2 3/4 ?

Could we take input as 2+3/4?

@cleblanc Input ruler length will be a mixed fraction (integer and proper fraction) - No, sorry.

@muddyfish I was intentionally vague about out how fractions are presented.  So yes, this is fine.

I was expecting a Star Wars challenge :(

Pyke, 38 bytes
KQz\/cebj*Bh Fj.DRIIid)ij.Hi'f jRf\/Rs

Try it online!
Not too bad for a language that has literally no fractional support. Explanation later if at all.

Mathematica, 55 53 bytes
Thanks to JungHwan Min for saving 2 bytes.
DeleteCases[{a=Floor@#,#-a},0,1,1]&/@Range[0,+##2,#]&

Takes three numbers as input, the step width, the integer part of the ruler length, the fractional part of the ruler length.
Output is a list of lists with sublists like {1} or {2, 3/4}.

Husk, 21 bytes
:"0"mȯwfI§e⌊%1↑≤Σ⁰¡+³

Try it online!
Have to prepend a 0 string before, cause filtering out zeroes messes with it.
Does anybody know how to run the Ohm answer?

Ohm, 17 bytes
II¢/II/a/#:$_*,;

Explanation:
II/¢II/a/#:$_*,;  ■Main wire
II/¢              ■Evaluate fraction and save to register
    II/           ■Evaluate another fraction
       a/         ■Divide first by second evaluating to the required steps
         #:    ;  ■foreach _ in range(0,steps){
           $_*,   ■  print (register * _)
                  ■}

Sorry, I'm not familiar with Ohm.  Is there an interpreter somewhere (preferably online) I can use to verify this answer?

Please include the byte count in your answer.

Batch, 213 bytes
@echo off
set n=%4
set/an*=%1,n+=%2*%1/%3
for /l %%i in (0,1,%n%)do call:c %%i %1
exit/b
:c
set/ad=%2,i=%1/d,n=%1%%d
if %n%==0 echo %i%&exit/b
set/an/=p=n^&-n,d/=p
if %i% gtr 0 set n=%i% %n%
echo %n%/%d%

Takes 4 numbers as input:

The number of marks per inch i.e. the reciprocal/denominator of the granularity
The numerator of the ruler length
The denominator of the ruler length
(Optional) The whole number of inches of the ruler length

So for the second example the parameters would be 8 3 4 2. Note that for lengths that are an exact number of integers you still need to specify a dummy fraction e.g. 4 0 1 2, or an improper fraction 4 2 1 would also work.

source: Stack Exchange

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

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

sort: votes


text:
5, 2, 16, 3580, What comes next?
Consider the positive integer powers of five in decimal. Here are the first 25, right aligned:
 X                5^X
 1                  5
 2                 25
 3                125
 4                625
 5               3125
 6              15625
 7              78125
 8             390625
 9            1953125
10            9765625
11           48828125
12          244140625
13         1220703125
14         6103515625
15        30517578125
16       152587890625
17       762939453125
18      3814697265625
19     19073486328125
20     95367431640625
21    476837158203125
22   2384185791015625
23  11920928955078125
24  59604644775390625
25 298023223876953125

Notice that the rightmost column of the powers is all 5's. The second column from the right is all 2's. The third column from the right, read from top to bottom, alternates 1, 6, 1, 6, etc. The next column starts 3, 5, 8, 0 and then cycles.
In fact, every column (if we go down far enough) has a cycling sequence of digits whose length is twice that of the previous cycle, except for the initial 5's and 2's cycles.
Calling N the column number, starting with N = 1 at the right, the first few cycles are:
N cycle at column N
1 5
2 2
3 16
4 3580
5 17956240
6 3978175584236200
7 19840377976181556439582242163600
8 4420183983595778219796176036355599756384380402237642416215818000

Challenge
Given a positive integer N, output the decimal digits of the cycle at column N, as described above. For example, the output for N = 4 would be 3580.
The digits may be output as a list such as [3, 5, 8, 0] or in another reasonable format so long as:

The digits are in order as read from top to bottom in the power columns. e.g. 0853 is invalid.
The cycle starts with the top number in its power column. e.g. 5803 is invalid as the 4th column starts with 3 not 5.
Exactly one cycle is output. e.g. 358 or 35803 or 35803580 would all be invalid.

Your code must work for at least N = 1 through 30.
If desired you may assume the columns are 0-indexed instead of 1-indexed. So N = 0 gives 5, N = 1 gives 2, N = 2 gives 16, N = 3 gives 3580, etc.
The shortest code in bytes wins.
Thanks to Downgoat and DJ for challenge support.

The order makes this quite tricky.

The cycle length is always 2^(N-2) except N = 1

Can approximations be used? The output is valid until N=72, which would theoretically print 2.36E+21 digits.

Is this sequence in the OEIS?

@StarWeaver Nope.

Python 2, 62 61 58 bytes
Zero-based. I assume the L suffixes are acceptable.
lambda n:[5**(n*3/7-~i)/2**n%10for i in range(2**n/2or 1)]

Output:
0 [5]
1 [2]
2 [1, 6]
3 [3, 5, 8, 0]
4 [1, 7, 9, 5, 6, 2, 4, 0]
5 [3, 9, 7, 8, 1, 7, 5, 5, 8, 4, 2, 3, 6, 2, 0, 0]
6 [1, 9, 8, 4, 0, 3, 7, 7, 9, 7, 6, 1, 8, 1, 5, 5, 6, 4, 3, 9, 5, 8, 2, 2, 4, 2L, 1L, 6L, 3
L, 6L, 0L, 0L]
7 [4, 4, 2, 0, 1, 8, 3, 9, 8, 3, 5, 9, 5, 7, 7, 8, 2, 1, 9, 7, 9, 6, 1, 7, 6L, 0L, 3L, 6L,
3L, 5L, 5L, 5L, 9L, 9L, 7L, 5L, 6L, 3L, 8L, 4L, 3L, 8L, 0L, 4L, 0L, 2L, 2L, 3L, 7L, 6L, 4L,
 2L, 4L, 1L, 6L, 2L, 1L, 5L, 8L, 1L, 8L, 0L, 0L, 0L]

Previous solution:
lambda n:[5**int(n/.7-~i)/10**n%10for i in range(2**n/2or 1)]
lambda n:[str(5**int(n/.7-~i))[~n]for i in range(2**n/2)]or 5

Explanation:
def f(n):
    r = max(2**n / 2, 1)
    m = int(n/0.7 + 1)
    for i in range(r):
        yield (5**(m+i) / 10**n) % 10

The range(2**n/2) uses the observation that each cycle has length r = 2n-1 except when n = 0, so we just compute the n-th digits for 5m to 5m + r - 1.
The start of the cycle 5m is the first number larger than 10n. Solving 5m ≥ 10n gives m ≥ n / log10 5. Here we approximate log10 5 ≈ 0.7 which will break down when n = 72. We could add more digits to increase the accuracy:
| approximation             | valid until        | penalty   |
|---------------------------|--------------------|-----------|
| .7                        | n = 72             | +0 bytes  |
| .699                      | n = 137            | +2 bytes  |
| .69897                    | n = 9297           | +4 bytes  |
| .698970004                | n = 29384          | +8 bytes  |
| .6989700043               | n = 128326         | +9 bytes  |
| .6989700043360189         | too large to check | +15 bytes |
| import math;math.log10(5) | same as above      | +23 bytes |

The / 10**n % 10 in the loop simply extract the desired digit. Another alternative solution uses string manipulation. I used the trick ~n == -n-1 here to remove 1 byte.
An mentioned in the comment, the expression 5**(m+i) / 10**n can further be simplified this way, which gives the current 58-byte answer.

(The division x/2**n can be done using bitwise right-shift x>>n. Unfortunately, due to Python's operator precedence this does not save any bytes.) The fraction 3/7 can also be improved in similar mannar:
| approximation                   | valid until         | penalty   |
|---------------------------------|---------------------|-----------|
| n*3/7                           | n = 72              | +0 bytes  |
| n*31/72                         | n = 137             | +2 bytes  |
| n*59/137                        | n = 476             | +3 bytes  |
| n*351/815                       | n = 1154            | +4 bytes  |
| n*643/1493                      | n = 10790           | +5 bytes  |
| n*8651/20087                    | n = 49471           | +7 bytes  |
| int(n*.43067655807339306)       | too large to check  | +20 bytes |
| import math;int(n/math.log2(5)) | same as above       | +26 bytes |

(5**(n*3/7-~i)>>n)%10. Because you're taking a power of 5 divided by a (smaller) power of 10, you can reduce the power of 5, and shift right instead. n/.7 - n → n*10/7 - n → n*3/7. In priciple, it's extracting the digits from the smallest power of 5 greater than 2ⁿ (with 3/7 an approximation for 1/log₂(5)). Also, using range(2**n/2or 1) instead will give you consistent output.

@primo Thanks, updated. (x>>n)%10 gives no improvement over x/2**n%10 so I don't use bit shift for now, as maybe there is a way to factor out the common 2**n.

interesting idea factoring out 2**n, seems slightly longer though: int(5**(-~i-n*log(2,5)%1))%10 (I've simplified int(n*log(2,5))-n*log(2,5) as -(n*log(2,5)%1)).

@primo Interesting, but what I mean is the 2**n here and the range argument.

dc, 72 bytes
[3Q]sq2?dsa^1+2/dsusk[Ola^/O%plk1-dsk1>q]sp1[d5r^dOla^<psz1+d4/lu>t]dstx

0-based indexing.
This uses exact integer arithmetic -- no logarithm approximations. It will work up to the memory capacity of the computer.
Try the dc program online!

The dc code can be turned into a Bash solution:
Bash + GNU utilities, 96 77 75 bytes
u=$[(2**$1+1)/2]
dc -e "[O$1^/O%p]sp1[d5r^dO$1^<psz1+d4/$u>t]dstx"|head -$u

Try the Bash version online!

Mathematica, 66 60 52 bytes
Floor@Mod[5^Floor[Range@Max[2^#/2,1]+#/.7]/10^#,10]&

Anonymous function, 0-indexed. Uses approximation of log5(10) (≈ 0.7)
How it works?
Range@Max[2^#/2,1]

Take larger of 2^(input)/2 and 1. Generate {1..that number}
...+#/.7

Add input/.7
5^Floor[...]/10^#

Raise 5 to the power of the result (generating powers of 5), divide by 10^input (getting rid of digits to the right of the desired column)
Mod[ ...,10]

Apply modulo 10, taking the one's digit (the desired column).
Exact version, 58 bytes
Floor@Mod[5^Floor[Range@Max[2^#/2,1]+#/5~Log~10]/10^#,10]&

JavaScript (ES7), 78 76 bytes
f=(N,z=5,s,X=2**N,q=z/10**N|0)=>s|q?X>0?q+f(N,z*5%10**-~N,1,X-2):"":f(N,z*5)

0-indexed, i.e. f(0) gives 2.
Test snippet

f=(N,z=5,s,X=1<<N,q=z/Math.pow(10,N)|0)=>s|q?X>0?q+f(N,z*5%Math.pow(10,-~N),1,X-2):"":f(N,z*5)

for (let i = 0; i < 10; i++) console.log(`f(${i}):`, f(i));

The snippet uses Math.pow instead of ** for cross-browser compatability.

CJam, 35
5ri(:N.7/i)#2N(#mo{_AN#/o5*AN)#%}*;

Try it online
It is space-efficient and not exceedingly slow, took several minutes for input 30 on my computer (using the java interpreter).

Jelly, 26 21 bytes
-2 bytes using kennytm's 0.7 approximation idea
2*HĊR+÷.7$Ḟ*@5:⁵*⁸¤%⁵

Try it online! (times out for n>15)
Returns a list of integers, the digits.
Zero based. Theoretically works for n<=72 (replace .7 with 5l⁵¤, to get floating point accuracy).
How?
2*HĊR+÷.7$Ḟ*@5:⁵*⁸¤%⁵ - Main link: n
2*                    - 2 raised to the power of n
  H                   - halved: 2 raised to the power of n-1
   Ċ                  - ceiling: adjust 2**-1 = 0.5 up to 1 for the n=0 edge case
    R                 - range: [1,2,...,ceiling(2**(n-1))] - has length of the period
         $            - last two links as a monad:
      ÷.7             -     divide by 0.7 (approximation of log(5, 10), valid up to n=72)
     +                - add (vectorises)
          Ḟ           - floor (vectorises)
             5        - 5
           *@         - exponentiate (vectorises) with reversed @arguments
                  ¤   - nilad followed by link(s) as a nilad
               ⁵      -     10
                 ⁸    -     left argument, n
                *     -     exponentiate: 10 raised to the power of n
              :       - integer division: strips off last n digits
                   %⁵ - mod 10: extracts the last digit

Locally: the working set memory for n=17 climbed to around 750MB then spiked to around 1GB; for n=18 it slowly reached 2.5GB then spiked to around 5GB.

Perl 6, 52 bytes
->\n{(map {.comb[*-n]//|()},(5 X**1..*))[^(2**n/4)]}

Works for arbitrarily high inputs, given sufficient memory (i.e. no logarithm approximation).
Returns a list of digits.
Try it online!
How it works
->\n{                                              }  # A lambda with argument n.
                            (5 X**1..*)               # The sequence 5, 25, 125, 625...
      map {               },                          # Transform each element as such:
           .comb[*-n]                                 #   Extract the n'th last digit,
                     //|()                            #   or skip it if that doesn't exist.
     (                                 )[^(2**n/4)]   # Return the first 2^(n-2) elements.

The "element skipping" part works like this:

Indexing a list at an illegal index returns a Failure, which counts as an "undefined" value.
// is the "defined or" operator.
|() returns an empty Slip, which dissolves into the outer list as 0 elements, essentially making sure that the current element is skipped.

The edge-case n=1 works out fine, because 2**n/4 becomes 0.5, and ^(0.5) means 0 ..^ 0.5 a.k.a. "integers between 0 (inclusive) and 0.5 (not inclusive)", i.e. a list with the single element 0.

J, 50 bytes
(2^0>.2-~]){.' '-.~-{"1[:([:":[:|:[:,:5^[:>:i.)2^]

Note: must pass in extended number
Usage:
   q =: (2^0>.2-~]){.' '-.~-{"1[:([:":[:|:[:,:5^[:>:i.)2^]
   q 1x
5
   q 2x
2
   q 4x
3580

why the downvote?

Haskell, 73 bytes
f 0="5"
f n=take(2^(n-1))[reverse x!!n|x<-show<$>iterate(*5)1,length x>n]

Try it online! Uses 0-indexing.
Explanation:
f 0="5"              -- if the input is 0, return "5"
f n=                 -- otherwise for input n
  take(2^(n-1))      -- return the first 2^(n-1) elements of the list
    [reverse x!!n    -- of the nth column of x
      |x<-show<$>    --    where x is the string representation
        iterate(*5)1 --    of the elements of the infinite list [5,25,125,...]
      ,length x>n    -- if x has at least n+1 columns
    ]                -- this yields a list of characters, which is equivalent to a string

Batch, 294 bytes
@echo off
if %1==1 echo 5
set/a"l=1<<%1-2,x=0,s=1
set t=
for /l %%i in (2,1,%1)do call set t=%%t%%x
:l
if %l%==0 exit/b
set t=%s%%t%
set s=
set c=
:d
set/ac+=%t:~,1%*5,r=c%%10,c/=10
set s=%s%%r%
set t=%t:~1%
if "%t%"=="" echo %r%&set/al-=1&goto l
if %c%%t:~,1%==0x goto l
goto d

Outputs each digit on its own line. Works by calculating the powers of 5 longhand, but only works up to N=33 due to using 32-bit integers to keep count of how many digits to print. s contains the (reversed) last N digits of the current power of 5, while t contains xs used as padding, although the x=0 makes them evaluate as zero when the next power is calculated. Example for N=4:
s   t
1   xxx (initial values before the first power of 5 is calculated)
5   xxx
52  xx
521 x
526 x
5213    (print 3)
5265    (print 5)
5218    (print 8)
5260    (print 0)

JavaScript (ES6), 73 bytes
1-indexed. Slightly shorter than the ES7 answer, but fails 3 steps earlier (at N=13).
n=>(g=x=>k>>n?'':(s=''+x*5%1e15)[n-1]?s.substr(-n,1)+g(s,k+=4):g(s))(k=1)

Demo

let f =

n=>(g=x=>k>>n?'':(s=''+x*5%1e15)[n-1]?s.substr(-n,1)+g(s,k+=4):g(s))(k=1)

console.log(f(1))
console.log(f(2))
console.log(f(3))
console.log(f(4))
console.log(f(5))
console.log(f(6))
console.log(f(7))
console.log(f(8))

PHP>=7.1, 104 Bytes
for($s=1;$i++<2**(-1+$a=$argn);)~($s=bcmul($s,5))[-$a]?$g.=$s[-$a]:0;echo substr($g,0,max(2**($a-2),1));

PHP Sandbox Online

Husk, 15 bytes
!z↑+ḋ3İ2Tmod↔İ5

Try it online! or Verify first 10 values
Explanation
!z↑+ḋ3İ2Tmod↔İ5
             İ5 list of powers of 5
         mod↔   reverse each and convert to digits
        T       transpose to get repeating columns
 z↑             zip with take using:
   +ḋ3İ2        powers of 2 with [1,1] added
!               return the nth element

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


text:
Write self-validating code
Write code that takes a string as input, and outputs a truthy or falsey value depending on whether or not the string follows these rules:
If you stack each character on top of each other, convert to binary and sums each column, then all the sums should be identical. You may assume the input string contains only printable ASCII-characters (code points 32 - 126).
As an example:
The input O5vy_+~ should return a truthy value, since its binary representation is:
1001111  | O
0110101  | 5
1110110  | v
1111001  | y
1011111  | _
0101011  | +
1111110  | ~
-------
5555555  <- Sum of bits in each column. Should give a truthy value.

The input PPCG should return a falsey value, since its binary representation is:
1010000  | P
1010000  | P
1000011  | C
1000111  | G
-------
4020122  <- Should give a falsey value

The twist is: Your code should return a truthy value if it's used as input to your function / program. I.e. the code must adhere to the same rules as above (your code can contain characters that are not ASCII 32-126).
Your program/function only needs to handle printable ASCII as input. If your code contains something else, 8 bit, 16 bit encoding, Unicode, a custom made character set (or something else), then the binary representation of it should adhere to the same rules, but your code doesn't need to handle it as input.
This is code-golf, so standard rules apply.

How long will the input string be? Can we assume the sum will always be 7 digits long?

Also, if our program uses characters other than ASCII characters, what happens?

I guess that "then the binary representation of it should adhere to the same rules" should explicitly exclude the clause "only needs to handle printable ASCII as input" (otherwise one could write code with just one byte that maps to non-printable ASCII).

@Okx you may assume the input string is less than 1kB. The input will only be printable ASCII that can be represented using 7 bits, so yes: There will always be 7 integer (not necessarily digits) sums.

@JonathanAllan, yes. The code obviously doesn't have the only printable ascii limitation. I'll clarify.

@StewieGriffin That's not a very good clarification. If I have a non-ASCII answer, and you try and input the program into the program, and it doesn't work because it only supports ASCII, what happens?

@Okx you don't have to support non-ASCII input. So if your program contains non-ASCII characters then you must verify that it's correct "manually", using something else than your program.

@StewieGriffin How would you do that?

It should be fairly simple. Convert your code to binary using your specific encoding and check it the same way as you would with ascii characters.

@StewieGriffin: So for ASCII input, you always check the lowest 7 bits (even if all codepoints in the input happen to have fewer significant bits than that)? How many bits would one have to check to validate UTF8 source code?

@smls, you may skip "leading" significant bits. So, if all codepoints are less than 63 then you can check only 6 bits. Same with UTF8. You can not skip bits the other way, i.e. you can't skip the first bit even if all codepoints are even.

@Okx, just wondering: Is it still unclear (if so, what)? I'll try to clarify if it is. :)

Would a correct non-8bit reaction be to simply return true?

JavaScript (ES6), 123 122 120 110 bytes
S=>[...S].map(S=>R.map((_GSSSSSSVWWW,V)=>R[V]-=S.charCodeAt()>>V&1),R=[_=3^3,_,_,_,_,_,_])&&!R.some(S=>S^R[_])

Below is a hexdump with bit sums.
Addr. | Dump                                            | #6 #5 #4 #3 #2 #1 #0
------+-------------------------------------------------+---------------------
00-0F | 53 3D 3E 5B 2E 2E 2E 53 5D 2E 6D 61 70 28 53 3D |  8 11  9 11  9  9  9
10-1F | 3E 52 2E 6D 61 70 28 28 5F 47 53 53 53 53 53 53 | 20 18 19 17 14 20 19
20-2F | 56 57 57 57 2C 56 29 3D 3E 52 5B 56 5D 2D 3D 53 | 30 24 32 25 26 30 29
30-3F | 2E 63 68 61 72 43 6F 64 65 41 74 28 29 3E 3E 56 | 41 37 37 32 34 38 36
40-4F | 26 31 29 2C 52 3D 5B 5F 3D 33 5E 33 2C 5F 2C 5F | 47 47 48 43 44 47 46
50-5F | 2C 5F 2C 5F 2C 5F 2C 5F 5D 29 26 26 21 52 2E 73 | 54 57 55 54 56 56 54
60-6D | 6F 6D 65 28 53 3D 3E 53 5E 52 5B 5F 5D 29       | 64 64 64 64 64 64 64

Demo

let f =

S=>[...S].map(S=>R.map((_GSSSSSSVWWW,V)=>R[V]-=S.charCodeAt()>>V&1),R=[_=3^3,_,_,_,_,_,_])&&!R.some(S=>S^R[_])

console.log(f("O5vy_+~"))
console.log(f("Hello World!"))
console.log(f(`S=>[...S].map(S=>R.map((_GSSSSSSVWWW,V)=>R[V]-=S.charCodeAt()>>V&1),R=[_=3^3,_,_,_,_,_,_])&&!R.some(S=>S^R[_])`))

MATL, 10 9 bytes
BXs&=?I&]

Input is a string enclosed with single quotes (if the input contains single qoutes, escape them by duplicating).
Output is 3 as truthy and nothing (empty output) as falsy.
Try it online!
The code in binary is as follows:
B     1 0 0 0 0 1 0
X     1 0 1 1 0 0 0
s     1 1 1 0 0 1 1
&     0 1 0 0 1 1 0
=     0 1 1 1 1 0 1
?     0 1 1 1 1 1 1
I     1 0 0 1 0 0 1
&     0 1 0 0 1 1 0
]     1 0 1 1 1 0 1

Sum   5 5 5 5 5 5 5

Explanation
B      % Input string (implicit). Convert each char to its ASCII code, and
       % then to binary. This gives a binary matrix, with each char of the
       % input corresponding to a row
Xs     % Sum of each column. Gives a row vector
&=     % All pairwise equality comparisons
?      % If all are true
  I    %    Push 3
  &    %    Specify that the next function, namely implicit display, will
       %    take one input, instead of the whole stack which is the default
]      % End
       % Display (implicit)

Jelly, 11 10 bytes
OBUSE&889.

Try It Online! Or see tests and self-input (the code is all printable ASCII, which have the same values in Jelly's code page, as seen below).
Char -> Hex -> Decimal -> Binary
O       0x4F   79         0b1001111
B       0x42   66         0b1000010
U       0x55   85         0b1010101
S       0x53   83         0b1010011
E       0x45   69         0b1000101
&       0x26   38         0b0100110
8       0x38   56         0b0111000
8       0x38   56         0b0111000
9       0x39   57         0b0111001
.       0x2E   46         0b0101110
                            -------
                            5555555

How?
OBUSE&889. - Main link: string
O          - cast to ordinals
 B         - convert to binary
  U        - upend (reverses each to prepare for vectorised sum)
   S       - sum (vectorises)
    E      - all equal? (yields 1 if all bit-sums are equal and 0 if not)
      889. - 889.0
     &     - bitwise and (1 & 889.0 is 1; and 0 & 889.0 is 0)

Your code looks much like Dennis's.

Yeah, I saw after.

Jelly, 11 10 bytes
OBUSE$*8?8

Uses no no-ops or comments.
Try it online!
Binary breakdown
O  1 0 0 1 1 1 1
B  1 0 0 0 0 1 0
U  1 0 1 0 1 0 1
S  1 0 1 0 0 1 1
E  1 0 0 0 1 0 1
$  0 1 0 0 1 0 0
*  0 1 0 1 0 1 0
8  0 1 1 1 0 0 0
?  0 1 1 1 1 1 1
8  0 1 1 1 0 0 0
————————————————
∑  5 5 5 5 5 5 5

How it works
OBUSE$*8?8  Main link. Argument: s (string)

O           Ordinal; map all characters in s to their code points.
 B          Binary; convert each code point to base 2.
  U         Upend; reverse each binary array to right-align the digits.
       8?   If 8 is non-zero (it is):
   SE$          Sum the corresponding digits and test the the sums for equality.
            Else (never happens):
      *  8      Raise all binary digits to the eighth power.

Is Jelly TC using only printable ASCII?

I don't think so.

I like that this code starts with OBUSE because it sounds like ABUSE.

Mathematica, 88 bytes
Total@IntegerDigits[ToCharacterCode@#,2,7]~MatchQ~{"?";a_ ..}&

Contains many unprintable characters between the quotes. Has 49 of each bit.
Here's the hexdump:
0000-0010:  54 6f 74 61-6c 40 49 6e-74 65 67 65-72 44 69 67  Total@In tegerDig
0000-0020:  69 74 73 5b-54 6f 43 68-61 72 61 63-74 65 72 43  its[ToCh aracterC
0000-0030:  6f 64 65 40-23 2c 32 2c-37 5d 7e 4d-61 74 63 68  ode@#,2, 7]~Match
0000-0040:  51 7e 7b 22-3f 1f 1f 1f-1f 1f 1f 1f-1f 1f 1f 1f  Q~{"?... ........
0000-0050:  1f 1f 1f 1f-1f 1a 1a 1a-1a 18 18 18-18 18 10 22  ........ ......."
0000-0058:  3b 61 5f 20-2e 2e 7d 26                          ;a_...}&

Octave, 53 52 bytes
Making a complete rewrite helped me golf the code 5 bytes, but I had to add more no-ops, making it a net-save of only 1 byte.
@(_)~diff(sum(de2bi(+_)))%RRPPPVVVW?????????________

I can't add a TIO-link, since none of the online interpreters have implemented the communication toolbox necessary for de2bi. Changing it to dec2bin instead would cost 4 bytes (2 for working code, and two no-ops).
I found no way to avoid any of the 27 no-ops. All function names and parentheses are between either below 64, or higher than 96, meaning all "necessary" characters have a 1 in the 6th position (from the right, 2^5). I had a solution with only 23 no-ops, but the code itself was longer. The actual code is 25 bytes, and has the following column sum when counting the bits of the binary equivalent:
15   22    6   15   10    9   13

There are 22 bits in the 6th position from the right (2^5), and only 6 bits in the 4th position from the right (2^3). That means, we have to add at least 16 bytes, to get the 6 up to 22. Now, the comment character % adds a bit to the 6th position, increasing it to 23. All printable ASCII-characters needs at least one of the two top bits to be 1. Therefore, adding 17 bytes will give us at least 27 bits in each of the two "top spots" (2^6 and 2^5). Now, we have 27 bits in the top two spots, and 22 in the rest. In order to get to an equilibrium, we have to add 10 bytes, to get to an even 32 bits in each position.
An explanation of the new code (52 bytes):
@(_)~diff(sum(de2bi(+_)))
@(_)      % An anonymous function that take a variable _ as input
          % We use underscore, instead of a character, since it has the
          % most suitable binary represetation
              de2bi(+_)    % Convert the input string to a binary matrix
          sum(de2bi(+_))   % Take the sum of each column
     diff(sum(de2bi(+_)))  % And calculate the difference between each sum
    ~diff(sum(de2bi(+_)))  % Negate the result, meaning 0 becomes true,
                           % and everything else becomes false

A vector containing only 1s (true) is evaluated to true in Octave, and a vector containing at least one zero is evaluated to false in Octave.
An explanation of the old code (53 bytes):
@(_)!((_=sum(de2bi(+_)))-_(1))%RRRFVVVVVVVVV_____????

@(_)      % An anonymous function that take a variable _ as input
          % We use underscore, instead of a character, since it has the
          % most suitable binary represetation
    !     % Negate the result, meaning 0 becomes true, and everything else becomes false
        de2bi(+_)         % Convert the input string to a binary matrix
    sum(de2bi(+_))        % Take the sum of each column
 (_=sum(de2bi(+_)))       % Assign the result to a new variable, also called _
                          % It's not a problem that we use the same variable name, due
                          % to the order of evaluation
((_=sum(de2bi(+_)))-_(1)) % Subtract the first element of the new variable _
                          % If all elements of the new variable _ are identical, then this
                          % should give us a vector containing only zeros,
                          % otherwise, at least one element should be non-zero
!((_=sum(de2bi(+_)))-_(1))  % And finally, we negate this.

A vector containing only 1s (true) is evaluated to true in Octave, and a vector containing at least one zero is evaluated to false in Octave.

JavaScript (ES6), 139 111 107 bytes

f=
S=>![...""+1E6].some((____________ABQWWWWWWWWW,P)=>P*=R^(R^=R,[...S].map(Q=>R+=Q.charCodeAt()>>P&1),R),R=0)
<textarea oninput=o.textContent=f(this.value) style=width:100% rows=10>S=>![...""+1E6].some((____________ABQWWWWWWWWW,P)=>P*=R^(R^=R,[...S].map(Q=>R+=Q.charCodeAt()>>P&1),R),R=0)</textarea><div id=o>true

Contains 81 63 61 of each bit.

Scala, 149 bytes
_.map(C=>("0"*7++(BigInt(C)toString 2))takeRight 7 map(_-48)).transpose.map(_.sum).toSet.size==1//______________________________

Usage:
val f:(String=>Any)=_.map(C=>("0"*7++(BigInt(C)toString 2))takeRight 7 map(_-48)).transpose.map(_.sum).toSet.size==1//______________________________
println(f("string here")

Hexdump:
00000000  5f 2e 6d 61 70 28 43 3d  3e 28 22 30 22 2a 37 2b  |_.map(C=>("0"*7+|
00000010  2b 28 42 69 67 49 6e 74  28 43 29 74 6f 53 74 72  |+(BigInt(C)toStr|
00000020  69 6e 67 20 32 29 29 74  61 6b 65 52 69 67 68 74  |ing 2))takeRight|
00000030  20 37 20 6d 61 70 28 5f  2d 34 38 29 29 2e 74 72  | 7 map(_-48)).tr|
00000040  61 6e 73 70 6f 73 65 2e  6d 61 70 28 5f 2e 73 75  |anspose.map(_.su|
00000050  6d 29 2e 74 6f 53 65 74  2e 73 69 7a 65 3d 3d 31  |m).toSet.size==1|
00000060  2f 2f 5f 5f 5f 5f 5f 5f  5f 5f 5f 5f 5f 5f 5f 5f  |//______________|
00000070  5f 5f 5f 5f 5f 5f 5f 5f  5f 5f 5f 5f 5f 5f 5f 5f  |________________|
00000080  1f 1f 1f 1f 1e 1e 1e 1e  16 16 16 16 16 12 12 10  |................|
00000090  10 10 10 10 10                                    |.....|

Ungolfed:
string =>
  string.map(char =>
    (
      "0" * 7 ++ BigInt(char).toString(2)
    ).takeRight(7).map(n=>n-48)
  ).transpose
  .map(bits=>bits.sum)
  .toSet
  .size == 1
  //______________________________

Explanation:
string =>                      //create an anonymous function with a parameter string
  string.map(char =>           //map each char in the string to
    (
      "0" * 7                  //a string of 7 zeroes
      ++                       //concatenated with
      BigInt(char).toString(2) //the ascii value as a binary string
    ).takeRight(7)             //the last 7 items from this sequence
    .map(n=>n-48)              //where each digit is mapped to its numerical value
  ).transpose                  //transpose, so the colums become rows and vice-versa
  .map(bits=>bits.sum)         //maps the bits in each column to their sum
  .toSet                       //and convert the sequence of sums to a set
  .size == 1                   //which has 1 element of the sums are the same
  //______________________________

J, 45 bytes
[:(*/@:={.)[:+/2 #.inv 3 u:]NB.____UUUUUUUUDD

Try it online! Includes test cases for most submissions submitted, along with the source code.

PHP, 95 93 91 bytes
I am so happy that PHP function names are case insensitive!
FOR(ZZSSSSQ__*;$W=ORD($argn[$T++]);)FOR($V=7;$V--;)$R[$V]+=$W>>$V&1;PRINT MIN($R)==MAX($R);

where the * must be replaced with ASCII 151 (0x97). (PHP would complain about any control character in the code - apart from \r and \n, but I need something with bit 4 set, so I added 128.)
+1 byte for pure printable ASCII: Use _7 instead.
Run with echo '<input>' | php -nR '<code>' or test it online. Output is 1 for truthy, empty for falsy.

Haskell, 118 bytes
_R _S=mod _S 2:_R(div _S 2)
_Z _S|_V:_W<-take 7.foldl1(zipWith(+))$_R.fromEnum<$>_S=all(==_V)_W
--________

Try it online! Usage: _Z "some string" returns either True or False.
There are some unprintable chars in the comment on the last line, so here is a string of the program using escaped chars:
"_R _S=mod _S 2:_R(div _S 2)\n_Z _S|_V:_W<-take 7.foldl1(zipWith(+))$_R.fromEnum<$>_S=all(==_V)_W\n--___\US\US\US\ETB\DC3\DC3\DC3\DC3\DC3\DC3\DC2\DC2_____"

Each bit occurs 68 times.

The shortest code I came up with was 82 bytes:
b n=mod n 2:b(div n 2)
(all=<<(==).head).take 7.foldl1(zipWith(+)).map(b.fromEnum)

However the sums of the bits for this code are [33,28,41,48,20,79,46], so 79 - 20 = 59 no-ops plus 2 bytes for starting a comment would additionally be needed, totalling in 143 bytes.
While rearranging the program I found that using upper case letters as variable names helps to level the sums because they don't have the bit in the 6th position set. Because Haskell does not allow variable names to start with an upper case letter they need to be prepended with  _, which also does not set the 6th bit.
In doing so I ended up with the above solution which has 97 bytes before adding the no-ops and the bist sum to [50,47,56,56,48,68,60], so (68 - 47) = 21, so only 21 bytes need to be added in the comment.

Python 2, 117 bytes
All "spaces" are tabs to reduce number of 0x20 bits.
def Y(S):
    O=map(sorted,zip(*['{:07b}'.format(ord(W))for   W   in  S]))
    return  O[1:]==O[:-1]#V_____________

Contains 66 of each bit. (There is no '%07b' as explained in this issue.)
Hex dump:
00000000: 64 65 66 09 59 28 53 29 3a 0a 09 4f 3d 6d 61 70  def.Y(S):..O=map
00000010: 28 73 6f 72 74 65 64 2c 7a 69 70 28 2a 5b 27 7b  (sorted,zip(*['{
00000020: 3a 30 37 62 7d 27 2e 66 6f 72 6d 61 74 28 6f 72  :07b}'.format(or
00000030: 64 28 57 29 29 66 6f 72 09 57 09 69 6e 09 53 5d  d(W))for.W.in.S]
00000040: 29 29 0a 09 72 65 74 75 72 6e 09 4f 5b 31 3a 5d  ))..return.O[1:]
00000050: 3d 3d 4f 5b 3a 2d 31 5d 23 56 5f 5f 5f 5f 5f 5f  ==O[:-1]#V______
00000060: 5f 5f 5f 5f 5f 5f 5f 16 16 16 16 16 16 16 16 16  _______.........
00000070: 16 16 14 14 10                                   .....

If you read the description of the bug report... "resolution: not a bug".