proof Jow Forums is nothing but cs freshmen
Proof Jow Forums is nothing but cs freshmen
Other urls found in this thread:
sciencealert.com
0x0.st
youtube.com
twitter.com
true computer science is not just programming.
it's
>Jow Forums - Technology
not
>Jow Forums - Programming
imbecile
Do your own homework.
I'm majoring in English.
Not interesting enough of a problem. In fact I've seen it multiple times before. Yawn.
Sure thing, dude. Bet it takes you O(n^2) time to solve it.
isn't CS a subset of math?
I'll have you know my brain operates on at LEAST O(n^7)
back to /sci/ with your pseudo intellectual friends
yes, or at least it's supposed to be.
> Do my algorithms homework, goy
You take us for fools?
Do your own homework you bastard!
Ughhh you find identical characters first, and then work out from there by looking next character and comparing it to the group, if one of the group stands out, discard. Not going to come up with complete algorithm you lazy fuck, work from there.
People unironiclly believe Jow Forums is just for Linux and programming
I guess it makes sense as both of those are the cheapest things you can get into technology wise and Jow Forums has a huge population of poorfags
They are also the most interesting topics in technology outside of engineering (a.k.a., real engineering, like the kind where you use differential equations). You can always go to /reddit/ if you need a safe space to talk about the best smartphone for tiktok.
It takes me at least O(2^n) if not worse.
I'd make an array.
Append 1st character
Move to 2nd character
Append 2nd character
Append 1st and 2nd character
Move to 3rd character
Append 3rd character
Append 2nd and 3rd character
Append 1st 2nd and 3rd character
Then move down the string doing this.
Then sort the array alphabetically (using a built in function).
Then iterate through the array.
Using a function I made called match(), It stores the text and number of times it repeats. If it is a higher number than 0 or whatever the past highest number is, it replaces that number with the new counter and changes the stored repeated text phrase.
I'm just a hobbyist and know there's a better solution as mine's probably the worst way to do it algorithmically.
const strC = (str => {
const ml = Math.floor(str.length / 2);
let cl = 0, strBuf = '';
for(let i = 0; i != str.length - 1; ++i){
for(let j = 1; j != ml + 1; ++j){
const buf = str.slice(i, i + j);
const re = new RegExp(buf,'g');
if(str.match(re).length > 1 && j > cl){
cl = j;
strBuf = buf;
}
}
}
return strBuf;
});
what proof? all you did was post a leetcode tier problem?
I don't really feel like spending the 20-30 minutes, or more possibly, on a problem I don't encounter frequently.
1) define a dumb recursive solution that explains some inputs and the expected outputs at each stage
2) work out the recurrence relationship and begin using experience to simplify the problem into a closed solution.
3) chip at it til satisfied with result.
niggger
std::string niggers(std::string str) {
if (str == "aaaaaa") return "aaa";
if (str == "rsrwsrsrwb") return "rsrw";
// undefined behaviour
}
>#include
Excuse me what the fuck are you doing
the quickest way would be to look for the largest possible ones first and if you can't find any, decrease the size of your match section by one character and then keep reducing it if you still can't find any
i have a super computer
and?
Oh yeah, well I have a super duper computer.
just use a hashmap, iterate over the string in 1 to n/2 size slices and return the one with the max count
i did your homework now just implement it yourself retard
we won faggot. Jow Forums is consumer technology now.
go to reddit with your shitty nigger ""engineering""
and it worked. so so what? its a proof of concept why not just include everything?
Please realize your solution is shit
I would Google this and find the already thoroughly documented answers and compare their performance, then implement one of the solutions in the language I'm working with.
Why do you think knowing a specific algorithm to solve this specific problem would be indicative of programming skill?
It's non standard, fucking idiot
Very based
Based. I bet you're self taught, am I right?
my solution worked. wheres yours?
Having a bad solution is even worse than having no solution, so I win.
>knowing
You're supposed to create an algorithm for that, stupid pajeet
The TDD approach. This clearly does what needs doing. Very easy to extend too, the perfect solution.
10/10.
Noob here. I think a riddle is only interesting if it's an actual, real problem. This here sciencealert.com
i'm a non programmer brainlet but here's what i came up with:
>divide the string by the lowest amount posible, in a manner that the highest ammount of characters are in groups of identical size(for example, divide aaasssd in three so that it's aaa + sss + d)
>see if there are identical groups
>see if those groups are repeated at least twice
>if no, increase the division number (using the same logic) then repeat (so the groups would now be aa + as + ss +d)
>if yes, print the group
tell me what i did wrong please
Fine, I didn't know what a suffix tree was and had only heard of it once before
oh shit wait i've just realized.
you also have to try every possible way of dividing the string (so aaasssd could also be divided as a + aas + ssd)
damn i'm stupid
According to Cracking the coding interview, you're hired.
I hate O(n^2)
Easy
void FaggotOP (void) {
while(木){tるえ;)0)
return;-1;
}
This. Jow Forumsnewfags have been tricked into doing other people's homework for over a decade. Before that, it was an unspeakable place full of atrocities.
なに?
Just use a suffix trie. What is the problem?
There's a brute force solution that just enumerates all the substrings and counts their number of occurances, that takes poly-time. How the hell are you doing worse than the naive solution?
Shouldn't the first string return "aaaaa"? It occurs twice, first at index 0 and second at index 1
If there's no practical reason to implement something, I'd have to force myself to think about the solution, and I never do that for questions like these.
i uhhh tried my best? JavaScript: 0x0.st
Meh. It does the job and it's poly-time.
ITT OP tricks Jow Forums into finishing his assignment
Doesnt look like it
I'm gonna remember this when I go back to college. I look forward to you doing all my homework, cucks.
holy mother of all fucking based
nice solutions faggots, now solve it in one line using vimscript
/pg/ - programming board when?
Seems to work okay...
import sys
def string_intersector(length_of_substr, string):
for i in range(len(string)-length_of_substr):
substr = string[i:i+length_of_substr]
for k in range(len(string)):
if k == i:
continue
if k+length_of_substr > len(string) + 1:
continue
print('Substring: '+substr)
print('String: '+string[k:k+length_of_substr])
if substr == string[k:k+length_of_substr]:
sys.exit('Solution-> '+substr)
return intersect
## Main
string = input("String here: ")
# Initial number of pieces to 'cut' string into
intersect = 2
# Calculate length of substr to begin with
remainder = 0
length_of_substr = int(len(string)/intersect)
if len(string)%intersect > 0:
remainder = 1
length_of_substr += remainder
# Iterate through string
while length_of_substr > 0:
string_intersector(length_of_substr,string)
length_of_substr -= 1
haha he say the funny nigger word haha (le upvotes)
Am a brainlet, explain what's wrong with the brute-force solution (checking every possible substring against the original string)?
We used to have a text board /prog/ but it was a place filled with experts who required payment for services rendered.
Because your meant to choose the most common, not any that repeats more than twice
>choose the most common
>question asks for largest
Surely the longest section that appears twice in "aaaaaa" is "aaaaa"? It doesn't specify non-overlapping.
It's implied that this is the case.
Everything else get deleted in minutes. Mods are retarded. It's brand wars and SHIT/trannux only.
Fun challenge. Optimization is shit though.
why parenthesis outside the function
basedscript lol
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication10
{
class Program
{
static bool eq(string s,int afrom, int bfrom,int len)
{
for(int i=0;i0;len--)
{
if (res != null)
break;
for(int aoffset=0;aoffset
It's not, modern computers can solve O(N^2) problems with ease. You could replace all sorting algorithms in glibc and STL with bubblesort and not notice a difference.
I'm used to test functions with IIFE.
Ok niggers what's a sub n^2 solution to this?
This is one of the most retarded posts I've seen this week
Can’t you use a substring search like KMP or Boyer Moore and modify some parsing so it retains a sequence until overwritten by a larger sequence then return that larger sequence? Never used tries but will look into that now.
>proof Jow Forums is nothing but cs freshmen
Aside from this beign an obvious homework thread, apparently OP didn't even bother to read his introductory programming book, since this or similar things are an incredibly common example within the first couple of chapters of almost any text on the subject. And it's also an absolutely trivial exercise.
Prove you aren't a newfag, post.
youtube.com
I did this on my laptop during a train ride. Pls no bully for slow typing speed it was crowded and tight. Also pls no dox.
Seethe.
Do you think someone dumb enough to post their homework on Jow Forums is smart enough to consider looking for the answer himself?
i'm not even in CS. CS is the worst major you can get.
shoo winjeet
Linux laptops...that's just for people that never have to leave the house. I need more than 2h of runtime with one charge. I leave linux where it belongs: on my servers.
Why did you do this, user?
I had a 7h trainride wtf am I supposed to do? It took my 15min to do this so why not?
keep telling that to yourself, slave
okay buddy
I'd just like to interject for a moment. What you're referring to as Linux,
is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux.
Linux is not an operating system unto itself, but rather another free component
of a fully functioning GNU system made useful by the GNU corelibs, shell
utilities and vital system components comprising a full OS as defined by POSIX.
Many computer users run a modified version of the GNU system every day,
without realizing it. Through a peculiar turn of events, the version of GNU
which is widely used today is often called "Linux", and many of its users are
not aware that it is basically the GNU system, developed by the GNU Project.
There really is a Linux, and these people are using it, but it is just a
part of the system they use. Linux is the kernel: the program in the system
that allocates the machine's resources to the other programs that you run.
The kernel is an essential part of an operating system, but useless by itself;
it can only function in the context of a complete operating system. Linux is
normally used in combination with the GNU operating system: the whole system
is basically GNU with Linux added, or GNU/Linux. All the so-called "Linux"
distributions are really distributions of GNU/Linux.
I am using the linux kernel on my servers. How dare you assume that i use that filthy gnu stuff there? Keep your trash kid. I have high ethical standards and would never use any software that is associated with people like richard stallman.
>the linux kernel
tuk tuk tuk... don't repeat yourself, moron!
i wanted to make it clear that i am not implicitly referring to gnu+linux when calling it linux. In this context calling it the "linux kernel" instead of just "linux" provides much needed clarity. Now fuck off gnu lover and rape apologist.
why would anyone think you were referring to the entire GNU operating system when you mentioned a small part of it?
Because that is a common mistake made by even a lot of tech savy people (and even more retards on Jow Forums)? That common mistake is the entire reason the copypaste in exist. By providing more clarity through redundant terms i try to compensate for a possible lack of knowledge of other participants of this discussion.
no, the common mistake is being redundant in your speech. try fixing your own mistakes before you try to "compensate for a possible lack of knowledge of other participants"
No, it is a mistake to remove pratical information in the form of redundancy from your texts if a common mistake of other participants is to be expected and can be fixed this way.
Now stop trying to find an error where there is none, it gets ridiculous.
Also this is a (casual) written discussion, not a spoken one you imbecile. If you like being short and specific (as well as having to correct people after they misunderstand you) then be my guest, but please use the correct terminology.
>please use the correct terminology
funny coming from the "man" who doesn't do so himself