Want to calculate all sum of all possible paths from root to leaf, each node has value of a integer number (decimal). In the following example,
1
/ \
2 4
/ /\
3 5 6
possible paths are (123, 145, and 146, which sum is 414). In this example, 12 is not a valid path since 2 is not a leaf node....
i am planning to parse below file with spark, so i have written a custom input split , i want the values from hadoop to Spark as `commitId:committerName:file1,file2.... Format.
As i am new to distributed paradigm so want to know if below code can work with spark or not to get the desired outp...
You guys use some acronyms I'm not familiar with, I looked up TTQW and I found this meaningfor.com/what-does-stand-for/ttqw ... well... "The acronym TTQW has a life path number 8. Individuals that have the life path number eight are full of energy with an extraordinary ability for focus. Their confidence can fill a room."
it only gets more bizarre as you get farther down the page, I have no idea what's up with this page, it's like an astrology bot generated it or something
Meme: [TTQW | TTGH] | TTGTB
Originator: [attributed to] Simon André Forsberg (first TTQW here)
Cultural Height: The 2nd Monitor
Background: leaving the chatroom and/or going AFK isn't something we do often. These funky acronyms efficiently communicate that it's either time to quit work (or tim...
this WM_RUBBERDUCK_CHILD_FOCUS is a... custom Windows message he's injecting into the message pump so that we can raise an event when a docked toolwindow loses focus. way to work around an underfeatured API: talk to its mom instead.
I have javascript code that repeats this pattern many times (though the values of INSTRUCTIONS and "a" are different each time). The number of elements in "INSTRUCTIONS" varies.
var INSTRUCTIONS = [ 'LEFT', '90', 'FORWARD', '10', 'LEFT', '90'];
var a = [
'red',
'blue',
'newjersey',
];
fo...
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
public class SmallestMultiple {
public static void main(String[] args) {
int ...
Revised from: Bash scripts and udev rules to handle USB auto mounting / unmounting
Tested:
Uses USB insert/remove to control a headless Raspberry Pi 3 with Raspian Jessie Lite
Changes:
Implement more functions
Improve comments
Modify if-fi exit handling
Add optional flag for auto proces...
Due to my needing to use C libraries inside C++, I kept finding myself wanting to be able to ensure that the free function got called, even if an exception got thrown. UTILS_SCOPE_EXIT ensures that the function will be called at the end of scope. External documentation shows how to use it, and al...
I'm working on a fork of Cygwin for native Windows development.
In this commit, I'm trying to improve the security of code that spawns cmd.exe, used by functions like system, popen.
What I would like to focus on is this:
static const char *cmd_exe_path = NULL;
static void init_cmd_exe_path(vo...
Problem
Count the number of character replacements necessary to convert an input String to a palindrome.
Each character replacement must replace the given character with the character directly before it in the alphabet (sorted A-Z).
In other words, D can only be replaced with C.
For simplicit...
@user2296177 They can be any distance apart. Anywhere from 1 2 3 5 8 9 to 1 15 89 153 23514
In my particular scenario, the likelihood of them being sequential is very high at the beginning, and very low at the end. I.e.: 1 2 3 4 5 6 7 8 9 10 11 12 12853 1585832
Quote of the day: “Dynamic typing: The belief that you can’t explain to a computer why your code works, but you can keep track of it all in your head.” hehe ^_^
The code below takes a filled out Sudoku board of size NxN, with sub-blocks of nxn, and checks if the solution is correct.
main_function takes a board as input. This function calls check_rows and check_blocks. The first of the two is used to check both the rows and columns of the board. The seco...
A cricketer can score 1, 2, 4 or 6 in a ball. Find in how many ways the player can score a total of "n" runs without hitting 3 consecutive boundaries. Note: Scoring 4 or 6 is considered as a boundary.
My solution is:
int *arr; //global array to save calculated ways
int waysUtil(int n, int boun...
--Small question: Can I say this, or is this the wrong terminology? "...use native Python or use numpy". If I use Python without any modules, can I call it "native Python", or should I say something else?
or maybe "plain Python", "pure Python", just "Python"?
@StewieGriffin you also have a module called array if you need it. But basically Python lists are very flexible and can hold completely heterogeneous, arbitrary data, and they can be appended to very efficiently, in amortized constant time
If you need to allocate an array that you KNOW will not change, then arrays can be faster and use less memory than lists. That's the only use-case where I'd use arrays instead of lists
But in the case where I need to do "strange" indexing, isn't numpy arrays better? If I have a list/array like this: x = [[1,2],[3,4]], and I want the elements [1,3], and [2,4], do you think it's best to use lists?
@Dex'ter If you don't mind, a few comments/suggestions/improvements in an answer to the question I linked to would be very much appreciated. It seems like you know quite a lot more than I do =)
well, no, it's actually not. He said that because numpy was actually made for this purpose. If you have to play around with arrays numpy is a good fit. They are really optimized when it comes to this purpose
Just a final quick yes/no question: For selecting sub-blocks in an array (or list of lists), e.g. the 3x3 blocks in Sudoku, would you still consider lists a good option?
I'd like to split an input string on the first colon that still has characters after it on the same line.
For this, I am using the regular expression /:.+/
So given the string
aaa:
bbb:ccc
I'd expect an output of
["aaa:\nbbb", "ccc"]
And given the string
aaa:bbb:ccc
I'd expect an outpu...
@Pimgd to get it working properly, though, you could just tell your colleague to use string.split(':'), then reduce the array into two elements - array[0] will be 'aaa', array[1...N] will be the remainng matches, which is exactly what you would have had with the regex anyway
@Pimgd I wonder what would happen if the entire world's population dropped what they were doing and started reading the What-if book from start to finish at the same time.
Without specifying which errors you get, we have a hard time to help you. Please post error codes and other things you tried (the for loop approach). If you want your code to be improved you should post to Code Review Stack Exchange instead. — mwormser15 secs ago
My program is made to tell the positions of each word in a sentence. However it simply doesn't work sometimes and I cannot tell why.
counter = 0
mainLoop = True
print ("this program takes a sentence and a word and puts outputs the positions of the words in the sentence")
sentence = str(input("i...
I want to send "6294" data on this web html page : "http://www.banquept.fr/2016_res_admiss/resultats_concours.php" for example.
I try to do it with this unix command :
wget ‐‐post-data ‘submit=6294’ http://www.banquept.fr/2016_res_admiss/resultats_concours.php
but it didn't work...
> Vogel612 has approved 168 edit suggestions and rejected 123 edit suggestions and improved 51 edit suggestions
check your latest handled suggested edit and expand the info-card with (more)
> Vogel612 has approved 53 edit suggestions and rejected 27 edit suggestions and improved 8 edit suggestions Community has approved 810 edit suggestions and rejected 229 edit suggestions and improved 2 edit suggestions
What it is about
I created an application where you need to push invisible buttons in a certain order to unlock the advanced mode. To handle this, I wanted to use a queue (FIFO) of my own, adapted to my problem.
Every time I click a button, its ID is added to the queue with addItem, and the pas...
> If you see public static final char COLON = ':' in Java code, find whomever wrote that and break their keyboards. If the representation for COLON ever changes from : you will have a maintenance nightmare.
> You've earned the "Nice Question" badge (Question score of 10 or more) for "Why does string.split with a regular expression that contains a capturing group return an array that ends with an empty string?".
I would make several arguments that EMPTY_STRING is beneficial. (1) I can much more easily find all uses of EMPTY_STRING in a file than I can find all uses of "". (2) when I see EMPTY_STRING I know for darn sure that the developer intended that string to be empty, and that it is not a mis-edit or a placeholder for a string to be supplied later. Now, you claim that by me making this argument that you may qualify my knowledge, and safely ignore me forever. So, how do you qualify my knowledge? And are you planning on ignoring my advice forever? I have no issue either way. — Eric Lippertyesterday
@Pimgd yea I have no idea, but usually you don't want your name longer than about 6 words or so, at a certain point people actually don't read something because the name deters them
can someone take a look at this answer and try to explain it to me in a different way? i'm not completely following his logic for some reason -- codereview.stackexchange.com/questions/134208/…
I have been writing an event class for my game engine and I came across to the following problem:
Is casting a base class object to a derived class object given a type flag a good programming design?
Let me give you the following simple example. I have this enum holding the categories of the e...
The intent is to have an auto_increment composite primary key on a InnoDB table which mimics the behavior as on a MyISAM table. The following assumes (3) InnoDB tables all with an auto_increment composite primary key (id incrementing and a_id not incrementing). Please comment positively or nega...
I have rolled back the last edit. Please see What to do when someone answers. You inadvertently invalidated section 2) of the existing answer. Feel free to post a follow-up question. — Mast11 secs ago
> Without seeing code for the new Exception classes to understand if there really is some value being added by these (rather than simply more complexity for calling code to deal with), the value certainly is not clear here for having these.
@Mast not sure if it needed rolled back, he said he couldn't be certain without it so it's kinda asking for the code
@N3buchadnezzar Sets are significantly faster when it comes to determining if an object is present in the set (as in x in s), but are slower than lists when it comes to iterating over their contents.
wwhen you want to store some values which you'll be iterating over, Python's list constructs are slightly faster. However, if you'll be storing (unique) values in order to check for their existence, then sets are significantly faster.
I'm solving problem 21, from Project Euler site. I can't see any mistakes in code, but it gives me wrong answer. Correct solution is 31626, but I get 18320.
#include <iostream>
using namespace std;
unsigned long sumOfDivisors(unsigned int a){
unsigned long sum = 0;
for(unsigned int i=1; i
@Dex'ter And you can backup your claim with facts:
>>> min(timeit.Timer('for e in elements:pass', setup='elements=set(range(10000))').repeat(7, 10000))
0.8969283030019142
>>> min(timeit.Timer('for e in elements:pass', setup='elements=list(range(10000))').repeat(7, 10000))
0.6928142239994486
@skiwi It's more that I'm working with promises, and when you're stacking like 15 if you forget to reject even one with an error, it will get lost in the stack
I've already got an ear infection, I don't want it to turn into cancer -- if you can't tell im adamantly against that song. played way to much and it makes my blood boil