15
2
A paragraph of text has numbers and alphabetic letters mixed. Your task is to separate the numbers to the left side and the alphabetic letters to the right side in the same order of each line.
Rules:
- Numbers are plain integers; so no decimal point, and no negative/positive signs.
- Numbers may or may not be contiguous, but whatever the case may be, they have to be pushed to left side in the same order.
- Numbers may occur in between words.
- The text contains only ASCII alphabetic letters and numbers, along with spaces, underscores, commas and dots.
- The one who does this with minimum keystrokes (like vim macros) or least amount of bytes in case of scripting is the winner.
Example Text:
A word can have any number of text like 433884,
but all the numb89ers has to be moved left side
but alph6abetical va9lues has to be pas46ted on right side.
The text might con4tain chara29cters s2huffled like hlep or dfeintino or even
meaningless1 words co43mbined togeth81er.
Expected output:
433884A word can have any number of text like ,
89but all the numbers has to be moved left side
6946but alphabetical values has to be pasted on right side.
4292The text might contain characters shuffled like hlep or dfeintino or even
14381meaningless words combined together.
"all the numbers has to be moved left side but numerical values has to be pasted o right side" ?!?!?! – Leaky Nun – 2016-05-25T10:28:32.023
numbers to leftside and alphabets to right side in each line? Please post a couple of test cases complete with output and including several lines. Also, by numbers do you mean digits or sets of contiguous digits considered as a unit? In the latter case, can the number contain minus sign, decimal point, exponential notation? Voting to close as unclear. I'll remove my vote when clarified – Luis Mendo – 2016-05-25T10:40:52.260
I will update it. I am new here :) – SibiCoder – 2016-05-25T11:09:11.913
4
@SibiCoder Welcome aboard then! You might want to use the sandbox next time. It's used for posting challenges before doing it here. That way you can get feedback from other users and improve the challenge
– Luis Mendo – 2016-05-25T11:15:00.603In the first output line there is a space missing before the last comma. Also, you should include commas in spec, item 4) – Luis Mendo – 2016-05-25T11:49:58.677
1Using alphabet to mean letter is, I believe, a distinctive of Indian English. – TRiG – 2016-05-25T14:35:50.137
Sorry if this is obvious but I am new here. Does this need to be a function or a program? – AstroDan – 2016-05-25T15:25:45.160
2@AstroDan Both are allowed by default. – Adnan – 2016-05-25T15:26:49.397
@AstroDan Welcome to the site! I hope you have a lot of fun here.
:)
– James – 2016-05-25T16:54:03.6972Seems pretty clear now. @close-voters - do you think you can retract your votes now? – Digital Trauma – 2016-05-25T17:44:07.187
@DigitalTrauma, I think the test cases contradict the spec, which requires the alphabetic letters to be moved to the end of the line. The four (out of five) test cases which have punctuation don't respect that requirement. – Peter Taylor – 2016-05-25T20:27:58.370
@PeterTaylor I would say Rule #2 (and the absence of other rules in the same template) clarifies this over what the introductory paragraph says. But perhaps I'm over-relying on the absence of other rules bit. – Digital Trauma – 2016-05-25T20:52:25.537
What happened to the space after
like
in the first line of the example? – msh210 – 2016-05-25T22:17:04.920@PeterTaylor Couldn't we just edit the test cases? It's pretty obvious where they're unclear. – James – 2016-05-26T02:58:11.060
1Fixed the first test case, since it was most likely nothing more than a typo. I am voting to reopen this post. – Bassdrop Cumberwubwubwub – 2016-05-26T08:44:34.047