|
ufarn posted:It's only for some basic benchmarking for image compression and the like, so something more nested like du/ds seems too elaborate. I just saw some people doing it in their tests and wondered how they did it, and almost assumed it was a straightforward UNIX command or pipe. Something like this, which takes the name of the file to use as the reference for the 100% size as an argument, seems to work, although I'm terrible at shell scripting and don't understand awk syntax at all and it will probably burn down your computer. code:
mystes fucked around with this message at 21:32 on Feb 18, 2018 |
# ? Feb 18, 2018 21:27 |
|
|
# ? Jun 9, 2024 06:33 |
|
ultrafilter posted:How exactly are you defining "right sibling"? I think that if you have the definition nailed down precisely, then it's much easier to write the code. Same depth, one "unit" to the right. I don't know, ask Amazon. Even with nielsm's help, I have no idea how to solve it. I think I need a course to help me learn data structures and algorithms, especially graph poo poo. Anyone got recommendations for a MOOC I can take or something? I learn best under structure.
|
# ? Feb 19, 2018 18:23 |
Here's an untested solution to the right sibling problem in Python: https://puu.sh/zrdEv/a6d725d8d5.txt
|
|
# ? Feb 19, 2018 18:48 |
|
Pollyanna posted:Same depth, one "unit" to the right. I don't know, ask Amazon. The point of the problem is to be able to define "right sibling" rigorously! Amazon ain't gonna tell you. Hint: how do you define whether something is to the left or the right of something else? What does "1 unit" translate to?
|
# ? Feb 19, 2018 18:56 |
|
Suspicious Dish posted:The point of the problem is to be able to define "right sibling" rigorously! Amazon ain't gonna tell you. I defined right sibling as rigorously as I could (I have no idea what I'm doing in graph problems), but whether or not that definition is correct/"okay" is up to the interviewer as they are judging me. I did make sure to hash out the definition alongside the interviewer and make sure they understood where I was going. Regardless, this is a set of right siblings: code:
5 is a right sibling of 4. 6 is a right sibling of 5. nielsm posted:Here's an untested solution to the right sibling problem in Python: https://puu.sh/zrdEv/a6d725d8d5.txt So you do need to manually keep track of the level you've gone down/depth? You can't put together an algorithm that doesn't need to know about the depth? That's actually quite complicated...but I'll bash my head against this until I understand.
|
# ? Feb 19, 2018 19:13 |
|
Pollyanna posted:Same depth, one "unit" to the right. I don't know, ask Amazon. Here's a full tree (I tried ok) with all slots filled pre:A / \ / \ / \ B C / \ / \ / \ / \ D E F G / \ / \ / \ / \ H I J K L M N O
So for H, that's easy - left node, get the right node of your parent, that's I For I - its a right node, need to find the RS of your parent (D) For D - it's a left node, easy again - right child of the parent is E Back to I - the left child of E is J, so that's your RS of I Try it with K, it's basically a recursive algorithm, based on a couple of simple rules e- just to pseudocode this since it's probably clearer code:
baka kaba fucked around with this message at 20:09 on Feb 19, 2018 |
# ? Feb 19, 2018 19:16 |
|
As asked, this is a little bit of a bad question, because there is a standard notion of when two nodes are siblings and that's not what's being asked for here. I would've lost some time clarifying exactly what the interviewer was asking for. (Two nodes are siblings if and only if they have the same parent, in case you're wondering.) Pollyanna posted:So you do need to manually keep track of the level you've gone down/depth? You can't put together an algorithm that doesn't need to know about the depth? That's actually quite complicated...but I'll bash my head against this until I understand. Yeah. What the interviewer seems to be asking for here is the least value in the tree such that it's greater than a given value and that the node storing it is at the same depth as the node storing the given value. There's no way to calculate that without somehow storing depth. ultrafilter fucked around with this message at 19:18 on Feb 19, 2018 |
# ? Feb 19, 2018 19:16 |
|
Pollyanna posted:So you do need to manually keep track of the level you've gone down/depth? You can't put together an algorithm that doesn't need to know about the depth? That's actually quite complicated...but I'll bash my head against this until I understand. You could probably come up with an algorithm that implicitly keeps track of depth, for example a breadth-first search that starts from the top of the tree. But that would have poor memory scaling (you need to keep an entire depth level of the tree in your search stack at a time) and runtime scaling (you examine an awful lot of the tree that's completely irrelevant to your search, since you don't start from the node you want the neighbor of), so if a candidate handed me that as a solution, the obvious next question would be to ask them to come up with a solution with better performance.
|
# ? Feb 19, 2018 19:17 |
|
You can also track depth implicitly by the depth of your call stack frame (yay recursion). One other way to phrase nielsm's intuition: make a single "right turn" the first time you can, which is when you arrive from a left child. If you get to the root and you arrived from the right, you can't turn right, since otherwise you would have done so already, so return null. From there, traverse down the rest of the tree left-first. If your tree has gaps (e.g. a node with one child), treat the child as a right-child on the way up (don't try to turn right), and a left-node on the way down (take the only path you can).
|
# ? Feb 19, 2018 19:28 |
Pollyanna posted:3 is a right sibling of 2. 1) Something with common parents and left/right side relationships. 2) Nodes B is the next right sibling to node A if and only if nodes A and B have a common parent where node A is on the left branch and node B on the right branch... Pollyanna posted:So you do need to manually keep track of the level you've gone down/depth? You can't put together an algorithm that doesn't need to know about the depth? That's actually quite complicated...but I'll bash my head against this until I understand. You can probably write a single recursive function that solves it without explicitly having a "depth" variable counting, but then you'd still implicitly keep track of the depth simply by the fact that there is a stack whose depth you can count. Whoops yeah there's a bug I didn't think of. nielsm fucked around with this message at 19:30 on Feb 19, 2018 |
|
# ? Feb 19, 2018 19:28 |
|
Seriously, genuinely, all I was given was this:quote:
Maybe I hosed up by calling them siblings, I dunno. As for the responses, I will reflect on this problem and wrap my head around it.
|
# ? Feb 19, 2018 20:10 |
|
Honestly there's so many questions about that diagram, it seems like a big part of them posing it is seeing how you work through it, what questions you ask and how you come to some kind of concrete spec to implement e- /4\D+(\d+)/ baka kaba fucked around with this message at 20:28 on Feb 19, 2018 |
# ? Feb 19, 2018 20:19 |
|
baka kaba posted:Honestly there's so many questions about that diagram, it seems like a big part of them posing it is seeing how you work through it, what questions you ask and how you come to some kind of concrete spec to implement writing a function to print the tree with annotations on L and R nodes then a sed script sounds like an awesome way to solve the problem while likely failing the interview. on the plus side, it would be a solution they hadn't seen before.
|
# ? Feb 20, 2018 13:14 |
|
I want to copy text from cells in a google doc spreasheet but it says: "Options to download, print, and copy have been disabled on this file." I use a particular spreadsheet a lot at work and I often have to copy the text from the cells and put it in another tab to fill out forms. To do this, I've been doing ctrl+c on the text in the formula bar, or manually typing what's in the cell. Obviously I don't "own" this file, so is there a way around this with a google spreadsheet api? Things I've tried so far: spreadsheet api: This looked promising https://stackoverflow.com/questions/4509336/how-to-copy-a-row-from-one-google-spreadsheet-to-another-google-spreadsheet-usin but when I typed "var ss = SpreadsheetApp.getActiveSpreadsheet();" into the console, I got "VM298:1 Uncaught ReferenceError: SpreadsheetApp is not defined at <anonymous>:1:10" inspecting html element: I can't seem to find the data within the cells, so I don't think I'd be able to copy data from a range of cells based on the html elements. I'm probably going to try this though: If I highlight a single cell, the text in the cell appears in the formula bar. I can find that text using html id t-formula-bar-input. Then I could write a script to copy/append the data into a string, repeat the process for every cell I need, and then copy the string to the clipboard. ^sorry about that; I came up with that idea as I was writing this post down. I guess my question remains: can I use an api or something to copy data from a range of cells in a google spreadsheet that has restrictions on downloading, printing, and copying.
|
# ? Feb 22, 2018 04:18 |
|
Have you considered asking whoever owns the sheet to give you less-restricted access?
|
# ? Feb 22, 2018 04:24 |
|
TooMuchAbstraction posted:Have you considered asking whoever owns the sheet to give you less-restricted access? I guess I could try that too.
|
# ? Feb 22, 2018 04:37 |
|
Hey dudS. Learning C. For context, I'm fluent N Python, A modern JS. So far, it seems similar to Python, but W curly bracS, semicolons, verbose loops, enforcD type decs, A fewer/more-basic builtin funcNs A data structurS. (ie doesn't have neat thGs like comprehensions, map/filter, loads F helpR methods etc) FM WT I've heard, it's supposD to B much more difficult TN this cursory examinaN indicatS; ie loads F memory-management etc. My suspicion is TT TS memory-management liS in T finR-points F pointers/malloc/free. Is TS T case? WT else am I missG? Dominoes fucked around with this message at 14:42 on Feb 23, 2018 |
# ? Feb 23, 2018 14:04 |
|
Dominoes posted:Hey dudS. Learning C. For context, I'm fluent N Python, A modern JS. A keyboard.
|
# ? Feb 23, 2018 14:56 |
|
Uh that post wasn't like that before. C exposure works fast huh
|
# ? Feb 23, 2018 15:21 |
|
Dominoes posted:Hey dudS. Learning C. For context, I'm fluent N Python, A modern JS.
|
# ? Feb 23, 2018 16:26 |
|
I'm working on a system of 1-1mapped, human-readable shorthand using only standard chars; didn't intend it to be this distracting. Unfortunately, it's only saving about 10% of chars.
|
# ? Feb 23, 2018 18:15 |
|
Jst drp ll th vwls
|
# ? Feb 23, 2018 18:20 |
|
Shorter and still easy to read, but has ambiguities. eg 'll' without context could be 'ill'; 'jst' → 'joust'; 'drp' → 'drip', but in this case it's unambiguous. I'm bills dip on a linked lust tutorial; abstract, bat note us beed is monads. Dominoes fucked around with this message at 18:33 on Feb 23, 2018 |
# ? Feb 23, 2018 18:24 |
Dominoes posted:I'm working on a system of 1-1mapped, human-readable shorthand using only standard chars; didn't intend it to be this distracting. Unfortunately, it's only saving about 10% of chars. premature optimization...
|
|
# ? Feb 23, 2018 18:32 |
|
Yeah but like, you're using T for The Tha Thi and also ending t's too. You could just address ambiguities where they appear, right? I mean I'm guessing there's a ton of analysis and research on this kind of thing anyway. I wonder if anyone's made a compression algorithm based on that observation taht sectneens are rbladee if you jblume up the wdros but keep the fsrit and lsat lrtetes in pcale
|
# ? Feb 23, 2018 18:37 |
|
baka kaba posted:I mean I'm guessing there's a ton of analysis and research on this kind of thing anyway. I wonder if anyone's made a compression algorithm based on that observation taht sectneens are rbladee if you jblume up the wdros but keep the fsrit and lsat lrtetes in pcale The value in compressing visual text tends to be slim to none, especially considering how badly it tends to gently caress up non-native or dyslexic readers.
|
# ? Feb 23, 2018 19:02 |
|
Hey I didn't say it would be good or anything! I was just wondering if being able to reduce the middle of words to a set of unordered characters would make for good pattern-based compression
|
# ? Feb 23, 2018 19:11 |
|
Pollyanna posted:Anyone got recommendations for a MOOC I can take or something? I learn best under structure. You should know all of this: https://www.coursera.org/specializations/data-structures-algorithms
|
# ? Feb 24, 2018 01:34 |
|
https://techdevguide.withgoogle.com/ This is also a thing that exists.
|
# ? Feb 24, 2018 02:01 |
|
baka kaba posted:sectneens are rbladee if you jblume up the wdros but keep the fsrit and lsat lrtetes in pcale This is only true if a human hand-scrambles the words. If you actually automate the process the text comes out much less readable. (Which is certainly an interesting observation on its own.)
|
# ? Feb 24, 2018 05:49 |
|
Dumb little question: I have a digitalocean box that runs a number of personal docker services for me. Checking websites, some alerts, things like that. Is there a dumb CI service I can use to automatically deploy docker containers from github with no fuss? Doesn't need to scale, personal use only. Currently when I make a change I git push my changes to github, then ssh into my droplet and git pull then manually restart the container. Ideally, I would like to just git push and have the container get the lastest version and redeploy itself. I've googled but haven't found a good solution, I figure something like this already should already exist?
|
# ? Feb 25, 2018 04:07 |
|
salted hash browns posted:Dumb little question: I have a digitalocean box that runs a number of personal docker services for me. Checking websites, some alerts, things like that. Is there a dumb CI service I can use to automatically deploy docker containers from github with no fuss? Doesn't need to scale, personal use only. cron job to git pull and check head commit hash against the hash of the branch currently deployed. If different do your redeploy logic. Edit: cron, not corn
|
# ? Feb 28, 2018 06:29 |
|
Yo dudes; looking for thoughts on learning Rust vs C as a low-level language. I'm learning a LL lang to improve my knowledge of programming in general, and to add another tool to the kit. Most guides, in comparison, emphasize Rust's compile-time memory safety over C; and C/++'s widespread-use. My impressions: Rust seems like the nicer language, aided by learning from the faults of earlier languages like C. Eg its package-management system, deliberate decisions to change the way memory-management is handled, addition of functional-language concepts like pattern-matching, implicit type determination in some cases, centralized documentation etc. Is my initial assessment correct? Ie disregarding existing code or career options, Rust is a better language. Related: Rust's official Book, (v2) is the best language-tutorial I've used. Context: I fit in its target demographic, of someone experienced with programming, but not necessary low-level. Dominoes fucked around with this message at 13:10 on Mar 3, 2018 |
# ? Mar 3, 2018 13:04 |
|
Yes, Rust and Go were created specifically to address the shortcomings of C and C++ without sacrificing much in terms of performance or control. I don't know about Rust, but Go even allows you to inline asm, although I'm not sure when it would be a good idea. I saw this talk about it a few days ago and found it really impressive: https://www.youtube.com/watch?v=KINIAgRpkDA&t=1s
|
# ? Mar 3, 2018 14:47 |
|
Not entirely sure what you’re asking. Rust came out decades later and didn’t explicitly reject a lot of the learning people did about programming languages in the meantime, so it’s probably a nicer language to learn. Fewer people use it right now, if that matters to you. In comparison, decades of failsons have learned C and think that’s the only way other people should be allowed to learn too, so you’ll get a lot of harebrained opinions about how vital it is for you to learn C or you’re not a real programmer etc. Those opinions can be discarded. That said, you probably will learn stuff if you pick up C instead of or in addition to Rust.
|
# ? Mar 3, 2018 14:54 |
|
tl;dr: Rust is probably a better choice if you just want to play around a bit, but there are good reasons to learn C. First off, Rust is a systems programming language, but it isn't a particularly low-level language. It's very performance-oriented and it lets you do systems programming, but it still abstracts away a lot of the details of the underlying machine. If you want to peel back that particular veil, C is the right choice. To really see what's going on at a machine level, take a look at Patt & Patel. It would take a while to get through, but you'd learn a lot from doing it. If you're not that interested in the guts of the computer and you just want to dabble in systems programming, then Rust is a better choice just because the various high-level features it has make it a lot more pleasant to program in than C. On the other hand, if you decide that you're interested in doing more, there are good reasons to learn C and eventually C++. First, there's a lot more C and C++ code out there than there is Rust code--probably a few orders of magnitude. In terms of getting a job, Rust is still a little bit of a gamble. Second, as performance-oriented as Rust is, C++ as written by someone who really knows what they're doing is still the gold standard for high performance computing. There are a lot of people trying to get that level of performance out of a higher-level language, but it's a hard problem and I don't think it'll be solved any time soon. All that said, C has no features. There are the basic control flow structures, structs, header files, and a handful of standard library functions (mostly malloc and free). If you have prior programming experience, then getting to the point where you can write small programs and read larger ones will take you somewhere between a few hours and half a week. Why not spend some time learning both? ultrafilter fucked around with this message at 17:21 on Mar 3, 2018 |
# ? Mar 3, 2018 17:16 |
|
If you are writing a real program, or learning a language to write real programs in, then there are all sorts of reasonable arguments for different languages, but Rust is a very acceptable choice. If you are learning a low-level programming language to try to understand computers better, you should learn C. C has a lot of things that will get in your way because it is not a great language, but Rust has a lot of things that will get in your way because it is trying to prevent you from doing dumb things. Spending two hours with a debugger and a disassembler trying to understand why those dumb things broke your program will teach far you more about computers than writing 10,000 lines of clean, idiomatic Rust that work perfectly once they compile at all and where all the ugliness is hidden behind the library's abstractions.
|
# ? Mar 4, 2018 09:56 |
|
I never know where to point people who are already programmers who want to learn C to understand computers better. I "learned" C from various blog posts and tutorials and that wasn't great. So what should such a person read?
|
# ? Mar 4, 2018 18:23 |
|
I honestly like K&R; it’s quite good at walking you through the language, it conveys the mindset of late-70s language design quite well, and enough of what it says is going to feel dated and questionable that you will not feel too tempted to take it to heart. Nobody should be learning C as their first language anymore. It’s like Song of the South, there are lots of things to appreciate but it needs to be watched with a critical eye and you probably shouldn’t show it to kids.
|
# ? Mar 4, 2018 20:52 |
|
|
# ? Jun 9, 2024 06:33 |
|
Thanks for the info dudes! I'm tempted to dive back into C after attempting a project with Rust.
|
# ? Mar 4, 2018 20:56 |