user-pic

Veesh

  • About: I do full-stack development with Mojolicious and Vue.
  • Posted Solving two problems to Veesh

    A Regular Question

    This weeks perl weekly challenge had a pretty straightforward question: take a string and split it when the characters change. That's a fairly straightforward regex issue:

    perl -pE's/(.) \g1*/$& /gx'
    

    Here we mat…

  • Commented on Greed is good, balance is better, beauty is best.
    You are literally insane. Thank you for writing such beautiful articles every week. (I happen to love TeX, so this is MEGA intriguing for me)...
  • Posted Up, up and Away! to Veesh

    This week's perl weekly challenge was a lot of fun. First of all, challenge number 2 was a breeze. The challenge was to parse and print the components of a URL. That was easy...

    use Mojo::URL;
    
    my $url = Mojo::URL->new(shift);
    say <<"ANSWER"
    scheme:   $…
  • Commented on Pizza Party for 100
    In all honesty, it was intuition. I tried it out with a couple of values, and it seemed to confirm the square root idea. Perhaps I'll be able to mathematically prove it one day. This week's ackermann question is pretty...
  • Commented on Pizza Party for 100
    Plan on it. I'm gonna try to write some perl 6 one of these days. It's so cool, but super overwhelming....
  • Posted Pizza Party for 100 to Veesh

    Hi all, this is my first blog post! Yay!

    Now that that's out of the way, I'd just like to go over my solution for this week's Perl weekly challenge.

    The first challenge was to divide a pie between 100 people, in a manner where the first guest gets 1/100 (i.e. 1%) of the pie, and th…

Subscribe to feed Recent Actions from Veesh

  • laurent_r commented on Pizza Party for 100

    I've tried to do the math and, if I got it right, it turns out that it is not exactly the square root, but it is pretty close (and the square root is probably right in practical terms).

    When guest n comes in, the rest of the cake can be called r. So, guest n gets r * n/100. And what is left after guest n has been served is r - (r * n/100) = r * (100 - n) / 100.

    Guest n+1 gets (r * (100 - n) / 100) * (n+1)/100. So guest n+1 gets more than guest n if r * (100 - n) / 100) * (n+1)/100 > r * n/100. Since r is a strictly positive number, we can remove r from both sides and simplify…

  • laurent_r commented on Pizza Party for 100

    Oops, the end of the third paragraph of my previous reply got somehow cut.

    ... This leads to: 100 - n² - n > 0. Or: n² + n

  • laurent_r commented on Pizza Party for 100

    (Again a problem).

    Oops, the end of the third paragraph of my previous reply got somehow cut.

    ... This leads to: 100 - n² - n > 0.

    Or: n² + n less than 100.

    We can easily see that guest n+1 will get more than guest n for n equal 3 to 9. In particular, for n = 9, guest 10 will get a larger share than guest 9. Subsequent guests will get less than their immediate predecessor and less than guest 10.

  • Gnustavo commented on Greed is good, balance is better, beauty is best.

    This is absolutely mind boggling!

  • vel commented on Greed is good, balance is better, beauty is best.

    Thanks a lot for the articles!

Subscribe to feed Responses to Comments from Veesh

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is hosted by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.