ubergeek77's Lemmy
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Pro@reddthat.com to People Twitter@sh.itjust.worksEnglish · 9 days ago

Good Use for AI

i.imgur.com

message-square
30
fedilink
508

Good Use for AI

i.imgur.com

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

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

Pete Alex Harris— Mastodon.

  • kryptonianCodeMonkey@lemmy.world
    link
    fedilink
    arrow-up
    9
    ·
    edit-2
    8 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
    • MeThisGuy@feddit.nl
      link
      fedilink
      arrow-up
      2
      ·
      8 days ago

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

      • kryptonianCodeMonkey@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        8 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
        ·
        8 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.

    • sugar_in_your_tea@sh.itjust.works
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      7 days ago

      Missed opportunity for an obfuscated recursive solution.

      • kryptonianCodeMonkey@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        7 days 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
          ·
          7 days ago

          So many missed opportunities. 🙂

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: [email protected]

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.

  • 2.55K users / day
  • 3.9K users / week
  • 8.36K users / month
  • 19.6K users / 6 months
  • 1 local subscriber
  • 8.15K subscribers
  • 1.32K Posts
  • 46.5K Comments
  • Modlog
  • mods:
  • SendMeYourTaTas@sh.itjust.works
  • pelespirit@sh.itjust.works
  • BE: 0.19.7
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org