Find the longest repeating character in a sorted string
String containing substring problem
This solution was built using theCoding Ground^] online IDE. Here is a link tothe solution^] where you can compile and run it.
This content, along with any associated source code and files, is licensed underThe Code Project Open License (CPOL)
But I would have to implement HashSet and Dictionary myself and I dont think Im up to that at this time.Graeme_Grant29-Jan-17 21:25pmPascals type StrDict: Array of Array of String;… Then, to use: var DictName: StrDict; ? But then again, Im only new to the language…
Enjoy! :)PermalinkPosted28-Jan-17 12:39pmGraeme_Grant48.3KUpdated28-Jan-17 12:45pmv2CommentsBryian Tan28-Jan-17 18:51pmTwo solution from Graeme_Grant!!! Look like you are the only participant !!!! 🙂 anyway congrats on your previous two competitions. You done a great job. I think you getting this one too.Graeme_Grant28-Jan-17 18:53pmThanks Bryian!
Coding challenge: longest substring contained in two strings
PIEBALD.Type.Substring.EnumSubstrings ( Subject [ i ] , shortest ) ) System.Collections.Generic.HashSetint v ;
The PIEBALD.Type.Substring class is similar to the StringSlice class I used for the Bad Word Filter challenge, but with more bells and whistles.
C program for length of the longest run in the string
I have VAX BASIC, HP BASIC, and Turbo BASIC…PIEBALDconsult27-Jan-17 18:45pmWell, how are BCPL and B considered C-like? They came first! (And second.)PIEBALDconsult27-Jan-17 18:19pmI think I have Pascal on one of my AlphaServers. I have a license. I also have a license for COBOL…Graeme_Grant28-Jan-17 5:28amThis may help:Free Turbo Pascal for Windows 10^] – have not tried it thought…PIEBALDconsult28-Jan-17 10:04am:cough: Win 7 :cough:Graeme_Grant28-Jan-17 11:27amIt is amazing what you can find with Google when one uses it… 😉
System.Collections.Generic.HashSetint() ; temp [ s ].Add (
Okay, as F is acceptable, here is an F version that will accept multiple inputs to be compared and return the Longest common substring. I am using the challenges text (including nulls) as the input for testing… 😉
Find matching substring from two strings
Dont tell someone to read the manual. Chances are they have and dont get it. Provide an answer or move on to the next question.
Lets work to help developers, not make them feel stupid.
sh-4.3$ fpc -vw main.pas Free Pascal Compiler version 2.6.4 [2015/06/17] for x86_64 Copyright (c) 1993-2014 by Florian Klaempfl and others Target OS: Linux for x86-64 Compiling main.pas Linking main /usr/bin/ld: warning: link.res contains output sections; did you forget -T? 209 lines compiled, 0.1 sec sh-4.3$ main processing… Matches found: 5564 Matches found: 253 Matches found: 147 Longest Substring: ings sh-4.3$
As if F was not as far away from normal for me (second attempt ever), here is a FreePascal version for PIEBALDConsultant. This is my first attempt at programming with this language, so please be gentle as I am sure there is plenty of room for improvement…
( kvp.Value.Count == Subject.Length ) result.Add ( kvp.Key.ToString() ) ;
We were not given anything to work with, so yes, it was a block of text, not just a bunch of strings in an array. The challenges own text appeared to be the best candidate. This allows for any number of strings to be used, not just two (2). The first thing I do is convert it into a string array.
and fix the problem. Insults are not welcome.
( System.Collections.Generic.KeyValuePairPIEBALD.Type.Substring,System.Collections.Generic.HashSetint kvp
Graeme_Grant again gets the guernsey for his outstanding and, Im assuming, time consuming treatment of last weeks problem. Noice.Posted27-Jan-17 4:25amUpdated5-Feb-17 16:41pmAdd a SolutionCommentsGraeme_Grant27-Jan-17 10:36amThanks Chris. But not really … tinkering while watching a movie…
Dynamically parsing substrings out of strings
 Subject ) System.Collections.Generic.Liststring result =
Melatonin for jetlag but it doesnt work.
Understand that English isnt everyones first language so be lenient of bad spelling and grammar.
PIEBALD.Type.Substring.EnumSubstrings ( Subject [
Mine [Pascal implementation] was based off the HashSet as a concept as it was based off the F implementation (that was prototyped in a few minutes in C) that in fact uses a HashSet. ;)Graeme_Grant29-Jan-17 21:29pmAlso, Pascal lacks many of the language tools found in the DotNet Framework, so you will also need to implement them too …. things like sorting, manually removing null entries from split strings, HashSets, etc…PIEBALDconsult29-Jan-17 23:55pmWell, if I knew how to access .net from Pascal… :cool:Graeme_Grant30-Jan-17 2:18amyes, modern-day devs are spoiled…Graeme_Grant29-Jan-17 21:35pmA quick hint… while doing the Pascal version, I found that a HashSet is not required.PIEBALDconsult29-Jan-17 23:54pmMy algorithm uses it. If I could be assured of 64 or fewer strings, Id use bitwise operators on an Int64 instead.
Your solution should take into account null strings and strings whose length is limited only by available storage.
If a question is poorly phrased then either ask for clarification, ignore it, or
Graeme_Grant28-Jan-17 15:19pmfair enuf…Graeme_Grant28-Jan-17 18:51pmI found the FreePascal online IDE a couple of hours ago, so as I have never done Pascal before, I gave it a go and you can see what I did below. Oh, how I missed my favorite IDE & the power of the .Net frameworks!PIEBALDconsult28-Jan-17 20:29pmYeah, I loved Pascal back in the day, particularly Turbo, but once I became comfortable with C I stopped using it. I cant even read my Pascal programs from college anymore.Graeme_Grant29-Jan-17 21:24pm[wrong place, so moved]PIEBALDconsult29-Jan-17 20:52pmOn the other hand…
I have a working implementation in C to prove an algorithm I devised.
Please subscribe me to the CodeProject newslettersSubmit your solution!
Yes, the classic LCS problem. Given two or more strings find the longest common substring in each string.
*How to Run Turbo Pascal v7.0 on Windows 7/8^]PIEBALDconsult28-Jan-17 12:59pmIf I wanted it Id have it already. I used to use Turbo Pascal (and Turbo C), but I dont anymore.
how to display the longest palindrome in a string of characters?
System.Collections.Generic.Liststring() ; System.Collections.Generic.DictionaryPIEBALD.Type.Substring,System.Collections.Generic.HashSetint temp =
Subject [ i ].Length ) shortest = Subject [ i ].Length ;
The second one was only after a chat with PIEBALDConsultant… Never done Pascal before so I thought that Id try it.
A couple of around each string would have been clearer to me.
So looking at your Link, R is out but F & PowerShell are okay then ;)ppolymorphe27-Jan-17 15:02pmWhat is supposed to be the result ? Just the length ? The substring ?Graeme_Grant27-Jan-17 15:53pmfind the longest common substring .. my guess is the common substring…Chris Maunder27-Jan-17 16:58pmYes.Jon McKee27-Jan-17 16:43pmPerl is considered C-based but F isnt? Thats a little odd tbh. If anything Perl has less in common with C than F. Also that link includes B which was the precursor to C which I find baffling.Graeme_Grant27-Jan-17 18:07pmId blow the dust off my C64 but basic was not allowed…Jon McKee27-Jan-17 18:40pmHe specified VB. Didnt say anything about just BASIC ;)Graeme_Grant27-Jan-17 18:57pmI planted my flag with F (second time Ive every used it apart from 3 weeks ago – was/is a steep learning curve)… Busy week ahead though, will have to see how it pans out and if I can find the old C64…PIEBALDconsult27-Jan-17 18:42pmVB is not allowed, real BASIC is.
Turbo Pascal (5.5+) has OOP, and HP Pascal probably doesnt — I learned data structures on VAX/DEC/HP Pascal back in the 80s.
Find length of longest substring with all 1s in a binary string with k queries