Remove every N-th N
awk, 10 bytes
Input is expected on STDIN, one number per line.
++a[$1]%$1
Explanation
Keeps a counter for each number in an associative array, prints only if the counter value modulo n
is not zero. Printing is implicit. Long version:
++a[$1]%$1{print $0}
Pyth, 18 15 14 10 9 bytes
f%/aYTTTQ
I think this is the first code I've written that has five consecutive variable references in nine bytes.
I wish the array manipulation solution (u.DG%HgxHGH{QQ
, 14 bytes) weren't so long.
f%/aYTTTQ Implicit: Q=input
lambda T:
Y Variable: starts as empty list.
a T Append T to Y. Mutates Y.
/ T Number of elts of Y that equal T.
% T Modulo by T
f Q Filter that lambda over Q.
Try it here.
Jelly, 10 8 bytes
=;\S€%af
Thanks to @Sp3000 for golfing off 2 bytes!
Try it online!
How it works
=;\S€%af Main link. Input: A (list)
;\ Compute the cumulative concatenations of the elements of A, i.e., the
list of A's prefixes.
= Compare the elements of the nth prefix with the nth element of A.
S€ Compute the sum of the resulting arrays.
% Take the nth sum modulo the nth element of A.
a Logical AND; replace the nth remainder with the nth element of A
if the remainder is non-zero.
f Filter; remove the zeroes (which do not occur in A) from the result.