160 points · by jazzychad · 12y ago · 118 comments
But seriously, spacing would be awesome.
I'm sure Stripe has a similar story.
We all agree, more careful spacing would be great. Oh well! :)
Props in general, I just feel like Level1 was kind of a brick wall for me.
It is a bit tricky because you're competing against random timings for the bot miners, but you need to mine before the bots do, so you need to speed up finding a commit hash, then do the commit. I hope that is useful without giving too much away.
remote: > Your submission has been placed in the queue. remote: > Kicking off a build for your submission (running `./build.sh`). remote: > `./build.sh` succeeded remote: > Kicking off 3 trials. Here goes... remote: > Started running Trial 0 remote: > Started running Trial 1 remote: > ERROR: There was an internal error scoring Trial 0. If this error persists, please let us know at ctf@stripe.com and include the following error token: err_3MRLt7sxWqqD4C To lvl0-xkzdabbt@stripe-ctf.com:level0 7fcfd3d..17d0e35 master -> master
My code looks to be working because the test ./test/harness says that tests pass.
I don't know Ruby, but I can guess what it is doing basically:
1. Read a list of words from a file with an input path or a default path
2. Take the runtime input from the user with any number of words before carriage return (I guess the words are separated by spaces)
3. Do a loop to compare each of the input words to lower case against the words in the list loaded from the file. If there is a match print out the original word, other wise print out something wrap up the word.
It's a O(NxM) algorithm. If the data set is small, we won't see to much difference. Otherwise, we need to concern about better algorithm to improve the speed.
1. Sort the list from the file (remove duplicates)
2. Always check the either half to reduce the number of checking in the list
3. Sort the input list (save the number of duplicates)
4. Print the duplicates directly without comparison again etc.
This way the runtime can be improved to O(N*lg M). This may not be the best algorithm. I'd like to hear from you about better solutions.
You can google it more. I don't have time to find out about the Big O footprint for both now. Here is one link discussing about it:
http://stackoverflow.com/questions/7975802/when-to-use-hashm...
We usually implement code on the application level, so we don't really care about the underlying algorithms. But if we have to implement on the system level, we do care about the how to manipulate the memory and number of executions, like Big O.
I don't see the original code is a huge issue per se which requires 19 levels? of improvement? I'm curious about how you guys move on though. Will appreciate if you can keep post your solution and progress.
I guess at the end of the entire program, people may learn how to send the query to multiple indexing servers in a concurrent (I prefer this than "distributed") system and then gather together of all the results. At the end of it, it shows how advanced algorithms Google search engine is used to index terabyte of data.
Is that the ultimate solution for a web of data? Take a look of the discussion: http://bit.ly/1f7xIve
From the "best" score I was worse than it by 150 or something. Not that I care really.
Edit: And to be clear, you should use the hash solution anyway since it is O(n+m).
http://stackoverflow.com/questions/1055243/is-a-java-hashmap...
But I couldn't agree with you about O(n+m) because we cannot hash on the input set as well since that way we will lost the sequence order. Then the caching may help or use LinkedHashmap.
It does not affect the Big O level I mentioned in sorting of the word list loaded from the file. Looks like it's the necessary step.
It looks like you have another in-progress Git operation, and we limit you to one concurrent operation. Waiting 2s (attempt 1/3) It looks like you have another in-progress Git operation, and we limit you to one concurrent operation. Waiting 2s (attempt 2/3) It looks like you have another in-progress Git operation, and we limit you to one concurrent operation. Waiting 2s (attempt 3/3) ERROR: Timed out waiting for your other Git operation to complete. Try again once it has finished. fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
first push:
git push warning: push.default is unset; its implicit value is changing in Git 2.0 from 'matching' to 'simple'. To squelch this message and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use: git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)Counting objects: 37, done. Delta compression using up to 4 threads. Compressing objects: 100% (33/33), done. Writing objects: 100% (36/36), 897.66 KiB | 0 bytes/s, done. Total 36 (delta 4), reused 14 (delta 0)
When I make an account.
EDIT I probably already had one. Maybe I failed level -1 for that.
version `GLIBCXX_3.4.18' not found (required by ./level0)
:-(And then the output of ldd on ./level0
linux-vdso.so.1 => (0x00007fff5cdca000) libstdc++.so.6 => /lib64/libstdc++.so.6 (0x0000003337400000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003333c00000) libc.so.6 => /lib64/libc.so.6 (0x0000003332800000) libm.so.6 => /lib64/libm.so.6 (0x0000003332c00000) /lib64/ld-linux-x86-64.so.2 (0x0000003332400000)
I know the problem is I am still dynamically linking glibc and whatever system I am running on doesn't have a new enough glibc. I am going to take another crack at it later and try to get it fully statically linked, but once you get to statically linking the C runtime I need to invoke my google foo and it is more time then I had on my lunch break.
contents = ARGV.length > 1 ? File.read(ARGV[1]) : $stdin.read
That's just allowing you to send the test files in on the command line. From there, you can measure the time using PowerShell's Measure-Command like so:
Measure-Command {ruby .\level0 "test/data/words" "long.txt"}
Assuming ruby is in your PATH and the "test/data/words" is a renamed words dictionary file. It's a little work but you can definitely do it on Windows. I'm working on getting the python test harness to work on Windows.
It's a bit of a shame the test harness isn't Windows compatible; it's rather small, and it doesn't look like the fixes required would have been very difficult.
[error] import java.nio.file._
Isn't it supposed to start with a TXT file and a sample?
meh.