Brachylog, (削除) 14 (削除ここまで) 12 bytes
ọtmN2m==tN2ọ
Explanation
ọ Occurrences. Gives a list of [char, count] pairs for the entire input.
tm Map "tail" over this list, giving each character count.
N2m Make sure that each count is at least 2.
= Make sure that all counts are equal.
At this point we're done with the actual code, but we need another copy
of each character (except m). We can just put them after this, as long as
we make sure that they can never cause the predicate to fail.
= Make sure that all counts are equal, again...
t Extract the last count.
N2 Make sure that it's at least 2, again...
ọ Get the digit occurrences in that count, this can't fail.
Alternative 12-byte solution that reuses t
instead of m
:
ọtm==tN2N2ọm
Brachylog, (削除) 14 (削除ここまで) 12 bytes
ọtmN2m==tN2ọ
Explanation
ọ Occurrences. Gives a list of [char, count] pairs for the entire input.
tm Map "tail" over this list, giving each character count.
N2m Make sure that each count is at least 2.
= Make sure that all counts are equal.
At this point we're done with the actual code, but we need another copy
of each character (except m). We can just put them after this, as long as
we make sure that they can never cause the predicate to fail.
= Make sure that all counts are equal, again...
t Extract the last count.
N2 Make sure that it's at least 2, again...
ọ Get the digit occurrences in that count, this can't fail.
Brachylog, (削除) 14 (削除ここまで) 12 bytes
ọtmN2m==tN2ọ
Explanation
ọ Occurrences. Gives a list of [char, count] pairs for the entire input.
tm Map "tail" over this list, giving each character count.
N2m Make sure that each count is at least 2.
= Make sure that all counts are equal.
At this point we're done with the actual code, but we need another copy
of each character (except m). We can just put them after this, as long as
we make sure that they can never cause the predicate to fail.
= Make sure that all counts are equal, again...
t Extract the last count.
N2 Make sure that it's at least 2, again...
ọ Get the digit occurrences in that count, this can't fail.
Alternative 12-byte solution that reuses t
instead of m
:
ọtm==tN2N2ọm
Brachylog, 14(削除) 14 (削除ここまで) 12 bytes
ọtm=hN2N2họtm=ọtmN2m==tN2ọ
Explanation
ọ Occurrences. Gives a list of [char, count] pairs for the entire input.
tm Map "tail" over this list, giving each character count.
=N2m Make sure Requirethat alleach countscount tois beat theleast same2.
h Extract the first character= count.
N2 Make sure it'sthat atall leastcounts 2are equal.
At this point we're done with the actual code, but we need another copy
of each character (except m). We can just put them after this, as long as we make
we make sure that they can never cause the predicate to fail.
N2 = Check that theMake charactersure countthat isall atcounts leastare 2equal, again...
ht GetExtract the character count's firstlast digitcount.
ọ Count theN2 occurrences, givesMake [[d,sure 1]].
tmthat it's Mapat tailleast again2, gives [1]again...
= Makeọ sure all elementsGet arethe equal.digit Thisoccurrences isin alwaysthat truecount, because there's
only one element inthis thecan't listfail.
Brachylog, 14 bytes
ọtm=hN2N2họtm=
Explanation
ọ Occurrences. Gives a list of [char, count] pairs for the entire input.
tm Map "tail" over this list, giving each character count.
= Require all counts to be the same.
h Extract the first character count.
N2 Make sure it's at least 2.
At this point we're done with the actual code, but we need another copy
of each character. We can just put them after this, as long as we make
sure that they can never cause the predicate to fail.
N2 Check that the character count is at least 2, again...
h Get the character count's first digit.
ọ Count the occurrences, gives [[d, 1]].
tm Map tail again, gives [1].
= Make sure all elements are equal. This is always true, because there's
only one element in the list.
Brachylog, (削除) 14 (削除ここまで) 12 bytes
ọtmN2m==tN2ọ
Explanation
ọ Occurrences. Gives a list of [char, count] pairs for the entire input.
tm Map "tail" over this list, giving each character count.
N2m Make sure that each count is at least 2.
= Make sure that all counts are equal.
At this point we're done with the actual code, but we need another copy
of each character (except m). We can just put them after this, as long as we make sure that they can never cause the predicate to fail.
= Make sure that all counts are equal, again...
t Extract the last count.
N2 Make sure that it's at least 2, again...
ọ Get the digit occurrences in that count, this can't fail.
Brachylog, 14 bytes
ọtm=hN2N2họtm=
Explanation
ọ Occurrences. Gives a list of [char, count] pairs for the entire input.
tm Map "tail" over this list, giving each character count.
= Require all counts to be the same.
h Extract the first character count.
N2 Make sure it's at least 2.
At this point we're done with the actual code, but we need another copy
of each character. We can just put them after this, as long as we make
sure that they can never cause the predicate to fail.
N2 Check that the character count is at least 2, again...
h Get the character count's first digit.
ọ Count the occurrences, gives [[d, 1]].
tm Map tail again, gives [1].
= Make sure all elements are equal. This is always true, because there's
only one element in the list.