deyahruhd

Last active 8 hours ago

  1. 2 weeks ago
    Thu Jun 28 16:56:58 2018
    deyahruhd posted in Word Association.

    Steph Curry

  2. Thu Jun 28 06:01:06 2018
    deyahruhd posted in Word Association.

    Our Glorious King

  3. 3 weeks ago
    Tue Jun 26 04:10:54 2018
    deyahruhd posted in Word Association.

    Alex Jones

  4. Mon Jun 25 03:57:21 2018
    deyahruhd posted in Word Association.

    I go hard like Vladimir Putin

  5. Sun Jun 24 18:34:14 2018
    deyahruhd posted in Word Association.

    Great Ice Ball Earth Theory

  6. 4 weeks ago
    Tue Jun 19 01:02:04 2018
    deyahruhd posted in Word Association.

    Look at me (rip in peaces btw)

  7. Sat Jun 16 20:05:09 2018
    deyahruhd posted in Humfrydog showcase of builds.

    @Inyashi What a magnificent work of art

  8. Thu Jun 14 21:27:28 2018
    deyahruhd posted in Efficient Code Thread.

    @WBlaine The codes I write for work are for mathematical computation ... so those aren't interesting for this thread.

    Sounds very interesting to me if it involves math. :^)

  9. Thu Jun 14 21:00:59 2018
    deyahruhd posted in Efficient Code Thread.

    @Stone__Warrior @deyahruhd If you add

    #include <thread>

    at the top, there's this pretty sweet optimization you can make to significantly impact the speed your process takes. In all of your functions, just copy-paste

    std::this_thread::sleep_for(std::chrono::milliseconds(std::numeric_limits<unsigned long int>::max()));

    wherever you see fit.
    :D

    Wow, that made my algorithm even more efficient by a factor of (9,223,372,036,854,775,807 + 1) * 2 - 1! Thanks!

  10. Thu Jun 14 20:43:16 2018
    deyahruhd posted in Efficient Code Thread.

    Here is a new, efficiently efficient recursive algorithm for sorting an array in ascending order.

    #include <cstdlib>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <chrono>
    
    // A simple algorithm that efficiently efficient sorts an array with recursion.
    void _efficientEfficientlySort (int *arr, size_t start, size_t count) {
    	bool is_valid;
    	if (count > 1) {
    		is_valid = true;
    	} else if (count <= 1) {
    		is_valid = false;
    	}
    
    	if (is_valid == true) {
    		int subdivision = count / 2;
    		_efficientEfficientlySort (arr, start, subdivision);
    		_efficientEfficientlySort (arr, start + subdivision, count - subdivision);
    
    		// Randomly shuffle the current subdivision while it is unsorted, this will give us a new sorted array
    		bool is_sorted;
    		do {
    			is_sorted = true;
    			for (int i = 0; is_sorted != false && i < count - 1; ++ i) {
    				if (arr [start + i] > arr [start + i + 1]) {
    					is_sorted = false;
    				}
    			}
    
    			if (is_sorted == false) {
    				std::random_shuffle (&arr [start], &arr [start + count]);
    			} else if (is_sorted == true) {
    				break;
    			}
    		} while (is_sorted == false);
    	}
    }
    
    void efficientEfficientSort (int *arr, size_t size) {
    	_efficientEfficientlySort (arr, 0, size);
    }
    
    const int SIZE = 100;
    
    int main (int argc, char ** argv) {
    	std::srand (std::time (NULL));
    	int arr [SIZE];
    
    	for (int i = 0; i < SIZE; ++ i) {
    		arr [i] = std::rand () % 1000;
    	}
    
    	std::cout << "Your array is ";
    	for (int i = 0; i < SIZE; ++ i) {
    		std::cout << arr [i] << ", ";
    	}
    
    	auto before = std::chrono::high_resolution_clock::now ();
    	efficientEfficientSort (arr, SIZE);
    	auto after = std::chrono::high_resolution_clock::now ();
    
    	std::cout << "Your new sorted array is ";
    	for (int i = 0; i < SIZE; ++ i) {
    		std::cout << arr [i] << ", ";
    	}
    	std::cout << "!\n" << std::endl;
    	std::cout << "And it took only "
    	          << std::chrono::duration_cast <std::chrono::seconds> (after - before).count ()
    	          << "seconds!\n" << std::endl;
    
    	return -1;
    }
    
    /*
                ,+@;                  
          .@@@@@@@#                   
         .@@@@@@@#                    
        `@@@@@@@@@;                   
       .@@@@@@@@@@'#                  
      ;@@@@@@;:@#`,;;                 
      ``+  @@@@: ''+',                
        +  @'+#`; :,:@                
        ,   +,`` .' ';                
        ..  .#  ` ,  `                
        :@   :,:      ,               
        ,@     `      . +             
        .@     :; `  ,  @@@@+`        
         #     ` ,#    ,@@@@@@@@'     
                 @@ .` #@@@@@@@++@    
                @@@'  ,@@@@@@+@;#'@   
              `@@@@@  :@@@@@@:@@@@':  
              @#'@@@' @@@@@@@@@@;@@@  
              @#,@@@@@@@@@@@@@@@#@@@: 
              @,.@@@@@@@@@@@@@@@@@@@@ 
             ,@@:@@@@@@@@@@@@@@@@@@@@ 
             @@@+@@@@@@@@@@@@@@@@@@@@.
             @@@#@@@@@@@@@@@@@@@@@@@@@
       `#    @@@#@@@@@@@@@@@@@@@@@@@@@
      ;: ,   @@@@@@@@@@@@@@@@@@@@@@@@@
       :   + @@@@@@@@@@@@@@@@@@@@@@@@@
         '  `;@@@@@@@@@@@@@@@@@@@@@@@@
          ..  '  @@@@@@@@@@@@#'+@@@@@@
            +  ,  #@@@@@@@@@@@@@@@@@@@
             `.#,  :@';:'@@@@;@'@@@@@@
              ,     `@@@:@@@@@#@:@@@@@
    */
View more