Generate a password
$begingroup$
It is very hard to remember my password, so I came up with a way to generate a password.
The way I generate my password is from a word or a sentence, following these steps:
Start from left to right
Find the count of each letter
Put letter with its count in an order
Letters with higher repetition will be in the end
Letters with the same repetition will be ordered alphabetically
Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)
Group letters ignoring case. In the output, use the case of the last occurrence in the input
Example:
Input: Kitkat Tango
(2k / 1i / 3T / 2a / 1n / 1g / 1o)
Output: 1g1i1n1o2a2k3T
Another example:
Input: Database Partitions Task
(1D / 5a / 4T / 1b / 3s / 1e / 1P / 1r / 2i / 1o / 1n / 3s / 1k)
Output: 1b1D1e1k1n1o1P1r2i3s4T5a
Note: the letters with 1 repeat are in the beginning ordered alphabetically
then the letters with more reps
This is code-golf, the shortest code wins.
code-golf word-puzzle
$endgroup$
|
show 4 more comments
$begingroup$
It is very hard to remember my password, so I came up with a way to generate a password.
The way I generate my password is from a word or a sentence, following these steps:
Start from left to right
Find the count of each letter
Put letter with its count in an order
Letters with higher repetition will be in the end
Letters with the same repetition will be ordered alphabetically
Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)
Group letters ignoring case. In the output, use the case of the last occurrence in the input
Example:
Input: Kitkat Tango
(2k / 1i / 3T / 2a / 1n / 1g / 1o)
Output: 1g1i1n1o2a2k3T
Another example:
Input: Database Partitions Task
(1D / 5a / 4T / 1b / 3s / 1e / 1P / 1r / 2i / 1o / 1n / 3s / 1k)
Output: 1b1D1e1k1n1o1P1r2i3s4T5a
Note: the letters with 1 repeat are in the beginning ordered alphabetically
then the letters with more reps
This is code-golf, the shortest code wins.
code-golf word-puzzle
$endgroup$
$begingroup$
By 'count in each letter', do you mean how many times a letter appears in the input sentence?
$endgroup$
– Embodiment of Ignorance
13 hours ago
10
$begingroup$
Can a letter appear more than 9 times?
$endgroup$
– Shaggy
9 hours ago
$begingroup$
Can we output as an array? e.g.,["1g","1i","1n","1o","2a","2k","3T"]
or even[["1","g"],["1","i"],["1","n"],["1","o"],["2","a"],["2","k"],["3","T"]]
$endgroup$
– Shaggy
7 hours ago
$begingroup$
"Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)" - does this mean[a-z][A-Z]
only?
$endgroup$
– Jonathan Allan
4 hours ago
2
$begingroup$
@manatwork: But that's not unclear (note, their answer didn't assume that letters appear less than 10 times), it's just trying to loosen the input restrictions.
$endgroup$
– BMO
1 hour ago
|
show 4 more comments
$begingroup$
It is very hard to remember my password, so I came up with a way to generate a password.
The way I generate my password is from a word or a sentence, following these steps:
Start from left to right
Find the count of each letter
Put letter with its count in an order
Letters with higher repetition will be in the end
Letters with the same repetition will be ordered alphabetically
Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)
Group letters ignoring case. In the output, use the case of the last occurrence in the input
Example:
Input: Kitkat Tango
(2k / 1i / 3T / 2a / 1n / 1g / 1o)
Output: 1g1i1n1o2a2k3T
Another example:
Input: Database Partitions Task
(1D / 5a / 4T / 1b / 3s / 1e / 1P / 1r / 2i / 1o / 1n / 3s / 1k)
Output: 1b1D1e1k1n1o1P1r2i3s4T5a
Note: the letters with 1 repeat are in the beginning ordered alphabetically
then the letters with more reps
This is code-golf, the shortest code wins.
code-golf word-puzzle
$endgroup$
It is very hard to remember my password, so I came up with a way to generate a password.
The way I generate my password is from a word or a sentence, following these steps:
Start from left to right
Find the count of each letter
Put letter with its count in an order
Letters with higher repetition will be in the end
Letters with the same repetition will be ordered alphabetically
Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)
Group letters ignoring case. In the output, use the case of the last occurrence in the input
Example:
Input: Kitkat Tango
(2k / 1i / 3T / 2a / 1n / 1g / 1o)
Output: 1g1i1n1o2a2k3T
Another example:
Input: Database Partitions Task
(1D / 5a / 4T / 1b / 3s / 1e / 1P / 1r / 2i / 1o / 1n / 3s / 1k)
Output: 1b1D1e1k1n1o1P1r2i3s4T5a
Note: the letters with 1 repeat are in the beginning ordered alphabetically
then the letters with more reps
This is code-golf, the shortest code wins.
code-golf word-puzzle
code-golf word-puzzle
edited 24 mins ago
Shaggy
19.3k21666
19.3k21666
asked 13 hours ago
asmgxasmgx
249110
249110
$begingroup$
By 'count in each letter', do you mean how many times a letter appears in the input sentence?
$endgroup$
– Embodiment of Ignorance
13 hours ago
10
$begingroup$
Can a letter appear more than 9 times?
$endgroup$
– Shaggy
9 hours ago
$begingroup$
Can we output as an array? e.g.,["1g","1i","1n","1o","2a","2k","3T"]
or even[["1","g"],["1","i"],["1","n"],["1","o"],["2","a"],["2","k"],["3","T"]]
$endgroup$
– Shaggy
7 hours ago
$begingroup$
"Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)" - does this mean[a-z][A-Z]
only?
$endgroup$
– Jonathan Allan
4 hours ago
2
$begingroup$
@manatwork: But that's not unclear (note, their answer didn't assume that letters appear less than 10 times), it's just trying to loosen the input restrictions.
$endgroup$
– BMO
1 hour ago
|
show 4 more comments
$begingroup$
By 'count in each letter', do you mean how many times a letter appears in the input sentence?
$endgroup$
– Embodiment of Ignorance
13 hours ago
10
$begingroup$
Can a letter appear more than 9 times?
$endgroup$
– Shaggy
9 hours ago
$begingroup$
Can we output as an array? e.g.,["1g","1i","1n","1o","2a","2k","3T"]
or even[["1","g"],["1","i"],["1","n"],["1","o"],["2","a"],["2","k"],["3","T"]]
$endgroup$
– Shaggy
7 hours ago
$begingroup$
"Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)" - does this mean[a-z][A-Z]
only?
$endgroup$
– Jonathan Allan
4 hours ago
2
$begingroup$
@manatwork: But that's not unclear (note, their answer didn't assume that letters appear less than 10 times), it's just trying to loosen the input restrictions.
$endgroup$
– BMO
1 hour ago
$begingroup$
By 'count in each letter', do you mean how many times a letter appears in the input sentence?
$endgroup$
– Embodiment of Ignorance
13 hours ago
$begingroup$
By 'count in each letter', do you mean how many times a letter appears in the input sentence?
$endgroup$
– Embodiment of Ignorance
13 hours ago
10
10
$begingroup$
Can a letter appear more than 9 times?
$endgroup$
– Shaggy
9 hours ago
$begingroup$
Can a letter appear more than 9 times?
$endgroup$
– Shaggy
9 hours ago
$begingroup$
Can we output as an array? e.g.,
["1g","1i","1n","1o","2a","2k","3T"]
or even [["1","g"],["1","i"],["1","n"],["1","o"],["2","a"],["2","k"],["3","T"]]
$endgroup$
– Shaggy
7 hours ago
$begingroup$
Can we output as an array? e.g.,
["1g","1i","1n","1o","2a","2k","3T"]
or even [["1","g"],["1","i"],["1","n"],["1","o"],["2","a"],["2","k"],["3","T"]]
$endgroup$
– Shaggy
7 hours ago
$begingroup$
"Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)" - does this mean
[a-z][A-Z]
only?$endgroup$
– Jonathan Allan
4 hours ago
$begingroup$
"Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)" - does this mean
[a-z][A-Z]
only?$endgroup$
– Jonathan Allan
4 hours ago
2
2
$begingroup$
@manatwork: But that's not unclear (note, their answer didn't assume that letters appear less than 10 times), it's just trying to loosen the input restrictions.
$endgroup$
– BMO
1 hour ago
$begingroup$
@manatwork: But that's not unclear (note, their answer didn't assume that letters appear less than 10 times), it's just trying to loosen the input restrictions.
$endgroup$
– BMO
1 hour ago
|
show 4 more comments
10 Answers
10
active
oldest
votes
$begingroup$
05AB1E, 19 17 16 bytes
Saved 1 byte thanks to Kevin Cruijssen
áΣl}.γl}éεgyθJ}J
Try it online!
or as a Test Suite
Explanation
á # keep only letters in input
Σl} # sort by lower-case
.γl} # group by lower-case
é # sort by length (stable)
ε } # map each to
g # its length
J # joined with
yθ # the last letter
J # join to string
$endgroup$
$begingroup$
You can save a byte by changing the‚
(pair with) to a«
(concat/merge), so one of the twoJ
s (joins) can be removed.
$endgroup$
– Kevin Cruijssen
5 hours ago
$begingroup$
@KevinCruijssen: Wow. I feel stupid now :) Why didn't I just move aJ
inside? Edit: Actually, I needed them as a pair in the 19-byte version and I didn't think to change it when I made the 17 one :P
$endgroup$
– Emigna
4 hours ago
$begingroup$
You might be able to drop the secondJ
oin, depending on the answer to this question
$endgroup$
– Shaggy
26 mins ago
add a comment |
$begingroup$
Japt v2.0a0 -P
, 14 bytes
fl üv ñÊ®ÌiZÊ
Try it
fl üv ñÊ®ÌiZÊ :Implicit input of string
> e.g., "Kitkat Tango"
f :Split to an array of characters
l : Matching RegEx /[a-z]/gi
> ["K","i","t","k","a","t","T","a","n","g","o"]
ü :Sort & group (Preserves original order within each group)
v : By lowercase
> [["a","a"],["g"],["i"],["K","k"],["n"],["o"],["t","t","T"]]
ñ :Sort
Ê : By length
> [["g"],["i"],["n"],["o"],["a","a"],["K","k"],["t","t","T"]]
® :Map each Z
Ì : Last element of Z
> ["g","i","n","o","a","k","T"]
i : Prepend
ZÊ : Length of Z
> ["1g","1i","1n","1o","2a","2k","3T"]
:Implicitly join & output
> "1g1i1n1o2a2k3T"
$endgroup$
add a comment |
$begingroup$
Retina, 67 66 41 bytes
[Wd_]
O$`.
$l$0
ir`1*(.)
$.0$1
N`d+.
-25 bytes and a minor bug-fix thanks to @Neil.
Try it online or verify all test cases.
Explanation:
Remove everything except for upper- and lowercase letters:
i.e. Kitkat Tango 123!
→ KitkatTango
[Wd_]
Sort the individual letters case-insensitive (thanks to @MartinEnder for this):
i.e. KitkatTango
→ aagiKknottT
O$`.
$l$0
Capture every chunk of case-insensitive repeated adjacent letters:
i.e. aagiKknottT
→ [aa
,g
,i
,Kk
,n
,o
,ttT
]
ir`1*(.)
Prepend the length of every match, and only keep the last letter of every chunk:
i.e. [aa
,g
,i
,Kk
,n
,o
,ttT
] → 2a1g1i2k1n1o3T
$.0$1
Sort the numbers and letter groups based on the numbers:2a1g1i2k1n1o3T
→ 1g1i1n1o2a2k3T
N`d+.
After which the result is output implicitly.
$endgroup$
$begingroup$
Are you sure that's a bug? Is it not just sorting lexicographically? ("aA" < "aa"
)
$endgroup$
– Shaggy
7 hours ago
$begingroup$
@Shaggy You're right it's not a bug. I meant a bug in my program, not in Retina itself. It's behaving as you would expect indeed. I've edited it to 'problem'. If only I could doO$i
to sort case-insensitive, just like I canL
ist orm
atch case-insensitive by using$i
..
$endgroup$
– Kevin Cruijssen
7 hours ago
1
$begingroup$
@Shaggy I'm not sure if it can. Because thew
and.
in theO`w.
were used to indicate that we're sorting pairs of characters. Not sure if we can sort every pair of characters, but only sort it based on the first character. But ah well, Martin's suggestion to sort each character based on a substitution (which is the lowercase variant of the match) works like a charm. :)
$endgroup$
– Kevin Cruijssen
7 hours ago
1
$begingroup$
Can it be done in 41 bytes or am I missing something?
$endgroup$
– Neil
5 hours ago
1
$begingroup$
github.com/m-ender/retina/wiki/The-Language#regex-modifiers
$endgroup$
– Neil
4 hours ago
|
show 3 more comments
$begingroup$
Perl 6, 66 bytes
{[~] map {+$_~.tail},sort {+$_,.lc},values classify &lc,m:g/<:L>/}
Try it online!
$endgroup$
add a comment |
$begingroup$
Pyth, 27 24 22 bytes
srD0m+lded.gr0kf}r0TGQ
Try it online here.
srD0m+lded.gr0kf}r0TGQ Implicit: Q=eval(input()), G=lowercase alphabet
f Q Filter keep elements of Q, as T, when truthy:
r0T Convert T to lowercase
} G Is the above in G?
.g Group the remaining characters, as k, using:
r0k Convert k to lowercase
(Grouping preserves relative order)
m Map the sorted groups, as d, using:
ld Length of d
ed Last element of d
+ Concatenate the previous two results
D Sort the above...
r 0 ... by their lowercase values
s Concatenate the result of the above into a string, implicit print
Edit: Golfed 3 bytes by ordering by character before group, previous version: sm+ldedo,lNr0eN.gr0kf}r0TGQ
Edit 2: Golfed off another 2 bytes by formatting output before any ordering, previous version: sm+ldedlD.gr0krD0f}r0TGQ
$endgroup$
$begingroup$
@+GrG1
seems to save a byte for filtering. It's also worth noting that your sorting method won't always work if a character appears 10 or more times, but that hasn't been clarified yet.
$endgroup$
– FryAmTheEggman
18 mins ago
add a comment |
$begingroup$
Python 2, 99 bytes
def f(s):a=s.lower();return''.join(sorted(`a.count(c)`+s[a.rfind(c)]for c in set(a)if c.isalpha()))
Try it online!
$endgroup$
$begingroup$
The output forDatabase Partitions Task
is not equal to1b1D1e1k1n1o1P1r2i3s4T5a
$endgroup$
– mdahmoune
1 hour ago
add a comment |
$begingroup$
Red, 220 196 bytes
func[s][a: charset[#"a"-#"z"#"A"-#"Z"]rejoin sort collect[foreach c sort
unique reverse rejoin parse s[collect[any[keep[a]| skip]]][i: 0
foreach d s[if(c% 32)=(d% 32)[i: i + 1]]keep rejoin[i c]]]]
Try it online!
$endgroup$
add a comment |
$begingroup$
Perl 5, 74 68 bytes
-6 bytes changing -p
to -n
and using say
instead of $_=join"",
s/[a-z]/($h{lc$&}+=1).=$&/gie;say sort{$a-$b||lc$a cmp lc$b}values%h
TIO
61 bytes, in case there is no more than 9 occurence of each character
s/[a-z]/($h{lc$&}+=1).=$&/gie;print sort{lc$a cmp lc$b}values%h
$endgroup$
add a comment |
$begingroup$
Jelly, 15 bytes
fØẠµŒlĠLÞịµL,Ṫ)
A full program printing the password as specified (as a monadic Link it yields a list of lists each containing an integer and a character).
Try it online!
$endgroup$
add a comment |
$begingroup$
Charcoal, 30 bytes
F⌈Eβ№↧θιFβ¿⁼№↧θκ⊕ι⁺⊕ι§Φθ⁼↧λκ±¹
Try it online! Link is to verbose version of code. Explanation:
F⌈Eβ№↧θι
Run through the lowercase alphabet and find the highest character count in the lowercased input. Loop over the implicit range. (The loop actually goes from 0
to n-1
so I have to increment the loop variable at each use.)
Fβ
Loop over the lowercase alphabet again.
¿⁼№↧θκ⊕ι
If the count of the current letter is equal to the outer loop value...
⁺⊕ι§Φθ⁼↧λκ±¹
Concatenate the current count with the last occurrence of the current letter and implicitly print.
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f178888%2fgenerate-a-password%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
10 Answers
10
active
oldest
votes
10 Answers
10
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
05AB1E, 19 17 16 bytes
Saved 1 byte thanks to Kevin Cruijssen
áΣl}.γl}éεgyθJ}J
Try it online!
or as a Test Suite
Explanation
á # keep only letters in input
Σl} # sort by lower-case
.γl} # group by lower-case
é # sort by length (stable)
ε } # map each to
g # its length
J # joined with
yθ # the last letter
J # join to string
$endgroup$
$begingroup$
You can save a byte by changing the‚
(pair with) to a«
(concat/merge), so one of the twoJ
s (joins) can be removed.
$endgroup$
– Kevin Cruijssen
5 hours ago
$begingroup$
@KevinCruijssen: Wow. I feel stupid now :) Why didn't I just move aJ
inside? Edit: Actually, I needed them as a pair in the 19-byte version and I didn't think to change it when I made the 17 one :P
$endgroup$
– Emigna
4 hours ago
$begingroup$
You might be able to drop the secondJ
oin, depending on the answer to this question
$endgroup$
– Shaggy
26 mins ago
add a comment |
$begingroup$
05AB1E, 19 17 16 bytes
Saved 1 byte thanks to Kevin Cruijssen
áΣl}.γl}éεgyθJ}J
Try it online!
or as a Test Suite
Explanation
á # keep only letters in input
Σl} # sort by lower-case
.γl} # group by lower-case
é # sort by length (stable)
ε } # map each to
g # its length
J # joined with
yθ # the last letter
J # join to string
$endgroup$
$begingroup$
You can save a byte by changing the‚
(pair with) to a«
(concat/merge), so one of the twoJ
s (joins) can be removed.
$endgroup$
– Kevin Cruijssen
5 hours ago
$begingroup$
@KevinCruijssen: Wow. I feel stupid now :) Why didn't I just move aJ
inside? Edit: Actually, I needed them as a pair in the 19-byte version and I didn't think to change it when I made the 17 one :P
$endgroup$
– Emigna
4 hours ago
$begingroup$
You might be able to drop the secondJ
oin, depending on the answer to this question
$endgroup$
– Shaggy
26 mins ago
add a comment |
$begingroup$
05AB1E, 19 17 16 bytes
Saved 1 byte thanks to Kevin Cruijssen
áΣl}.γl}éεgyθJ}J
Try it online!
or as a Test Suite
Explanation
á # keep only letters in input
Σl} # sort by lower-case
.γl} # group by lower-case
é # sort by length (stable)
ε } # map each to
g # its length
J # joined with
yθ # the last letter
J # join to string
$endgroup$
05AB1E, 19 17 16 bytes
Saved 1 byte thanks to Kevin Cruijssen
áΣl}.γl}éεgyθJ}J
Try it online!
or as a Test Suite
Explanation
á # keep only letters in input
Σl} # sort by lower-case
.γl} # group by lower-case
é # sort by length (stable)
ε } # map each to
g # its length
J # joined with
yθ # the last letter
J # join to string
edited 4 hours ago
answered 10 hours ago
EmignaEmigna
45.7k432139
45.7k432139
$begingroup$
You can save a byte by changing the‚
(pair with) to a«
(concat/merge), so one of the twoJ
s (joins) can be removed.
$endgroup$
– Kevin Cruijssen
5 hours ago
$begingroup$
@KevinCruijssen: Wow. I feel stupid now :) Why didn't I just move aJ
inside? Edit: Actually, I needed them as a pair in the 19-byte version and I didn't think to change it when I made the 17 one :P
$endgroup$
– Emigna
4 hours ago
$begingroup$
You might be able to drop the secondJ
oin, depending on the answer to this question
$endgroup$
– Shaggy
26 mins ago
add a comment |
$begingroup$
You can save a byte by changing the‚
(pair with) to a«
(concat/merge), so one of the twoJ
s (joins) can be removed.
$endgroup$
– Kevin Cruijssen
5 hours ago
$begingroup$
@KevinCruijssen: Wow. I feel stupid now :) Why didn't I just move aJ
inside? Edit: Actually, I needed them as a pair in the 19-byte version and I didn't think to change it when I made the 17 one :P
$endgroup$
– Emigna
4 hours ago
$begingroup$
You might be able to drop the secondJ
oin, depending on the answer to this question
$endgroup$
– Shaggy
26 mins ago
$begingroup$
You can save a byte by changing the
‚
(pair with) to a «
(concat/merge), so one of the two J
s (joins) can be removed.$endgroup$
– Kevin Cruijssen
5 hours ago
$begingroup$
You can save a byte by changing the
‚
(pair with) to a «
(concat/merge), so one of the two J
s (joins) can be removed.$endgroup$
– Kevin Cruijssen
5 hours ago
$begingroup$
@KevinCruijssen: Wow. I feel stupid now :) Why didn't I just move a
J
inside? Edit: Actually, I needed them as a pair in the 19-byte version and I didn't think to change it when I made the 17 one :P$endgroup$
– Emigna
4 hours ago
$begingroup$
@KevinCruijssen: Wow. I feel stupid now :) Why didn't I just move a
J
inside? Edit: Actually, I needed them as a pair in the 19-byte version and I didn't think to change it when I made the 17 one :P$endgroup$
– Emigna
4 hours ago
$begingroup$
You might be able to drop the second
J
oin, depending on the answer to this question$endgroup$
– Shaggy
26 mins ago
$begingroup$
You might be able to drop the second
J
oin, depending on the answer to this question$endgroup$
– Shaggy
26 mins ago
add a comment |
$begingroup$
Japt v2.0a0 -P
, 14 bytes
fl üv ñÊ®ÌiZÊ
Try it
fl üv ñÊ®ÌiZÊ :Implicit input of string
> e.g., "Kitkat Tango"
f :Split to an array of characters
l : Matching RegEx /[a-z]/gi
> ["K","i","t","k","a","t","T","a","n","g","o"]
ü :Sort & group (Preserves original order within each group)
v : By lowercase
> [["a","a"],["g"],["i"],["K","k"],["n"],["o"],["t","t","T"]]
ñ :Sort
Ê : By length
> [["g"],["i"],["n"],["o"],["a","a"],["K","k"],["t","t","T"]]
® :Map each Z
Ì : Last element of Z
> ["g","i","n","o","a","k","T"]
i : Prepend
ZÊ : Length of Z
> ["1g","1i","1n","1o","2a","2k","3T"]
:Implicitly join & output
> "1g1i1n1o2a2k3T"
$endgroup$
add a comment |
$begingroup$
Japt v2.0a0 -P
, 14 bytes
fl üv ñÊ®ÌiZÊ
Try it
fl üv ñÊ®ÌiZÊ :Implicit input of string
> e.g., "Kitkat Tango"
f :Split to an array of characters
l : Matching RegEx /[a-z]/gi
> ["K","i","t","k","a","t","T","a","n","g","o"]
ü :Sort & group (Preserves original order within each group)
v : By lowercase
> [["a","a"],["g"],["i"],["K","k"],["n"],["o"],["t","t","T"]]
ñ :Sort
Ê : By length
> [["g"],["i"],["n"],["o"],["a","a"],["K","k"],["t","t","T"]]
® :Map each Z
Ì : Last element of Z
> ["g","i","n","o","a","k","T"]
i : Prepend
ZÊ : Length of Z
> ["1g","1i","1n","1o","2a","2k","3T"]
:Implicitly join & output
> "1g1i1n1o2a2k3T"
$endgroup$
add a comment |
$begingroup$
Japt v2.0a0 -P
, 14 bytes
fl üv ñÊ®ÌiZÊ
Try it
fl üv ñÊ®ÌiZÊ :Implicit input of string
> e.g., "Kitkat Tango"
f :Split to an array of characters
l : Matching RegEx /[a-z]/gi
> ["K","i","t","k","a","t","T","a","n","g","o"]
ü :Sort & group (Preserves original order within each group)
v : By lowercase
> [["a","a"],["g"],["i"],["K","k"],["n"],["o"],["t","t","T"]]
ñ :Sort
Ê : By length
> [["g"],["i"],["n"],["o"],["a","a"],["K","k"],["t","t","T"]]
® :Map each Z
Ì : Last element of Z
> ["g","i","n","o","a","k","T"]
i : Prepend
ZÊ : Length of Z
> ["1g","1i","1n","1o","2a","2k","3T"]
:Implicitly join & output
> "1g1i1n1o2a2k3T"
$endgroup$
Japt v2.0a0 -P
, 14 bytes
fl üv ñÊ®ÌiZÊ
Try it
fl üv ñÊ®ÌiZÊ :Implicit input of string
> e.g., "Kitkat Tango"
f :Split to an array of characters
l : Matching RegEx /[a-z]/gi
> ["K","i","t","k","a","t","T","a","n","g","o"]
ü :Sort & group (Preserves original order within each group)
v : By lowercase
> [["a","a"],["g"],["i"],["K","k"],["n"],["o"],["t","t","T"]]
ñ :Sort
Ê : By length
> [["g"],["i"],["n"],["o"],["a","a"],["K","k"],["t","t","T"]]
® :Map each Z
Ì : Last element of Z
> ["g","i","n","o","a","k","T"]
i : Prepend
ZÊ : Length of Z
> ["1g","1i","1n","1o","2a","2k","3T"]
:Implicitly join & output
> "1g1i1n1o2a2k3T"
edited 6 hours ago
answered 9 hours ago
ShaggyShaggy
19.3k21666
19.3k21666
add a comment |
add a comment |
$begingroup$
Retina, 67 66 41 bytes
[Wd_]
O$`.
$l$0
ir`1*(.)
$.0$1
N`d+.
-25 bytes and a minor bug-fix thanks to @Neil.
Try it online or verify all test cases.
Explanation:
Remove everything except for upper- and lowercase letters:
i.e. Kitkat Tango 123!
→ KitkatTango
[Wd_]
Sort the individual letters case-insensitive (thanks to @MartinEnder for this):
i.e. KitkatTango
→ aagiKknottT
O$`.
$l$0
Capture every chunk of case-insensitive repeated adjacent letters:
i.e. aagiKknottT
→ [aa
,g
,i
,Kk
,n
,o
,ttT
]
ir`1*(.)
Prepend the length of every match, and only keep the last letter of every chunk:
i.e. [aa
,g
,i
,Kk
,n
,o
,ttT
] → 2a1g1i2k1n1o3T
$.0$1
Sort the numbers and letter groups based on the numbers:2a1g1i2k1n1o3T
→ 1g1i1n1o2a2k3T
N`d+.
After which the result is output implicitly.
$endgroup$
$begingroup$
Are you sure that's a bug? Is it not just sorting lexicographically? ("aA" < "aa"
)
$endgroup$
– Shaggy
7 hours ago
$begingroup$
@Shaggy You're right it's not a bug. I meant a bug in my program, not in Retina itself. It's behaving as you would expect indeed. I've edited it to 'problem'. If only I could doO$i
to sort case-insensitive, just like I canL
ist orm
atch case-insensitive by using$i
..
$endgroup$
– Kevin Cruijssen
7 hours ago
1
$begingroup$
@Shaggy I'm not sure if it can. Because thew
and.
in theO`w.
were used to indicate that we're sorting pairs of characters. Not sure if we can sort every pair of characters, but only sort it based on the first character. But ah well, Martin's suggestion to sort each character based on a substitution (which is the lowercase variant of the match) works like a charm. :)
$endgroup$
– Kevin Cruijssen
7 hours ago
1
$begingroup$
Can it be done in 41 bytes or am I missing something?
$endgroup$
– Neil
5 hours ago
1
$begingroup$
github.com/m-ender/retina/wiki/The-Language#regex-modifiers
$endgroup$
– Neil
4 hours ago
|
show 3 more comments
$begingroup$
Retina, 67 66 41 bytes
[Wd_]
O$`.
$l$0
ir`1*(.)
$.0$1
N`d+.
-25 bytes and a minor bug-fix thanks to @Neil.
Try it online or verify all test cases.
Explanation:
Remove everything except for upper- and lowercase letters:
i.e. Kitkat Tango 123!
→ KitkatTango
[Wd_]
Sort the individual letters case-insensitive (thanks to @MartinEnder for this):
i.e. KitkatTango
→ aagiKknottT
O$`.
$l$0
Capture every chunk of case-insensitive repeated adjacent letters:
i.e. aagiKknottT
→ [aa
,g
,i
,Kk
,n
,o
,ttT
]
ir`1*(.)
Prepend the length of every match, and only keep the last letter of every chunk:
i.e. [aa
,g
,i
,Kk
,n
,o
,ttT
] → 2a1g1i2k1n1o3T
$.0$1
Sort the numbers and letter groups based on the numbers:2a1g1i2k1n1o3T
→ 1g1i1n1o2a2k3T
N`d+.
After which the result is output implicitly.
$endgroup$
$begingroup$
Are you sure that's a bug? Is it not just sorting lexicographically? ("aA" < "aa"
)
$endgroup$
– Shaggy
7 hours ago
$begingroup$
@Shaggy You're right it's not a bug. I meant a bug in my program, not in Retina itself. It's behaving as you would expect indeed. I've edited it to 'problem'. If only I could doO$i
to sort case-insensitive, just like I canL
ist orm
atch case-insensitive by using$i
..
$endgroup$
– Kevin Cruijssen
7 hours ago
1
$begingroup$
@Shaggy I'm not sure if it can. Because thew
and.
in theO`w.
were used to indicate that we're sorting pairs of characters. Not sure if we can sort every pair of characters, but only sort it based on the first character. But ah well, Martin's suggestion to sort each character based on a substitution (which is the lowercase variant of the match) works like a charm. :)
$endgroup$
– Kevin Cruijssen
7 hours ago
1
$begingroup$
Can it be done in 41 bytes or am I missing something?
$endgroup$
– Neil
5 hours ago
1
$begingroup$
github.com/m-ender/retina/wiki/The-Language#regex-modifiers
$endgroup$
– Neil
4 hours ago
|
show 3 more comments
$begingroup$
Retina, 67 66 41 bytes
[Wd_]
O$`.
$l$0
ir`1*(.)
$.0$1
N`d+.
-25 bytes and a minor bug-fix thanks to @Neil.
Try it online or verify all test cases.
Explanation:
Remove everything except for upper- and lowercase letters:
i.e. Kitkat Tango 123!
→ KitkatTango
[Wd_]
Sort the individual letters case-insensitive (thanks to @MartinEnder for this):
i.e. KitkatTango
→ aagiKknottT
O$`.
$l$0
Capture every chunk of case-insensitive repeated adjacent letters:
i.e. aagiKknottT
→ [aa
,g
,i
,Kk
,n
,o
,ttT
]
ir`1*(.)
Prepend the length of every match, and only keep the last letter of every chunk:
i.e. [aa
,g
,i
,Kk
,n
,o
,ttT
] → 2a1g1i2k1n1o3T
$.0$1
Sort the numbers and letter groups based on the numbers:2a1g1i2k1n1o3T
→ 1g1i1n1o2a2k3T
N`d+.
After which the result is output implicitly.
$endgroup$
Retina, 67 66 41 bytes
[Wd_]
O$`.
$l$0
ir`1*(.)
$.0$1
N`d+.
-25 bytes and a minor bug-fix thanks to @Neil.
Try it online or verify all test cases.
Explanation:
Remove everything except for upper- and lowercase letters:
i.e. Kitkat Tango 123!
→ KitkatTango
[Wd_]
Sort the individual letters case-insensitive (thanks to @MartinEnder for this):
i.e. KitkatTango
→ aagiKknottT
O$`.
$l$0
Capture every chunk of case-insensitive repeated adjacent letters:
i.e. aagiKknottT
→ [aa
,g
,i
,Kk
,n
,o
,ttT
]
ir`1*(.)
Prepend the length of every match, and only keep the last letter of every chunk:
i.e. [aa
,g
,i
,Kk
,n
,o
,ttT
] → 2a1g1i2k1n1o3T
$.0$1
Sort the numbers and letter groups based on the numbers:2a1g1i2k1n1o3T
→ 1g1i1n1o2a2k3T
N`d+.
After which the result is output implicitly.
edited 4 hours ago
answered 8 hours ago
Kevin CruijssenKevin Cruijssen
36.4k555192
36.4k555192
$begingroup$
Are you sure that's a bug? Is it not just sorting lexicographically? ("aA" < "aa"
)
$endgroup$
– Shaggy
7 hours ago
$begingroup$
@Shaggy You're right it's not a bug. I meant a bug in my program, not in Retina itself. It's behaving as you would expect indeed. I've edited it to 'problem'. If only I could doO$i
to sort case-insensitive, just like I canL
ist orm
atch case-insensitive by using$i
..
$endgroup$
– Kevin Cruijssen
7 hours ago
1
$begingroup$
@Shaggy I'm not sure if it can. Because thew
and.
in theO`w.
were used to indicate that we're sorting pairs of characters. Not sure if we can sort every pair of characters, but only sort it based on the first character. But ah well, Martin's suggestion to sort each character based on a substitution (which is the lowercase variant of the match) works like a charm. :)
$endgroup$
– Kevin Cruijssen
7 hours ago
1
$begingroup$
Can it be done in 41 bytes or am I missing something?
$endgroup$
– Neil
5 hours ago
1
$begingroup$
github.com/m-ender/retina/wiki/The-Language#regex-modifiers
$endgroup$
– Neil
4 hours ago
|
show 3 more comments
$begingroup$
Are you sure that's a bug? Is it not just sorting lexicographically? ("aA" < "aa"
)
$endgroup$
– Shaggy
7 hours ago
$begingroup$
@Shaggy You're right it's not a bug. I meant a bug in my program, not in Retina itself. It's behaving as you would expect indeed. I've edited it to 'problem'. If only I could doO$i
to sort case-insensitive, just like I canL
ist orm
atch case-insensitive by using$i
..
$endgroup$
– Kevin Cruijssen
7 hours ago
1
$begingroup$
@Shaggy I'm not sure if it can. Because thew
and.
in theO`w.
were used to indicate that we're sorting pairs of characters. Not sure if we can sort every pair of characters, but only sort it based on the first character. But ah well, Martin's suggestion to sort each character based on a substitution (which is the lowercase variant of the match) works like a charm. :)
$endgroup$
– Kevin Cruijssen
7 hours ago
1
$begingroup$
Can it be done in 41 bytes or am I missing something?
$endgroup$
– Neil
5 hours ago
1
$begingroup$
github.com/m-ender/retina/wiki/The-Language#regex-modifiers
$endgroup$
– Neil
4 hours ago
$begingroup$
Are you sure that's a bug? Is it not just sorting lexicographically? (
"aA" < "aa"
)$endgroup$
– Shaggy
7 hours ago
$begingroup$
Are you sure that's a bug? Is it not just sorting lexicographically? (
"aA" < "aa"
)$endgroup$
– Shaggy
7 hours ago
$begingroup$
@Shaggy You're right it's not a bug. I meant a bug in my program, not in Retina itself. It's behaving as you would expect indeed. I've edited it to 'problem'. If only I could do
O$i
to sort case-insensitive, just like I can L
ist or m
atch case-insensitive by using $i
..$endgroup$
– Kevin Cruijssen
7 hours ago
$begingroup$
@Shaggy You're right it's not a bug. I meant a bug in my program, not in Retina itself. It's behaving as you would expect indeed. I've edited it to 'problem'. If only I could do
O$i
to sort case-insensitive, just like I can L
ist or m
atch case-insensitive by using $i
..$endgroup$
– Kevin Cruijssen
7 hours ago
1
1
$begingroup$
@Shaggy I'm not sure if it can. Because the
w
and .
in the O`w.
were used to indicate that we're sorting pairs of characters. Not sure if we can sort every pair of characters, but only sort it based on the first character. But ah well, Martin's suggestion to sort each character based on a substitution (which is the lowercase variant of the match) works like a charm. :)$endgroup$
– Kevin Cruijssen
7 hours ago
$begingroup$
@Shaggy I'm not sure if it can. Because the
w
and .
in the O`w.
were used to indicate that we're sorting pairs of characters. Not sure if we can sort every pair of characters, but only sort it based on the first character. But ah well, Martin's suggestion to sort each character based on a substitution (which is the lowercase variant of the match) works like a charm. :)$endgroup$
– Kevin Cruijssen
7 hours ago
1
1
$begingroup$
Can it be done in 41 bytes or am I missing something?
$endgroup$
– Neil
5 hours ago
$begingroup$
Can it be done in 41 bytes or am I missing something?
$endgroup$
– Neil
5 hours ago
1
1
$begingroup$
github.com/m-ender/retina/wiki/The-Language#regex-modifiers
$endgroup$
– Neil
4 hours ago
$begingroup$
github.com/m-ender/retina/wiki/The-Language#regex-modifiers
$endgroup$
– Neil
4 hours ago
|
show 3 more comments
$begingroup$
Perl 6, 66 bytes
{[~] map {+$_~.tail},sort {+$_,.lc},values classify &lc,m:g/<:L>/}
Try it online!
$endgroup$
add a comment |
$begingroup$
Perl 6, 66 bytes
{[~] map {+$_~.tail},sort {+$_,.lc},values classify &lc,m:g/<:L>/}
Try it online!
$endgroup$
add a comment |
$begingroup$
Perl 6, 66 bytes
{[~] map {+$_~.tail},sort {+$_,.lc},values classify &lc,m:g/<:L>/}
Try it online!
$endgroup$
Perl 6, 66 bytes
{[~] map {+$_~.tail},sort {+$_,.lc},values classify &lc,m:g/<:L>/}
Try it online!
answered 6 hours ago
nwellnhofnwellnhof
6,55511125
6,55511125
add a comment |
add a comment |
$begingroup$
Pyth, 27 24 22 bytes
srD0m+lded.gr0kf}r0TGQ
Try it online here.
srD0m+lded.gr0kf}r0TGQ Implicit: Q=eval(input()), G=lowercase alphabet
f Q Filter keep elements of Q, as T, when truthy:
r0T Convert T to lowercase
} G Is the above in G?
.g Group the remaining characters, as k, using:
r0k Convert k to lowercase
(Grouping preserves relative order)
m Map the sorted groups, as d, using:
ld Length of d
ed Last element of d
+ Concatenate the previous two results
D Sort the above...
r 0 ... by their lowercase values
s Concatenate the result of the above into a string, implicit print
Edit: Golfed 3 bytes by ordering by character before group, previous version: sm+ldedo,lNr0eN.gr0kf}r0TGQ
Edit 2: Golfed off another 2 bytes by formatting output before any ordering, previous version: sm+ldedlD.gr0krD0f}r0TGQ
$endgroup$
$begingroup$
@+GrG1
seems to save a byte for filtering. It's also worth noting that your sorting method won't always work if a character appears 10 or more times, but that hasn't been clarified yet.
$endgroup$
– FryAmTheEggman
18 mins ago
add a comment |
$begingroup$
Pyth, 27 24 22 bytes
srD0m+lded.gr0kf}r0TGQ
Try it online here.
srD0m+lded.gr0kf}r0TGQ Implicit: Q=eval(input()), G=lowercase alphabet
f Q Filter keep elements of Q, as T, when truthy:
r0T Convert T to lowercase
} G Is the above in G?
.g Group the remaining characters, as k, using:
r0k Convert k to lowercase
(Grouping preserves relative order)
m Map the sorted groups, as d, using:
ld Length of d
ed Last element of d
+ Concatenate the previous two results
D Sort the above...
r 0 ... by their lowercase values
s Concatenate the result of the above into a string, implicit print
Edit: Golfed 3 bytes by ordering by character before group, previous version: sm+ldedo,lNr0eN.gr0kf}r0TGQ
Edit 2: Golfed off another 2 bytes by formatting output before any ordering, previous version: sm+ldedlD.gr0krD0f}r0TGQ
$endgroup$
$begingroup$
@+GrG1
seems to save a byte for filtering. It's also worth noting that your sorting method won't always work if a character appears 10 or more times, but that hasn't been clarified yet.
$endgroup$
– FryAmTheEggman
18 mins ago
add a comment |
$begingroup$
Pyth, 27 24 22 bytes
srD0m+lded.gr0kf}r0TGQ
Try it online here.
srD0m+lded.gr0kf}r0TGQ Implicit: Q=eval(input()), G=lowercase alphabet
f Q Filter keep elements of Q, as T, when truthy:
r0T Convert T to lowercase
} G Is the above in G?
.g Group the remaining characters, as k, using:
r0k Convert k to lowercase
(Grouping preserves relative order)
m Map the sorted groups, as d, using:
ld Length of d
ed Last element of d
+ Concatenate the previous two results
D Sort the above...
r 0 ... by their lowercase values
s Concatenate the result of the above into a string, implicit print
Edit: Golfed 3 bytes by ordering by character before group, previous version: sm+ldedo,lNr0eN.gr0kf}r0TGQ
Edit 2: Golfed off another 2 bytes by formatting output before any ordering, previous version: sm+ldedlD.gr0krD0f}r0TGQ
$endgroup$
Pyth, 27 24 22 bytes
srD0m+lded.gr0kf}r0TGQ
Try it online here.
srD0m+lded.gr0kf}r0TGQ Implicit: Q=eval(input()), G=lowercase alphabet
f Q Filter keep elements of Q, as T, when truthy:
r0T Convert T to lowercase
} G Is the above in G?
.g Group the remaining characters, as k, using:
r0k Convert k to lowercase
(Grouping preserves relative order)
m Map the sorted groups, as d, using:
ld Length of d
ed Last element of d
+ Concatenate the previous two results
D Sort the above...
r 0 ... by their lowercase values
s Concatenate the result of the above into a string, implicit print
Edit: Golfed 3 bytes by ordering by character before group, previous version: sm+ldedo,lNr0eN.gr0kf}r0TGQ
Edit 2: Golfed off another 2 bytes by formatting output before any ordering, previous version: sm+ldedlD.gr0krD0f}r0TGQ
edited 2 hours ago
answered 8 hours ago
SokSok
3,627723
3,627723
$begingroup$
@+GrG1
seems to save a byte for filtering. It's also worth noting that your sorting method won't always work if a character appears 10 or more times, but that hasn't been clarified yet.
$endgroup$
– FryAmTheEggman
18 mins ago
add a comment |
$begingroup$
@+GrG1
seems to save a byte for filtering. It's also worth noting that your sorting method won't always work if a character appears 10 or more times, but that hasn't been clarified yet.
$endgroup$
– FryAmTheEggman
18 mins ago
$begingroup$
@+GrG1
seems to save a byte for filtering. It's also worth noting that your sorting method won't always work if a character appears 10 or more times, but that hasn't been clarified yet.$endgroup$
– FryAmTheEggman
18 mins ago
$begingroup$
@+GrG1
seems to save a byte for filtering. It's also worth noting that your sorting method won't always work if a character appears 10 or more times, but that hasn't been clarified yet.$endgroup$
– FryAmTheEggman
18 mins ago
add a comment |
$begingroup$
Python 2, 99 bytes
def f(s):a=s.lower();return''.join(sorted(`a.count(c)`+s[a.rfind(c)]for c in set(a)if c.isalpha()))
Try it online!
$endgroup$
$begingroup$
The output forDatabase Partitions Task
is not equal to1b1D1e1k1n1o1P1r2i3s4T5a
$endgroup$
– mdahmoune
1 hour ago
add a comment |
$begingroup$
Python 2, 99 bytes
def f(s):a=s.lower();return''.join(sorted(`a.count(c)`+s[a.rfind(c)]for c in set(a)if c.isalpha()))
Try it online!
$endgroup$
$begingroup$
The output forDatabase Partitions Task
is not equal to1b1D1e1k1n1o1P1r2i3s4T5a
$endgroup$
– mdahmoune
1 hour ago
add a comment |
$begingroup$
Python 2, 99 bytes
def f(s):a=s.lower();return''.join(sorted(`a.count(c)`+s[a.rfind(c)]for c in set(a)if c.isalpha()))
Try it online!
$endgroup$
Python 2, 99 bytes
def f(s):a=s.lower();return''.join(sorted(`a.count(c)`+s[a.rfind(c)]for c in set(a)if c.isalpha()))
Try it online!
answered 9 hours ago
TFeldTFeld
14.5k21241
14.5k21241
$begingroup$
The output forDatabase Partitions Task
is not equal to1b1D1e1k1n1o1P1r2i3s4T5a
$endgroup$
– mdahmoune
1 hour ago
add a comment |
$begingroup$
The output forDatabase Partitions Task
is not equal to1b1D1e1k1n1o1P1r2i3s4T5a
$endgroup$
– mdahmoune
1 hour ago
$begingroup$
The output for
Database Partitions Task
is not equal to 1b1D1e1k1n1o1P1r2i3s4T5a
$endgroup$
– mdahmoune
1 hour ago
$begingroup$
The output for
Database Partitions Task
is not equal to 1b1D1e1k1n1o1P1r2i3s4T5a
$endgroup$
– mdahmoune
1 hour ago
add a comment |
$begingroup$
Red, 220 196 bytes
func[s][a: charset[#"a"-#"z"#"A"-#"Z"]rejoin sort collect[foreach c sort
unique reverse rejoin parse s[collect[any[keep[a]| skip]]][i: 0
foreach d s[if(c% 32)=(d% 32)[i: i + 1]]keep rejoin[i c]]]]
Try it online!
$endgroup$
add a comment |
$begingroup$
Red, 220 196 bytes
func[s][a: charset[#"a"-#"z"#"A"-#"Z"]rejoin sort collect[foreach c sort
unique reverse rejoin parse s[collect[any[keep[a]| skip]]][i: 0
foreach d s[if(c% 32)=(d% 32)[i: i + 1]]keep rejoin[i c]]]]
Try it online!
$endgroup$
add a comment |
$begingroup$
Red, 220 196 bytes
func[s][a: charset[#"a"-#"z"#"A"-#"Z"]rejoin sort collect[foreach c sort
unique reverse rejoin parse s[collect[any[keep[a]| skip]]][i: 0
foreach d s[if(c% 32)=(d% 32)[i: i + 1]]keep rejoin[i c]]]]
Try it online!
$endgroup$
Red, 220 196 bytes
func[s][a: charset[#"a"-#"z"#"A"-#"Z"]rejoin sort collect[foreach c sort
unique reverse rejoin parse s[collect[any[keep[a]| skip]]][i: 0
foreach d s[if(c% 32)=(d% 32)[i: i + 1]]keep rejoin[i c]]]]
Try it online!
edited 8 hours ago
answered 8 hours ago
Galen IvanovGalen Ivanov
6,51711032
6,51711032
add a comment |
add a comment |
$begingroup$
Perl 5, 74 68 bytes
-6 bytes changing -p
to -n
and using say
instead of $_=join"",
s/[a-z]/($h{lc$&}+=1).=$&/gie;say sort{$a-$b||lc$a cmp lc$b}values%h
TIO
61 bytes, in case there is no more than 9 occurence of each character
s/[a-z]/($h{lc$&}+=1).=$&/gie;print sort{lc$a cmp lc$b}values%h
$endgroup$
add a comment |
$begingroup$
Perl 5, 74 68 bytes
-6 bytes changing -p
to -n
and using say
instead of $_=join"",
s/[a-z]/($h{lc$&}+=1).=$&/gie;say sort{$a-$b||lc$a cmp lc$b}values%h
TIO
61 bytes, in case there is no more than 9 occurence of each character
s/[a-z]/($h{lc$&}+=1).=$&/gie;print sort{lc$a cmp lc$b}values%h
$endgroup$
add a comment |
$begingroup$
Perl 5, 74 68 bytes
-6 bytes changing -p
to -n
and using say
instead of $_=join"",
s/[a-z]/($h{lc$&}+=1).=$&/gie;say sort{$a-$b||lc$a cmp lc$b}values%h
TIO
61 bytes, in case there is no more than 9 occurence of each character
s/[a-z]/($h{lc$&}+=1).=$&/gie;print sort{lc$a cmp lc$b}values%h
$endgroup$
Perl 5, 74 68 bytes
-6 bytes changing -p
to -n
and using say
instead of $_=join"",
s/[a-z]/($h{lc$&}+=1).=$&/gie;say sort{$a-$b||lc$a cmp lc$b}values%h
TIO
61 bytes, in case there is no more than 9 occurence of each character
s/[a-z]/($h{lc$&}+=1).=$&/gie;print sort{lc$a cmp lc$b}values%h
edited 6 hours ago
answered 8 hours ago
Nahuel FouilleulNahuel Fouilleul
1,67228
1,67228
add a comment |
add a comment |
$begingroup$
Jelly, 15 bytes
fØẠµŒlĠLÞịµL,Ṫ)
A full program printing the password as specified (as a monadic Link it yields a list of lists each containing an integer and a character).
Try it online!
$endgroup$
add a comment |
$begingroup$
Jelly, 15 bytes
fØẠµŒlĠLÞịµL,Ṫ)
A full program printing the password as specified (as a monadic Link it yields a list of lists each containing an integer and a character).
Try it online!
$endgroup$
add a comment |
$begingroup$
Jelly, 15 bytes
fØẠµŒlĠLÞịµL,Ṫ)
A full program printing the password as specified (as a monadic Link it yields a list of lists each containing an integer and a character).
Try it online!
$endgroup$
Jelly, 15 bytes
fØẠµŒlĠLÞịµL,Ṫ)
A full program printing the password as specified (as a monadic Link it yields a list of lists each containing an integer and a character).
Try it online!
answered 3 hours ago
Jonathan AllanJonathan Allan
51.2k534166
51.2k534166
add a comment |
add a comment |
$begingroup$
Charcoal, 30 bytes
F⌈Eβ№↧θιFβ¿⁼№↧θκ⊕ι⁺⊕ι§Φθ⁼↧λκ±¹
Try it online! Link is to verbose version of code. Explanation:
F⌈Eβ№↧θι
Run through the lowercase alphabet and find the highest character count in the lowercased input. Loop over the implicit range. (The loop actually goes from 0
to n-1
so I have to increment the loop variable at each use.)
Fβ
Loop over the lowercase alphabet again.
¿⁼№↧θκ⊕ι
If the count of the current letter is equal to the outer loop value...
⁺⊕ι§Φθ⁼↧λκ±¹
Concatenate the current count with the last occurrence of the current letter and implicitly print.
$endgroup$
add a comment |
$begingroup$
Charcoal, 30 bytes
F⌈Eβ№↧θιFβ¿⁼№↧θκ⊕ι⁺⊕ι§Φθ⁼↧λκ±¹
Try it online! Link is to verbose version of code. Explanation:
F⌈Eβ№↧θι
Run through the lowercase alphabet and find the highest character count in the lowercased input. Loop over the implicit range. (The loop actually goes from 0
to n-1
so I have to increment the loop variable at each use.)
Fβ
Loop over the lowercase alphabet again.
¿⁼№↧θκ⊕ι
If the count of the current letter is equal to the outer loop value...
⁺⊕ι§Φθ⁼↧λκ±¹
Concatenate the current count with the last occurrence of the current letter and implicitly print.
$endgroup$
add a comment |
$begingroup$
Charcoal, 30 bytes
F⌈Eβ№↧θιFβ¿⁼№↧θκ⊕ι⁺⊕ι§Φθ⁼↧λκ±¹
Try it online! Link is to verbose version of code. Explanation:
F⌈Eβ№↧θι
Run through the lowercase alphabet and find the highest character count in the lowercased input. Loop over the implicit range. (The loop actually goes from 0
to n-1
so I have to increment the loop variable at each use.)
Fβ
Loop over the lowercase alphabet again.
¿⁼№↧θκ⊕ι
If the count of the current letter is equal to the outer loop value...
⁺⊕ι§Φθ⁼↧λκ±¹
Concatenate the current count with the last occurrence of the current letter and implicitly print.
$endgroup$
Charcoal, 30 bytes
F⌈Eβ№↧θιFβ¿⁼№↧θκ⊕ι⁺⊕ι§Φθ⁼↧λκ±¹
Try it online! Link is to verbose version of code. Explanation:
F⌈Eβ№↧θι
Run through the lowercase alphabet and find the highest character count in the lowercased input. Loop over the implicit range. (The loop actually goes from 0
to n-1
so I have to increment the loop variable at each use.)
Fβ
Loop over the lowercase alphabet again.
¿⁼№↧θκ⊕ι
If the count of the current letter is equal to the outer loop value...
⁺⊕ι§Φθ⁼↧λκ±¹
Concatenate the current count with the last occurrence of the current letter and implicitly print.
answered 4 hours ago
NeilNeil
79.9k744177
79.9k744177
add a comment |
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f178888%2fgenerate-a-password%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
By 'count in each letter', do you mean how many times a letter appears in the input sentence?
$endgroup$
– Embodiment of Ignorance
13 hours ago
10
$begingroup$
Can a letter appear more than 9 times?
$endgroup$
– Shaggy
9 hours ago
$begingroup$
Can we output as an array? e.g.,
["1g","1i","1n","1o","2a","2k","3T"]
or even[["1","g"],["1","i"],["1","n"],["1","o"],["2","a"],["2","k"],["3","T"]]
$endgroup$
– Shaggy
7 hours ago
$begingroup$
"Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)" - does this mean
[a-z][A-Z]
only?$endgroup$
– Jonathan Allan
4 hours ago
2
$begingroup$
@manatwork: But that's not unclear (note, their answer didn't assume that letters appear less than 10 times), it's just trying to loosen the input restrictions.
$endgroup$
– BMO
1 hour ago