Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
MIXED CONTENT - string and numbers separation in a large string
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 /* Quiz on Code-Eval You have a string of words and digits divided by comma. Write a program which separates words with digits. You shouldn't change the order elements. INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Input example is the following 8,33,21,0,16,50,37,0,melon,7,apricot,peach,pineapple,17,21 24,13,14,43,41 OUTPUT SAMPLE: melon,apricot,peach,pineapple|8,33,21,0,16,50,37,0,7,17,21 24,13,14,43,41 As you cas see you need to output the same input string if it has words only or digits only. ================================================================ */ using System; using System.Linq; using System.Collections.Generic; namespace Rextester { public class Program { public static void Main(string[] args) { for(int i=0;i<2;i++){ string[] l=Console.ReadLine().Split(','); List<string> fruits=new List<string>(); List<string> digits=new List<string>(); foreach(string s in l) { if(s.All(char.IsDigit)) digits.Add(s); else fruits.Add(s); } string output=""; if(fruits.Count()>0) output=string.Join(",",fruits); if(fruits.Count()>0&&digits.Count()>0) output+="|"+string.Join(",",digits); if(fruits.Count()==0&&digits.Count()>0) output+=string.Join(",",digits); Console.WriteLine(output); } } } }
run
|
edit
|
history
|
help
0
Create URL Safe and Cryptographically Strong Short GUID
Array Comparison
ö1
services
Problem: rstring
asdfghyjuytt4wed
Selection Sort
hacktonxx
Kz
code for part 4 gogoaim