Jump to content

Nineshadow

Member
  • Posts

    8,210
  • Joined

  • Last visited

Everything posted by Nineshadow

  1. Nineshadow

    Just watched Arrival. What an amazing movie. Ea…

    I watched it and I thought it was great, very good in fact, but not good enough to make it a favourite of mine. I don't really know why though, the direction felt very cohesive, the message and the themes it's based upon are great, acting was pretty good and the cinematography was spot-on
  2. I've had a cheap Acer notebook (~400 eur) from 2007 and it still works to this day. Sure, it doesn't work that well these days, it's slow as hell, but it still works, surprisingly.
  3. An acquaintance of mine has an old Galaxy Tab 10.1. And I really mean it, the tablet must be around 6 years old right now. Anyway, he is looking to get a laptop as a replacement. Why a laptop you might ask? He realized tablets are mostly useless and he doesn't have a proper pc either, so a laptop seems just fine. Plus he'd be able to use it for other stuff as well, such as working with Office. First of all, the budget is around 400 EUR. The cheaper the better, unless it comes with a clear disadvantage. As far as the usage scenario goes,the laptop will mostly be used for casual activities: basic web browsing, maybe Office, streaming/playing movies. No games or other intensive graphical applications. After browsing the local online stores for a little bit, I think I found a good choice: an Acer Aspire E5-575-33P6. It has an i3 6006U, 8GBs of RAM and a 128GB SSD. The SSD is M.2 and the laptop also has a 2.5" SATA slot, so fitting an extra 1TB HDD for storage should be no problem. Oh, and even with the extra HDD it still fits the budget. The display is 1080p, that's pretty great. Sure, it's TN but I'm not expecting anything else than that in this price range. The build does consist of plastic, but at least it's sturdy and looks somewhat sleek. Again, you can't have too high expectations from a 350EUR laptop. Overall, it looks like a great package for the price. Other than this, I've found some HP laptops with similar specs, but they're overall more expensive. Also some Lenovos but they have HD displays and usually come with 4GBs of RAM. I'd like to hear your thoughts and/or suggestions.
  4. While optimizing programs at an assembly level does bring some performance improvements, it's nothing compared to the complexity of the algorithm you are using. That's what will make the most impact. Imagine an algorithm in which you're taking into consideration all combinations of a set. That will have a complexity of O(2n). Things are fine until you get to tests with values of n up to, let's say 30. But after that? What if n is 100? The program would not finish in our lifetime. No matter what low-level optimizations you make, it will still take a tremendous amount of time
  5. Welcome to Snapchat on Android! Bad as always. I'm not kidding. If you didn't know, Snapchat doesn't take a picture per se on Android. It accesses the live view of your camera and takes a screenshot from that. This is simply a terrible way to handle things. Nevertheless, until Snapchat gets fixed on Android, well, there's not much you can do. Try to be more accurate with your shots: take them right when the camera hits the right focus. Oh, and try not to move your phone.
  6. Nevermind, I'm an idiot. I was simply not stopping from searching when the value I find is already smaller than what I'm looking for. Whops. Here's what my source code looks like for those interested.
  7. Yeah, an x-fast trie pretty much. After that add subdivisioning, balancing and amortization and you get y-fast tries. Anyway, it's a possibility but it's too complicated for this problem. It's not supposed to be that hard.
  8. That's what I was thinking as well, but then I realized it's not that simple. Suppose you have a=1011101 b=1101101 a<=b even if it has the 3rd bit (from the left) equal to 1, while b has it equal to 0. That's because the previous bit in a, which is more significant, is smaller than the previous bit in b. So I thought about it this way: Suppose I traverse the tree until I get to the most significant bit of b. I only go down the nodes which indicate a value of 0, since otherwise a would be bigger than b. Once I reach the most significant bit of b, I have two choices: If the bit in a is 0, then the rest of the binary representation of a could be whatever, because a<=b at that point. I can stop searching and add to the solutions. But if the bit in a is 1, then I must continue searching. So I search to the next most significant bit in b, going down only through the 0 nodes again, then do the same thing.
  9. The input data is structured as follows: First, a number n: number of queries. Next n lines are of the form (q,a) or (q,a,b). If q, is 0 the instruction corresponds to the insert(a) operation. If q, is 1 the instruction corresponds to delete(a) operation. If q is 2, the instruction corresponds to the query(a,b) operation. That being said : Input: 5 0 1 0 2 2 3 1 1 2 2 3 1 Output: 1 0 Oh, and I guess I should have some constraints. @Erik Sieghart number of queries <= 200.000 1 <= any numbers in the input <= 2.000.000.000 And yes,they are integers.
  10. You are given a multiset, initially empty, on which you can do 3 operations: insert(x) : insert number x into the multiset delete(i) : delete the i-th number inserted into the multiset query(a,b) : count how many numbers x there are in the multiset such that x xor a <= b. O(n) for the queries isn't fast enough, so I tried looking for something along the lines of O(logn). I thought I could use a trie/prefix tree. If you think of the binary representation of a number as a string, then you can construct a trie out of it. Well, it will also be a binary tree since we can only branch out to '0's and '1's. Nevertheless, in each node I store how many numbers there are with a specific prefix. Since I know how many numbers there are with a specific prefix, then I can also calculate how many numbers xor another one there are with a specific prefix. Now it's just the matter of selecting the ones which are smaller than b, and this is where I'm having problems.
  11. It should be the RGBA because it should be applied after the RGB field. I checked and that's what happens. On a browser without RGBA support I think it should use the RGB value. That's what common sense dictates anyway.
  12. Yeah, Civ 6 still needs a bit more work, even if it probably is the best Civ game at launch from recent history. Civ 5 with all the expansions is great.
  13. Nineshadow

    Quick math/programming question. I have: x xor…

    I have a multiset-like data structure on which I need to do 3 operations: insert(x) - pretty obvious delete(i) - delete the i-th value inserted query(a,b) - count how many numbers x there are in the multiset such that x xor a <= b Of course, it's very simple to implement the query operation in O(n), but that isn't fast enough. I need to get it down to O(logn) or something along those lines. I'm just not sure if a <= b implies a xor c <= b xor c. If this were true, then it should bring things down to ~O(logn). I do a binary search for the value in a sorted vector and that's pretty much it.
  14. Quick math/programming question.

    I have:

    x xor y <= k

     

    Is this good in any way?

    x xor y xor y <= k xor y (?)

    x xor 0 <= k xor y

    x <= k xor y

    1. Mira Yurizaki

      Mira Yurizaki

      What is the point of this?

       

      I ask because I'm having trouble figuring out why you want to do a bitwise operation (especially a XOR function), then compare the result with a range of values.

    2. Nineshadow

      Nineshadow

      I have a multiset-like data structure on which I need to do 3 operations:

      • insert(x) - pretty obvious
      • delete(i) - delete the i-th value inserted
      • query(a,b) - count how many numbers x there are in the multiset such that x xor a <= b

      Of course, it's very simple to implement the query operation in O(n), but that isn't fast enough. I need to get it down to O(logn) or something along those lines.

      I'm just not sure if a <= b implies a xor c <= b xor c. If this were true, then it should bring things down to ~O(logn). I do a binary search for the value in a sorted vector and that's pretty much it.

  15. Learn Euclid's algorithm: https://en.wikipedia.org/wiki/Euclidean_algorithm. def gcd(a, b): while a ≠ b : if a > b: a = a − b; else: b = b − a; return a; And the recursive version def gcd(a, b): if b = 0: return a; else: return gcd(b, a mod b); Ps: gcd is already in STL, although in an experimental fashion.
  16. Nineshadow

    Does anybody want a monitor + GPU combo? I can…

    What monitor/gpu?
  17. Oh, I have an idea! Let's then apply a machine learning algorithm to recognize terrorists from the brain scans! That's bound to work! All jokes aside, while I do understand the intentions(or some of them) behind this, I just don't...like it. There's something not ok about it. But I guess in the lack of a better choice, you have to pick the lesser evil. That's from the view of the government, of course.
  18. So it's ok to violate the privacy of foreign citizens, just not those of US citizens. Sure thing...
  19. Nineshadow

    Ok, so I need some help with this. @fizzlestick…

    I'm not sure what the heck happened to the formatting in the previous post, but whatever.
  20. Nineshadow

    Ok, so I need some help with this. @fizzlestick…

    @fizzlesticks Well, it's not exactly an std::multiset or something like that. It's just conceptually like that : there can be more than one number with the same value in the data structure. I think it's obvious I need to implement some kind of binary tree here. It's just that I don't think it's one that's common, it's probably used just for this purpose. Here's what I'm thinking: Let's scale down the problem from a multi-bit xor (with integers), to a simple xor with booleans. y xor x <= k means that, for each bit in y,x,k, which should fit in 32 bits so let's just use that, the value of y xor x must be smaller or equal than k, where k represents the i-th bit in the number. That's pretty much the definition of bitwise xor, but I needed to emphasise this. If I can store the number of elements with specific bits in specific positions, that should do it. So let's try it. The node structure should look something like this : struct node{ int tot; node *one, *zero; node(...){...} } But how should I construct this tree? Well, let's say I'm considering i-th bit in the number that's to be inserted. If the bit is 1, the I go further down the tree to the one child.. If it's 0, then I go down to the zero child. Whichever child I'm at, I increment the tot field. Then I recursively insert from that child, considering the bit i-1. Removing the i-th inserted number is pretty simple. I hold a vector of the numbers inserted. I get the i-th inserted number from there, then I delete that number from the tree. This should be pretty much the same as the insertion procedure, but decrementing instead of incrementing. But what about the query? We need to compare, bit by bit, the value of y xor x to k. Again, let's say we are considering the i-th bit. We need to select the numbers which respect our condition. If I visit the one child, then I'll be considering numbers with the bit i equal to 1. Thus, I check if 1 xor x <= k. If it's true, then I recursively query on that child, considering the bit i-1. If I visit the zero child, then I'll be considering numbers with the bit i equal to 0. I check if 0 xor x <= k, and yada yada yada. The query is over when I'm at the bottom of the tree, where there are no more children to visit. When that happens, I add whatever I have in the tot field to the solution. I just got this out of my head now, time to implement it and see if it works.
  21. Ok, so I need some help with this. @fizzlesticks

    I have a multiset. On this multiset I need to be able to do 3 operations :

    • insert(x) : insert x into multiset.
    • delete(x) : delete the x-th number inserted into the multiset.
    • count(x,k) : count how many elements y there are in the multiset with the property y xor x <= k.

    I'm looking for something along the lines of O(logn) for the count queries. O(n) isn't fast enough.

     

    1. fizzlesticks

      fizzlesticks

      Well I've never had a reason to use a multiset so I'm certainly no expert, but I believe the only way to get O(logn) for count would be if you could transform (y xor x) <= k into some form like y <= (k op x) which I'm not sure is possible for xor then do an upper_bound(k op x). 

    2. Nineshadow

      Nineshadow

      @fizzlesticks Well, it's not exactly an std::multiset or something like that. It's just conceptually like that : there can be more than one number with the same value in the data structure.

      I think it's obvious I need to implement some kind of binary tree here. It's just that I don't think it's one that's common, it's probably used just for this purpose.

       

      Here's what I'm thinking:

      Let's scale down the problem from a multi-bit xor (with integers), to a simple xor with booleans. 

      y xor x <= k means that, for each bit in y,x,k, which should fit in 32 bits so let's just use that, the value of y xor x must be smaller or equal than k, where k represents the i-th bit in the number. That's pretty much the definition of bitwise xor, but I needed to emphasise this. If I can store the number of elements with specific bits in specific positions, that should do it.

      So let's try it.

      The node structure should look something like this :
       

      struct node{
      	int tot;
      	node *one, *zero;
      	node(...){...}
      }

      But how should I construct this tree?

       

      Well, let's say I'm considering i-th bit in the number that's to be inserted.

      If the bit is 1, the I go further down the tree to the one child.. If it's 0, then I go down to the zero child. Whichever child I'm at, I increment the tot field. Then I recursively insert from that child, considering the bit i-1.

       

      Removing the i-th inserted number is pretty simple. I hold a vector of the numbers inserted. I get the i-th inserted number from there, then I delete that number from the tree. This should be pretty much the same as the insertion procedure, but decrementing instead of incrementing.

       

      But what about the query?

      We need to compare, bit by bit, the value of y xor x to k.

      Again, let's say we are considering the i-th bit. We need to select the numbers which respect our condition.

      If I visit the one child, then I'll be considering numbers with the bit i equal to 1. Thus, I check if 1 xor x <= k. If it's true, then I recursively query on that child, considering the bit i-1.

      If I visit the zero child, then I'll be considering numbers with the bit i equal to 0. I check if 0 xor x <= k, and yada yada yada.

      The query is over when I'm at the bottom of the tree, where there are no more children to visit. When that happens, I add whatever I have in the tot field to the solution.

       

      I just got this out of my head now, time to implement it and see if it works. 

    3. Nineshadow

      Nineshadow

      I'm not sure what the heck happened to the formatting in the previous post, but whatever.

  22. I seriously doubt the OP knows or should know regex right now. Keeping it simple and dumb is just fine. And for that, I could think of 2 options: public static boolean isVowel(char c) { return "AEIOUaeiou".indexOf(c) != -1; } or public static boolean isVowel(char c) { return c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='A' || c=='E' || c=='I' || c=='O' || c=='U'; }
  23. Mmm...my space bar is squeaking for some reason.

×