min's recent activity

  1. Comment on <deleted topic> in ~misc

    min
    Link Parent
    I'm sorry but I'm going to have to disagree on this one. Codecademy is very far away from being comparable with a college computer science course. They teach the syntax of a couple of languages...

    Codecademy

    I'm sorry but I'm going to have to disagree on this one. Codecademy is very far away from being comparable with a college computer science course. They teach the syntax of a couple of languages and nothing more. It's okay if you just want to check out a language for a bit, but it is certainly not something I'd recommend if you want to get serious in the subject.

    You can take various online programming courses from various colleges and companies on edX, which was started by Harvard and MIT. There's also MIT's OpenCourseWare with videos of real university lectures. And best of all, they're both free!

    I've watched one of my old high school teachers tell their students to just go on codecademy every class after they gave up on teaching javascript in web design course! The students' poor quality of code and overall lack of understanding in their real website project was disappointing.

    Also depending on the learner, some physical programming books can be a great tool as well. I learned a lot from a book about Scala written by the creator of the language.

    11 votes
  2. Comment on Programming Challenge: Merge an arbitrary number of arrays in sorted order. in ~comp

    min
    Link Parent
    You can get it even shorter using concat: function mergeAndSort(arr) { return [].concat(...arr).sort() } Or if you still want it in a set: function mergeAndSort(arr) { return new...

    You can get it even shorter using concat:

    function mergeAndSort(arr) {
       return [].concat(...arr).sort()
    }
    

    Or if you still want it in a set:

    function mergeAndSort(arr) {
       return new Set([].concat(...arr).sort())
    }
    
    1 vote
  3. Comment on Programming Challenge: Merge an arbitrary number of arrays in sorted order. in ~comp

    min
    (edited )
    Link Parent
    I could rewrite it as def merge[T: Ordering: scala.reflect.ClassTag](arrays: Array[T]*): Array[T] = arrays.flatten.sorted.toArray But that seemed pretty unnecessary given how much elegance and...

    I could rewrite it as

    def merge[T: Ordering: scala.reflect.ClassTag](arrays: Array[T]*): Array[T] = 
        arrays.flatten.sorted.toArray
    

    But that seemed pretty unnecessary given how much elegance and readability is lost.

    Edit: If I remove the return type (and use type inference instead) and line break I can get it down to one line:

    def merge[T: Ordering: scala.reflect.ClassTag](arrays: Array[T]*) = arrays.flatten.sorted.toArray
    
    1 vote
  4. Comment on Programming Challenge: Merge an arbitrary number of arrays in sorted order. in ~comp

    min
    (edited )
    Link
    I used Scala for this problem, and it almost feels like cheating. My solution is: import scala.reflect.ClassTag def merge[T: Ordering: ClassTag](arrays: Array[T]*): Array[T] =...

    I used Scala for this problem, and it almost feels like cheating.

    My solution is:

    import scala.reflect.ClassTag
    def merge[T: Ordering: ClassTag](arrays: Array[T]*): Array[T] = 
        arrays.flatten.sorted.toArray
    

    Yep, that's all.

    I implemented it as a generic function that will work on any array that implements the Ordering trait, which will let it use the sorted function. The * in Array[T]* denotes the parameter as variadic and allows an infinite (?) amount of parameters. ClassTag allows it to be converted back into an Array in order to be returned. flatten turns the Seq parameter, arrays, into a single Array, combining all elements.

    Here are some assertions showing it working with various different types:

    // Characters
    assert(merge(Array('G', 'V', 'K', 'T', 'X'),
                 Array('r', 'y', 'b', 's'),
                 Array('#', '%', '!')) sameElements
                 Array('!', '#', '%', 'G', 'K', 'T', 'V', 'X', 'b', 'r', 's', 'y'))
    
    // Integers
    assert(merge(Array(9, 2, 3),
                 Array(7, 5, 4), 
                 Array(8, 6, 1)) sameElements 
                 Array(1, 2, 3, 4, 5, 6, 7, 8, 9))
    
    // Doubles
    assert(merge(Array(7.64, 2.31, 3.28),
                 Array(1.31, -7.2, 1.03), 
                 Array(5.82, 6.33, 8.73)) sameElements
                 Array(-7.2, 1.03, 1.31, 2.31, 3.28, 5.82, 6.33, 7.64, 8.73))
    

    I also tried to find the complexity:

    val startTime = System.nanoTime()
    
    merge(
        (for (i <- 1 to 1000)
            yield Array(
                (for (i <- 1 to 1000) 
                    yield scala.util.Random.nextInt(100)): _*)): _*)
    
    println("Time to merge and sort 1,000 Arrays with 1,000 random (0 to 100) Integers: " + ((System.nanoTime() - startTime) / 1e6) + " ms")
    
    
    val startTime2 = System.nanoTime()
    
    merge(
        (for (i <- 1 to 10000)
            yield Array(
                (for (i <- 1 to 1000) 
                    yield scala.util.Random.nextInt(100)): _*)): _*)
    
    println("Time to merge and sort 10,000 Arrays with 1,000 random (0 to 100) Integers: " + ((System.nanoTime() - startTime2) / 1e6) + " ms")
    

    I'd like to mention the _* in the function calls, which I think is pretty cool. It's called the Splat operator, and it unpacks the arguments so the function call acts if all of those Arrays where being called as individual parameters. You might recognize it as * from various dynamic languages like Ruby and Python or as the spread operator (...) from Javascript.

    Each array fed into the merge function has 1,000 elements, which are all random Integers between 0 and 100. On my PC (i7 7700k/16GB) it does the 1,000 arrays in about 0.35 Seconds, and 10,000 arrays in about 1.3 seconds. Seems like some pretty good optimization: a 10x increase in elements only increases the runtime by about 4x. Could it be a O(log n) complexity? I'm not quite sure about why this performs this way, but it may be inherent to the ways functional programing concepts are implemented.

    And finally, here is an online compiler showing it working: https://scastie.scala-lang.org/uEvBr82dTMyMKfoZmQhosQ

    On Scastie, my average times were .4 seconds for 1,000 elements and 3.5 seconds for 10,000 elements. In other words, about a 9x increase in runtime for a 10x increase in number of elements. So, not as great as it ran on my machine, but still faster than a O(n) complexity.

    Overall, this was a fun problem to do. Even though I didn't do most of the work (that credit goes to the Scala Developers for the stdlib), it was a great practice for reading documentation (and stack overflow :) ). It did take me an embarrassingly long time to find all that documentation for a language I barely know, but I still enjoyed it.

    I'll keep this write-up and the source code on Github for anybody who wants to look at it later: https://github.com/mnxn/Merge-and-Sort-Arrays.Scala

    7 votes
  5. Comment on <deleted topic> in ~games

    min
    Link Parent
    As far as I'm aware, there are no Blizzard games on Steam, everything is on Battle.net, which Blizzard owns. They won't have to strong-arm anything if they control their own store. Even if they...

    As far as I'm aware, there are no Blizzard games on Steam, everything is on Battle.net, which Blizzard owns. They won't have to strong-arm anything if they control their own store. Even if they did have it on Steam, I believe it's pretty easy to region lock games, as there are numerous games blocked in certain countries.

    14 votes
  6. Comment on "Disable SMT/Hyperthreading in all Intel BIOSes" in ~comp

    min
    Link Parent
    I remember hearing that name pop up around some articles a while back but never actually looked into it. Just watched LTT's new video and it looks pretty cool. I think I'll play around with the...

    I remember hearing that name pop up around some articles a while back but never actually looked into it. Just watched LTT's new video and it looks pretty cool. I think I'll play around with the instruction set and see if I can teach to some other people at a club I co-lead.

    3 votes
  7. Comment on "Disable SMT/Hyperthreading in all Intel BIOSes" in ~comp

    min
    Link Parent
    Yeah I acknowledge the fact that AMD has an equivalent technology, and while I'd rather have neither, from what information I can find seems that the IME has had a lot more dangerous...

    Yeah I acknowledge the fact that AMD has an equivalent technology, and while I'd rather have neither, from what information I can find seems that the IME has had a lot more dangerous vulnerabilities compared to AMD's PSP (They still did have some). It's pretty shocking how little control we have with our hardware, when you compare it to software, maybe it's time for a 100% open source CPU to take over, but I doubt any of the current manufactures would be very happy with that and Intel's anti-competitive practices are no joke.

    4 votes
  8. Comment on "Disable SMT/Hyperthreading in all Intel BIOSes" in ~comp

    min
    Link
    I built my last PC just a bit over a year ago with an Intel 7700k and the amount of vulnerabilities with the architecture and the monstrosity that is the Intel Management Engine makes me really...

    I built my last PC just a bit over a year ago with an Intel 7700k and the amount of vulnerabilities with the architecture and the monstrosity that is the Intel Management Engine makes me really wish I had went with a Ryzen 7 when I had the chance. I got 50% off on the CPU and my whole build still cost more than if it was a Ryzen platform because of how expensive Z170 motherboards were and the fact that you practically need a water cooler to keep temperatures manageable. Unlike Intel, AMD lets you overclock their CPUs on their mid-tier motherboards. They also solder the IHS to the CPU die instead of using the horrible TIM that Intel seems to be infatuated with (Intel even uses it on their ~$2000 "Enthusiast" CPUs), and if you want to de-lid your Intel CPU to put on liquid metal or a better TIM, you get your warranty voided. My next CPU is absolutely going to be from AMD, especially if they get 7nm out quickly; the extra cores could certainly help with Blender.

    8 votes
  9. Comment on What computer/programming/etc. project are you working on this weekend? in ~comp

    min
    Link Parent
    Most developers should learn how to use CMake, just based on the sheer volume of projects using it, and the earlier you learn it the better. I also found Meson which can generate Ninja, Visual...

    Most developers should learn how to use CMake, just based on the sheer volume of projects using it, and the earlier you learn it the better. I also found Meson which can generate Ninja, Visual Studio, and XCode build scripts/projects files in a much more readable syntax. Might be worth looking into after you learn CMake

    3 votes
  10. Comment on Programming Mini-Challenge: TicTacToeBot in ~comp

    min
    Link
    This took way longer than it should, but that's probably expected when learning a new language. I decided to do this challenge in Scala and made use of the grouped and sliding methods in the Scala...

    This took way longer than it should, but that's probably expected when learning a new language.

    I decided to do this challenge in Scala and made use of the grouped and sliding methods in the Scala standard library in order to split up a string that represented the board and check whether there were three 'X's or 'O's in a row. I couldn't think of anything better for diagonals, so I had to resort just manually checking the indices. I didn't feel that this challenge was large enough in size to need to setup a whole SBT project with ScalaTest, so I ran some simple checks within the same file. I used @Celeo 's test cases (Thanks!) and they all appear pass.

    Here's the source code in a gist: https://gist.github.com/mnxn/a84c2fdd2c7f99e40882f2efac1a8694

    And here it is in Scastie, so you can run it: https://scastie.scala-lang.org/rLeWuw13QGqfVaQZRNdz8g

    Thank you for the challenge, I needed something to do and I could certainly use more practice with Scala.

    4 votes
  11. Comment on I'm sorry for the silly question, but where is the search function? in ~tildes

    min
    Link Parent
    No, not some. All.

    No, not some.

    All.

    14 votes
  12. Comment on What games have you guys been playing lately? Yall stick to a certain genre or play anything? in ~games

    min
    Link
    I just finished Batman: Arkham City and Batman: Arkham Knight, putting in about 30 hours for each of them on PC. The initial PC release for Arkham Knight was quite dreadful, but after updates and...

    I just finished Batman: Arkham City and Batman: Arkham Knight, putting in about 30 hours for each of them on PC. The initial PC release for Arkham Knight was quite dreadful, but after updates and community tweaks it runs quite well (120+ fps for a GTX 1070 on 1080p maxed settings). Both have open worlds (I think Knight's is 5x the size of City's) and excellent, fluid movement. The combat is probably the best I've ever played in any game; the series is commended for it often. The bat-mobile in Knight seemed a little overused but was still a fun experience. The story isn't too hard to follow and I could understand most references without having consumed any other Batman themed content. Without spoiling anything, I would say I enjoyed Arkham Knight's story more and it had more of an impact on me.

    All-in-All, two extremely well made games with tons of content in them and a satisfying combat system that really makes you feel like batman. All I have left to do in those two games is to finish up the in-game collectables, and then wait for the other two games in the series, Arkham Asylum and Arkham Origins, to go on sale.

    2 votes
  13. Comment on ~Random acts of Steam Sale in ~games

  14. Comment on ~Random acts of Steam Sale in ~games

    min
    Link Parent
    Do you still have FEZ? I absolutely adore the premise and movement between 2D and 3D worlds has always intrigued me after I played Super Paper Mario. I'd love to play it. Thanks!

    Do you still have FEZ? I absolutely adore the premise and movement between 2D and 3D worlds has always intrigued me after I played Super Paper Mario. I'd love to play it.

    Thanks!

  15. Comment on NVIDIA Reveals Titan V CEO Edition with 32 GB HBM2 VRAM in ~tech

    min
    Link
    I assume it's called that because only a CEO will be able to afford one in the current state of GPUs.

    I assume it's called that because only a CEO will be able to afford one in the current state of GPUs.

    17 votes
  16. Comment on Programming Challenge: creative FizzBuzz in ~comp

    min
    Link Parent
    That would work, but as far as I know, browser JS will always have a a trailing newline when using console.log. So, a number divisible by 15 would output Fizz Buzz Not the intended FizzBuzz If...

    That would work, but as far as I know, browser JS will always have a a trailing newline when using console.log.

    So, a number divisible by 15 would output

    Fizz
    Buzz
    

    Not the intended

    FizzBuzz
    

    If using NodeJS, you can do process.stdout.write() to have a print()-like statement, as opposed to console.log(), which is like println(). To achieve this with browser JS, you would need to use temporary variables.

  17. Comment on Programming Challenge: creative FizzBuzz in ~comp

    min
    Link Parent
    By using else if you can trim that down. That way, the interpreter won't have to check the value of I 4 times. It would stop after the first statement is true. You can certainly get even more...

    By using else if you can trim that down. That way, the interpreter won't have to check the value of I 4 times. It would stop after the first statement is true. You can certainly get even more concise, but I think it's a nice balance of readability and length.

    for (var i = 1; i <= 100; i++) {
        if (i % 15 == 0) console.log('fizzbuzz');
        else if (i % 3 == 0) console.log('fizz');
        else if (i % 5 == 0) console.log('buzz');
        else console.log(i);
    }
    
    2 votes
  18. Comment on Favorite Laptop? in ~tech

    min
    Link
    I have a MSI GS40 with a 970m, but when I built my desktop I stopped gaming on the laptop, so it was basically a waste of money. If I were to go a for a new laptop, it would have to be Dell XPS 13...

    I have a MSI GS40 with a 970m, but when I built my desktop I stopped gaming on the laptop, so it was basically a waste of money.

    If I were to go a for a new laptop, it would have to be Dell XPS 13 or Dell Inspiron 13 7370. Those things are nice and thin with a long battery, something my current laptop really isn't.

    1 vote
  19. Comment on Text Formatting in ~tildes

    min
    Link Parent
    Thank you for the clarification. I remember dealing with escaping characters quite a bit on Reddit.

    Thank you for the clarification. I remember dealing with escaping characters quite a bit on Reddit.

    3 votes