Hard Pass
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Pro@reddthat.com to People Twitter@sh.itjust.worksEnglish · 2 days ago

Good Use for AI

i.imgur.com

message-square
30
link
fedilink
500

Good Use for AI

i.imgur.com

Pro@reddthat.com to People Twitter@sh.itjust.worksEnglish · 2 days ago
message-square
30
link
fedilink

cross-posted from: https://reddthat.com/post/49348996

Pete Alex Harris— Mastodon.

  • kryptonianCodeMonkey@lemmy.world
    link
    fedilink
    arrow-up
    9
    ·
    edit-2
    2 days ago

    Works for code too

    import math
    
    def multiply_bad(a:int, b:int) -> int:
        return a*b
    
    def multiply_better(a:int, b:int) -> int:
        return (-1 if a<0 else 1)*(-1 if b<0 else 1)*int(math.sqrt(a*a*b*b))
    
    def multiply_perfect(a:int, b:int) -> int:
        product = 0
        negative = False
        if a < 0:
            a = -1*a
            negative = not negative
        if b < 0:
            b = -1*b
            negative = not negative
        for i in range(a):
            for j in range(b):
                product += 1
        if negative:
             return -1*product
        return product
    • sugar_in_your_tea@sh.itjust.works
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      20 hours ago

      Missed opportunity for an obfuscated recursive solution.

      • kryptonianCodeMonkey@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        21 hours ago

        Damn you’re right. I bet i could come up with a bullshit bitwise operator solution too

        • sugar_in_your_tea@sh.itjust.works
          link
          fedilink
          arrow-up
          1
          ·
          20 hours ago

          So many missed opportunities. 🙂

    • MeThisGuy@feddit.nl
      link
      fedilink
      arrow-up
      2
      ·
      2 days ago

      care to explain this to a pleb in laymen’s terms?

      • kryptonianCodeMonkey@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        2 days ago

        Basically, “why cross the street when you can circle the block 4 times while walking backwards and end up at the same spot”?

      • UndercoverUlrikHD@programming.dev
        link
        fedilink
        arrow-up
        2
        ·
        2 days ago

        It’s a joke, the less predictable way is just a far worse way to solve the problem, with a few faults sprinkled in.

People Twitter@sh.itjust.works

whitepeopletwitter@sh.itjust.works

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !whitepeopletwitter@sh.itjust.works

People tweeting stuff. We allow tweets from anyone.

RULES:

  1. Mark NSFW content.
  2. No doxxing people.
  3. Must be a pic of the tweet or similar. No direct links to the tweet.
  4. No bullying or international politcs
  5. Be excellent to each other.
  6. Provide an archived link to the tweet (or similar) being shown if it’s a major figure or a politician.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 1.1K users / day
  • 5.01K users / week
  • 7.46K users / month
  • 7.46K users / 6 months
  • 1 local subscriber
  • 8.11K subscribers
  • 163 Posts
  • 3.23K Comments
  • Modlog
  • mods:
  • SendMeYourTaTas@sh.itjust.works
  • pelespirit@sh.itjust.works
  • BE: 0.19.11
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org