Jump to content

duckypath

Member
  • Posts

    356
  • Joined

  • Last visited

Awards

This user doesn't have any awards

1 Follower

About duckypath

  • Birthday Jan 01, 1990

Profile Information

  • Gender
    Male
  • Location
    Unknown
  • Interests
    Computers, VFX. Dev

Recent Profile Visitors

1,202 profile views
  1. https://onlinegdb.com/NAu1whXV0 This might also help, when you debug can see the segmentation errors.
  2. I would also get some double free() error messages, which was the cause to not finishing compiling before as well.
  3. Depends, sometimes I get set 1 to print, other times like on repl.it, I can get it all to print, but the difference method doesn't work. I think it comes down to the memory being all mismanaged, and giving me these odd results. Somewhere I am accessing memory I am not supposed to according to the debug I ran.
  4. I am having trouble finding where the memory issue is, even after trying multiple ways, including not even freeing the memory. Any help appreciated! A lot of lines, so feel free to download the file. Can paypal someone $10 if you help me out here. Just point me in the right direction ERROR: zsh: segmentation fault Sometimes I can get it to compile and finish the rest of main, but other times it won't. SO definitely undefined behavior, memory issue. MAIN.CPP #include <iostream> #include "Set.h" using namespace std; int main() { int arr1[6] = {2, 1, 4, 3, 5, 4}; cout<<"int arr1[] = {2, 1, 4, 3, 5, 4}"<<endl; Set set1(arr1,6); cout << "Set1(arr1): "; set1.display(); cout << endl; cout<<"adding 1, 3, 5 again then 6 and 7"<<endl; set1.add(1); set1.add(3); set1.add(5); set1.add(6); set1.add(7); cout << "Set1: "; set1.display(); // remove an existing element and a non-existing element cout<<"Remove(7); Remove(9)"<<endl; set1.Remove(7); set1.Remove(9); cout << "Set1: "; set1.display(); cout<<endl; cout << endl; cout << "Creating set2, copying the former set. (Testing copy constructor)" << endl; Set set2(set1); cout << "Set2: "; set2.display(); cout << endl; int arr3[4] = {0, 1, 4, 9}; Set set3(arr3, 4); cout << "Set3: "; set3.display(); cout << endl; cout << "The union of set1 and set3 is: " << endl; Set unionSet = set1.Union(set3); unionSet.display(); cout << endl; cout << "intersectSet = set1.Intersection(set3)" << endl; Set intersectSet = set1.Intersection(set3); intersectSet.display(); cout << endl; // Test - the difference between two sets cout << "diffSet = unionSet.Difference(intersectSet)" << endl; Set diffSet = unionSet.Difference(intersectSet); diffSet.display(); cout << endl; // Test == if two sets are equal Set set4(set1); cout << "Set4(set1): "; set4.display(); cout << endl; cout << "set1: "; set1.display(); cout << "set4: "; set4.display(); if (set1.Equal(set4)) cout<<"set1 is equal to set4"<<endl; else cout<<"set1.Equal(set4) failed"<<endl; cout << endl; // Test != if two sets are not equal cout << "set1: "; set1.display(); cout << "set3: "; set3.display(); if (!(set1.Equal(set3))) cout<<"set1 is not equal to set3"<<endl; else cout<<"!(set1.Equal(set3 ) failed"<<endl; cout << endl; return 0; } SET.H #ifndef SET_H #define SET_H class Set { private: int *arp; int pSize; int numElements; const static int DEFAULT_SIZE = 5; public: Set(int arrSize = DEFAULT_SIZE); Set(int[], int arrSize); ~Set(); Set(const Set &origObj); // copy constructor //Set(Set *copyObj); void display(); bool add(int newElement); bool isElement(int elementToCheck); void extendSet(); void showSize(); void countElements(); bool Remove(int elementToRemove); Set Union(Set setToUnion); Set Intersection(Set setToIntersect); Set Difference(Set toDifference); bool Equal(Set equalCheckSet); }; #endif SET.CPP #include <iostream> #include "Set.h" // Default constructor Set::Set(int SIZE) { pSize = SIZE; arp = new int[pSize]; numElements = 0; } // Copy constructor Set::Set(const Set &origObj) { arp = origObj.arp; pSize = origObj.pSize; numElements = origObj.numElements; } /* Set:: Set(Set *copyObj) { for(int i = 0; i < copyObj->numElements; i++) { arp[i] = copyObj->arp[i]; } numElements = copyObj->numElements; pSize = copyObj->pSize; } */ // Constructor to create array and set its size. Set::Set(int arr[], int arrSize) { pSize = Set::DEFAULT_SIZE; arp = new int[pSize]; for (int i = 0; i < arrSize; ++i) { add(arr[i]); // must add all the elements to arr. } } // Destructor: removes the dynamically allocated array. Set::~Set() { delete [] arp; } void Set::display() { std::cout << "{"; for (int i = 0; i < numElements; ++i) { std::cout << arp[i]; if (i != numElements - 1) // checks for the last elm. std::cout<<", "; } std::cout << "}" << std::endl; /* // OLD, didnt end up working int count = 0; std::cout << "{"; for (int i = 0; i < this->pSize; ++i) { if (i == this->pSize - 1) { std::cout << arp[i]; break; } else if (this->arp[this->pSize - 1] < 1) {std::cout << ""; break;} std::cout << this->arp[i] << ", "; } std::cout << "}" << std::endl; */ } bool Set::add(int newElement) { if (!isElement(newElement)) { if (numElements == pSize) { extendSet(); } arp[numElements++] = newElement; } return false; } // checks of the input element is in the array bool Set::isElement(int elementToCheck) { for (int i = 0; i < numElements; ++i) { if (elementToCheck == this->arp[i]) { return true; } } return false; } void Set::extendSet() { //dynamically creating new arr in memory equal to new size + old default. int *newArr = new int[pSize + Set::DEFAULT_SIZE]; pSize += Set::DEFAULT_SIZE; for(int i = 0; i < numElements; i++) { newArr[i] = arp[i]; } arp = newArr; } // Shows the size of the current array void Set::showSize() { std::cout << "Current size of array: " << this->pSize << std::endl; } // will count current elements in array void Set::countElements() { std::cout << "Current Element Count: "; std::cout << numElements << std::endl; } bool Set::Remove(int elementToRemove) { int elmRemovePosition; if (isElement(elementToRemove) == true) { for (int i = 0; i < pSize; ++i) { if (elementToRemove == arp[i]) { elmRemovePosition = i; } for (int i = elmRemovePosition; i < numElements; ++i) { arp[i] = arp[i + 1]; } } numElements--; // reduce array size by 1 } else { return false; } return 0; } Set Set::Union(Set setToUnion) { Set unionSet; for (int i = 0; i < numElements; ++i) { unionSet.add(arp[i]); } for (int i = 0; i < numElements; ++i) { unionSet.add(setToUnion.arp[i]); } return unionSet; } Set Set::Intersection(Set setToIntersect){ Set intersectSet; for (int i = 0; i < numElements; i++){ if(setToIntersect.isElement(arp[i]) != false) intersectSet.add(arp[i]); } return intersectSet; } Set Set::Difference(Set toDifference){ Set differenceSet(toDifference); for (int i = 0; i < toDifference.numElements; i++) { differenceSet.Remove(toDifference.arp[i]); } return differenceSet; } /* Set Set::Difference(Set toDifference) { Set differenceSet; int tempElement; for (int i = 0; i < this->numElements; ++i) { for (int j = 0; j < toDifference.numElements; ++j) { if (arp[i] != toDifference.arp[j]) { differenceSet.add(arp[i]); } else { tempElement = this->arp[i]; } } differenceSet.Remove(tempElement); } return differenceSet; }*/ /* Set Set::Intersection(Set setToIntersect) { Set intersectSet; for (int i = 0; i < this->numElements; ++i) { for (int j = 0; j < setToIntersect.numElements; ++j) { if (arp[i] == setToIntersect.arp[j]) { intersectSet.add(arp[i]); } } } return intersectSet; }*/ bool Set::Equal(Set equalCheckSet) { if (numElements == equalCheckSet.numElements) { for (int i = 0; i < numElements; ++i) { for (int j = 0; j < equalCheckSet.numElements; ++j) { if (arp[i] == equalCheckSet.arp[i]) { break; } else { continue; } } } } else { return false; } return true; } ltt.zip
  5. Youtubers (LTT included) using "Sponsored" for their videos instead of Paid Product Overview, or Paid Product Showcase. A sponsored video is a normal video that was organically developed that was monetized by an unaffiliated third party. When a company is invested in the development, and final result of the video in question, you can no longer claim that it's a normal video. I don't claim that there's malicious intent behind it either, but it's confusing for viewers, and annoying when watching a video on a product, only to find I can't with good judgment trust the opinions because they're clearly biased. (Although Linus is particularly good at removing himself from that.)
  6. I assume you want to know where to lower the refresh rate, when windows settings doesn't provide the option. Since you mention that the laptop has a 3060 in it, this can be done via the Nvidia control panel. Just right click on desktop, find the control panel with Nvidia Logo, and you should see Desktop Resolution option somewhere on the left hand side. From there you should see a similar drop down with refresh rates, which should provide more to you. If you do not, reply to my post and I can help you creating a custom resolution profile with the new refresh rate you want.
  7. Which is very very wrong anyways? Tasks like adobe need the 3090 for the VRAM, 12GB VRAM is no where near ideal for professional tasks. Linus agrees, which is why he just upgraded all his editors PCs to 3090s. 12GB VRAM in the 80Ti, and being considered for professional applications? lol ok Let's not glaze over the fact that this "review" was completely wrong, inaccurate, and provided terrible advice. Only being made worse by having it justified, rather than redacted, and remade. Typical LTT to leave up a bad review rather than spend some $$ and have it remade to provide factual, good information for the consumer. I'll also be clear here, I don't think LTT was paid by nVidia, that's stupid. I do think they based the review on bad information, or made some bad calls about its performance and value, and decided to double down rather than admit mistake, which would require them to take down a video with sponsor spots.
  8. Once again LTT prioritizing being first, making assumptions. Clearly the 3080Ti is not a great value, and seeing how they have a 'review' video and recommending that it's a no brainer purchase without knowing a price solidifies that LTT is not a channel for reviews anymore. My opinion makes zero difference, and I don't expect for anything to change, but I can't not call out something this dishonest, especially from a channel that claims to be one of the top in its field. TL;DR -> Don't watch LTT for honest reviews.
  9. Manage an e-commerce business and you'd change your mind real quick. Although not ideal, Facebook is probably the top platform for advertising your products, right behind Google and Instagram.
  10. Nobody will be able to tell you, simply because the companies that supply the vast amount of components are spread globally with vastly different governments. We could say by summer, or end of year, but maybe some countries in Asia decide that another lockdown is necessary, and that gets taken well into 2022. I think it's safe to say that the estimate of this being felt will be easily 5+ years, but the worst of it we're currently in. The more governments feel it's necessary to keep businesses closed and remain locked down in an attempt to "beat" the virus the longer the supply chain will be affected. With all that said, a new precedent was set as well. Low prices are a great media tool for companies, but the real profit is made through the bait and switch, selling the products for their actual intended MSRPs. NVIDIA knew their GPUs would be in low supply, and their prices unsustainable. I see this new business tool being used long into the future, cheap release prices -> something causes low supply -> higher MSRPs. It's been used for RAM, Hard Drives (WD), Power Supplies (Corsair), and now GPUs and CPUs.
  11. Wow! Totally missed the multiply assign! Thank you!!!! The invalid1 being pushed was actually a debug test I forgot to revert before posting code, but thank you for that as well.
  12. // All valid credit card numbers const valid1 = [4, 5, 3, 9, 6, 7, 7, 9, 0, 8, 0, 1, 6, 8, 0, 8]; const valid2 = [5, 5, 3, 5, 7, 6, 6, 7, 6, 8, 7, 5, 1, 4, 3, 9]; const valid3 = [3, 7, 1, 6, 1, 2, 0, 1, 9, 9, 8, 5, 2, 3, 6]; const valid4 = [6, 0, 1, 1, 1, 4, 4, 3, 4, 0, 6, 8, 2, 9, 0, 5]; const valid5 = [4, 5, 3, 9, 4, 0, 4, 9, 6, 7, 8, 6, 9, 6, 6, 6]; // All invalid credit card numbers const invalid1 = [4, 5, 3, 2, 7, 7, 8, 7, 7, 1, 0, 9, 1, 7, 9, 5]; const invalid2 = [5, 7, 9, 5, 5, 9, 3, 3, 9, 2, 1, 3, 4, 6, 4, 3]; const invalid3 = [3, 7, 5, 7, 9, 6, 0, 8, 4, 4, 5, 9, 9, 1, 4]; const invalid4 = [6, 0, 1, 1, 1, 2, 7, 9, 6, 1, 7, 7, 7, 9, 3, 5]; const invalid5 = [5, 3, 8, 2, 0, 1, 9, 7, 7, 2, 8, 8, 3, 8, 5, 4]; // Can be either valid or invalid const mystery1 = [3, 4, 4, 8, 0, 1, 9, 6, 8, 3, 0, 5, 4, 1, 4]; const mystery2 = [5, 4, 6, 6, 1, 0, 0, 8, 6, 1, 6, 2, 0, 2, 3, 9]; const mystery3 = [6, 0, 1, 1, 3, 7, 7, 0, 2, 0, 9, 6, 2, 6, 5, 6, 2, 0, 3]; const mystery4 = [4, 9, 2, 9, 8, 7, 7, 1, 6, 9, 2, 1, 7, 0, 9, 3]; const mystery5 = [4, 9, 1, 3, 5, 4, 0, 4, 6, 3, 0, 7, 2, 5, 2, 3]; // An array of all the arrays above const batch = [valid1, valid2, valid3, valid4, valid5, invalid1, invalid2, invalid3, invalid4, invalid5, mystery1, mystery2, mystery3, mystery4, mystery5]; // Add your functions below: const validateCred = arr => { let newArr = []; let doubleDigit; newArr.unshift(arr[arr.length - 1]); for (let i = arr.length - 2; i > 0; i--) { doubleDigit = arr[i] *= 2; newArr.unshift(doubleDigit); //newArr.unshift(arr[i] *= 2); newArr.unshift(arr[i - 1]); i--; } if (arr.length > 15) { newArr.unshift(arr[0] * 2); } for (let j = 0; j <= newArr.length - 1; j++) { if (newArr[j] > 9) { newArr[j] -= 9; } else { newArr[j]; } } let finalSum = newArr.reduce((a,b) => a + b, 0); if (finalSum % 10 === 0) { return true; } else { return false; } } const findInvalidCards = batchArr => { let invalidCards = []; for (let i = 0; i <= batchArr.length - 1; i++) { if (validateCred(batchArr[i]) === false) { invalidCards.push(invalid1); } } return invalidCards; } //console.log(findInvalidCards(batch)); console.log(findInvalidCards(batch)); Project from Codecademy, and I am stuck on the function validateCred(). Somewhere that function is mutation the original arrays, even though all values are being pushed to the new array newArr, and arr isn't being touched. With that said, it could be that newArr is referencing arr? Or some of my array methods are mutating the original arrays, but I can't find out where. The out put is: [ [ 4, 5, 6, 2, 14, 7, 16, 7, 14, 1, 0, 9, 2, 7, 18, 5 ], [ 4, 5, 6, 2, 14, 7, 16, 7, 14, 1, 0, 9, 2, 7, 18, 5 ], [ 4, 5, 6, 2, 14, 7, 16, 7, 14, 1, 0, 9, 2, 7, 18, 5 ], [ 4, 5, 6, 2, 14, 7, 16, 7, 14, 1, 0, 9, 2, 7, 18, 5 ], [ 4, 5, 6, 2, 14, 7, 16, 7, 14, 1, 0, 9, 2, 7, 18, 5 ], [ 4, 5, 6, 2, 14, 7, 16, 7, 14, 1, 0, 9, 2, 7, 18, 5 ], [ 4, 5, 6, 2, 14, 7, 16, 7, 14, 1, 0, 9, 2, 7, 18, 5 ], [ 4, 5, 6, 2, 14, 7, 16, 7, 14, 1, 0, 9, 2, 7, 18, 5 ] ] Which is what I need, except that the double digits that were added were not supposed to be returned. The original values were supposed to be returned.
  13. Looks to be a tearing issue, and stuttering. Do you have GSYNC/FREESYNC/VRR on?
  14. You really can't be that upset though, because there was opportunity for them to grab the resources they needed as well. If you say they don't have the demand, thus the cash to reserve so much, well then you answered your own question. MORE DEMAND = MORE RESOURCES NEEDED. Apple has really pushed tech in an interesting direction, and have gotten a ton of support and demand for their product. It makes ZERO sense for apple to not get ahead of everything and procure resources they need. If you argue against that you're a hypocrite, because you're blaming AMD and NVIDIA right now for their low supply. (not you specifically i don't think, but in general with your similar argument against apple).
×