+ 4

Failed 2 out of 5 test cases, how can I improve my code ?

Explanation: If you remove everything that isn't a letter or space from the original message and flip it around, you get "hello world" using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Textsing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { string input = Console.ReadLine(); var output = new char[] {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','.','_'}; var result = string.Join("",(from x in input.ToCharArray() where output.Contains(x) select x.ToString()).ToArray()); char[] reverse = result.ToCharArray(); Array.Reverse(reverse); string reversed = new string(reverse); Console.WriteLine(reversed); } } }

24th Apr 2020, 4:02 PM
Joseph Oritseweyinmi
Joseph Oritseweyinmi - avatar
21 Respostas
+ 9
Exactly, you should keep space, not fullstop and underscore. So your output array is containing the wrong elements, and so the output.Contains(x) is doing wrong screening. See?
24th Apr 2020, 4:30 PM
Gordon
Gordon - avatar
+ 5
Go to the question page, read the text in yellow "Explanation" box, copy and paste it here.
24th Apr 2020, 4:17 PM
Gordon
Gordon - avatar
+ 3
Hi Bro, Just modify space and try to Avoid fullstop
26th Apr 2020, 11:45 AM
🄲🅄🅃🄴 🄲🄾🄳🄴🅁
🄲🅄🅃🄴 🄲🄾🄳🄴🅁 - avatar
+ 2
You need to read the question carefully. Currently your output array contains two non-valid elements and is missing one necessary elements. Don't guess the rules by your assumptions, read the input-output example in specification and also the yellow Notes textbox.
24th Apr 2020, 4:15 PM
Gordon
Gordon - avatar
+ 2
So, what does the yellow text say? What is its exact wordings? Copy and paste its original wordings here.
24th Apr 2020, 4:26 PM
Gordon
Gordon - avatar
+ 2
No, you did it wrongly. Apart from letters, what should be kept?
24th Apr 2020, 4:28 PM
Gordon
Gordon - avatar
+ 2
Thank you Gordon.
24th Apr 2020, 4:31 PM
Joseph Oritseweyinmi
Joseph Oritseweyinmi - avatar
+ 2
By practicing
26th Apr 2020, 10:17 AM
Ninad Ganesh Karde
Ninad Ganesh Karde - avatar
+ 1
Why do you mark your own answer as Best Answer?
24th Apr 2020, 4:50 PM
Gordon
Gordon - avatar
+ 1
Sorry, mistake.
24th Apr 2020, 4:51 PM
Joseph Oritseweyinmi
Joseph Oritseweyinmi - avatar
+ 1
Joseph Oritseweyinmi congratz on your dedication. Keep it like that and you're gonna go far.
24th Apr 2020, 9:47 PM
Antônio Gabriel Zeni Landim
Antônio Gabriel Zeni Landim - avatar
+ 1
Do practice daily, make note, Study new things daily and start challenge others
26th Apr 2020, 2:58 PM
Arun Nain
Arun Nain - avatar
0
I don't understand.
24th Apr 2020, 4:16 PM
Joseph Oritseweyinmi
Joseph Oritseweyinmi - avatar
0
Ok Gordon I'll do it.
24th Apr 2020, 4:19 PM
Joseph Oritseweyinmi
Joseph Oritseweyinmi - avatar
0
Gordon I've done it.
24th Apr 2020, 4:23 PM
Joseph Oritseweyinmi
Joseph Oritseweyinmi - avatar
0
I've already done it.
24th Apr 2020, 4:27 PM
Joseph Oritseweyinmi
Joseph Oritseweyinmi - avatar
0
Space!.
24th Apr 2020, 4:29 PM
Joseph Oritseweyinmi
Joseph Oritseweyinmi - avatar
0
Try to open another browsers and dowland wit link.
26th Apr 2020, 2:35 AM
NURIK
NURIK - avatar
0
Add a space to the array and remove the '.' (dot) one
26th Apr 2020, 11:03 AM
Ayan Das
Ayan Das - avatar
0
Its so easy
26th Apr 2020, 11:40 AM
Shams Urahman Rashidy
Shams Urahman Rashidy - avatar