1. 3

    Working on a rust bot for this very fun challenge. Currently in the top 30, but competition is fierce!

    1. 1

      Codingame frequently hosts programming challenges. For this challenge, you have to write a bot controlling a submarine, trying to locate your opponent in spite of incomplete information. You can pick the language of your choice from a rather large selection. This time I’m trying my hand at Rust and so far like it a lot! The challenge will last about a month.

      1. 5

        Are you planning to support lichess accounts? I’d love to try it 😊

        1. 12

          The truth is we already support lichess :) You only need to select it from the drop-down :)

          1. 1

            Cool! You might want to find a better title for your next posts then :-D

        1. 1

          I’ve been working on and off on a client/server version of this, with a persistent daemon process taking care of the database. I feel that would be a better design, as the work performed by the client after each key press would be really minimal. That daemon could also eventually be used for automating other parts of the CLI experience.

          1. 1

            I did consider this, but I didn’t want an entire process running on my computer for the sole purpose of serving me cd suggestions. Moreover, given how fast zoxide already is, I doubt that a client-server model would be a massive improvement.

            1. 2

              You’re right, I’m sure it’s fast enough. The main point would be to add more features in addition to jumping: a central daemon that talks to all your shells simultaneously could certainly help for many other things.

            2. 1

              Yeah, I’ve thought about this as well. Just couldn’t be bothered to figure out all the possible security implications, and never wanted it bad enough. But it could be the sort of generic project that opens up a lot of possibilities we don’t even see yet… Also, who doesn’t love over-engineering stuff ? :-)

              1. 1

                Right now I was thinking client/server on the same machine, using a UNIX socket for communication, so the security implications aren’t big. But maybe you’re right, and we could imagine a cloud-based version!

                I’ll try to ping you if I ever put something on GitHub :)

                1. 2

                  Yeah, please do. I shudder to think what the reaction of some folks on HN or here or reddit would be if you announce ‘I made a client-server version of cd’! :-)

                  1. 1

                    Lol, I’m old enough not to care anymore :)

            1. 3

              Applying to Google can be a great learning experience. But it’s too much work if you’re simply looking for a job. There are zillions of fine companies that don’t make you jump through hoops for three months before giving you a clear answer.

              1. 2

                Decompression performance is unfortunately not that great. I’m sure it has its uses, but probably not for general-public use.

                1. 3

                  I imagine it could be used for compression on slower machines (edge or sensors for instance) before transmitting over the network on larger machines. I’m curious about the memory requirements though.

                  1. 3

                    I skimmed the code and the decoder could be improved a lot, it’s not necessarily an issue with the format.

                    MTF is not ideal for general purpose compression though. The file tested in the readme is html and English text, i.e. a small alphabet with skewed frequencies, which is the best case for MTF. It will probably do significantly worse on binary files.

                  1. 9

                    “Responsibly mapping” and then including Taiwan into it, over which the PRC has about as much control as over any other neighboring country?

                    1. 1

                      You could argue it’s still part of China, which is composed of two states.

                      1. 8

                        Which would be roughly as sensible as grouping North and South Korea together.

                        1. 2

                          It can be, depending on what you’re talking about. Even though they live under very different regimes, North and South Korea are the same people. Same goes for China.

                          Not sure in this case though. Management of an epidemic is indeed a responsibility of the state.

                          1. 2

                            Okay, agreed, if we were to discuss e.g. the cultural response to things, then yes. Similarly to West/East Germany, but also Austria, at which point looking at it from the perspective of national states becomes somewhat meaningless.

                            In this case, less so, so including Taiwan only acknowledges the PRCs claim over the “Taiwan province”.

                    1. 3

                      Neat!!!

                      It’s not foolproof, of course. I was able to defeat it with large numbers:

                      def make_bigger(n: int) -> int:
                       '''
                       post: __return__ > 1
                       '''
                       return (n+333333)*(n+333333) +1
                      
                      make_bigger(5)
                      

                      I guess that’s expected though. An SMT solver can only do so much. And that’s probably not a huge issue in practice.

                      1. 2

                        Thank you for playing around with it!! I think your example falls into the “nonlinear integer arithmetic” space where Z3 cannot always find an answer.

                        That said, I think perhaps there isn’t a counterexample in your example. (n+333333) will be either positive or negative, and if it’s negative, the product will become positive. If we try something like (n+333333)*(n+333) +1 instead, we can sometimes get the result to be negative! example

                        1. 5

                          Ha! I am going to have to correct myself! Your condition does have a counterexample. make_bigger(-333333) gives a result of exactly 1 which I think is the one and only input that fails your post condition!

                          Perhaps, all the more reason that I need a computer to help me think about problems like this.😀

                          1. 1

                            Good job :) That was the point of the test, to have only one failing condition with a very big number, so something hard to find if you don’t know how to reason about quadratic equations, which I doubted the solver would be able to do.

                      1. 2

                        Can you use this with cmd.exe and bash as well? Or is it powershell only?

                        1. 3

                          Works with all three.

                          1. 2

                            Yes all three in a really nice package. In fact you can default to the Linux shell on loading Terminal.

                          1. 1

                            I’d much rather work fewer but longer days. I feel it would be more efficient since I need a few hours to get back in business every day.

                            1. 1

                              I agree with you but I don’t think the math still needs to work out to 40hrs (not sure if you are holding that constant). I would love three 12hrs instead, for instance. Then I can view that time more of a “performance” where you prepare and you go do your three days. 40hrs spread over 5 days is just so wasteful of employees time IMO