General > General Technical Chat

Video: AI that generates code

<< < (8/15) > >>

Ed.Kloonk:

--- Quote from: xrunner on June 15, 2022, 11:32:22 am ---
--- Quote from: Ed.Kloonk on June 15, 2022, 11:12:24 am ---Good heavens.

--- End quote ---

Hold on Ed. I've read poetry by so-called "sentient" humans way worse.  :-DD

--- End quote ---

I wonder if it was trying to channel some Vogon poetry?

SilverSolder:

Looks like it needs more work, for sure!  :D

MK14:

--- Quote from: magic on June 15, 2022, 08:34:07 am ---Can it write "a Perl script which prints the value of a resistor given its three-letter EIA96 code"?
 :popcorn:

--- End quote ---

You shouldn't make jokes like that.  Or the HAL9000, AI might get angry, annoyed and do things.

On the second attempt, this is what it produced/said:


--- Quote ---write a Perl script which prints the value of a resistor given its three-letter EIA96 code.

my %eia96_code = (
  "100" => "brown",
  "101" => "red",
  "102" => "orange",
  "103" => "yellow",
  "104" => "green",
  "105" => "blue",
  "106" => "violet",
  "107" => "gray",
  "108" => "white",
);
my $eia96_code = <STDIN>;
chomp $eia96_code;
if (exists $eia96_code{$eia96_code}) {
   print "$eia96_code{$eia96_code}\n";
} else {
   print "Unknown code\n";
--- End quote ---

Third attempt:

--- Code: ---write a Perl script which prints the value of a resistor given its three-letter EIA96 code.

#!/usr/bin/perl -w
use strict;

my %colours = (
        "black" => 0,
        "brown" => 1,
        "red" => 2,
        "orange" => 3,
        "yellow" => 4,
        "green" => 5,
        "blue" => 6,
        "violet" => 7,
        "grey" => 8,
        "white" => 9 );


if(scalar @ARGV != 3) {die("Please provide a three letter code\n");}

  my $code=join('',@ARGV);

  if($code =~ /[^a-zA-Z]/) {die("Please provide a valid three letter code\n");}

  my @letters=split(//, $code);

  my $value = ($colours{lc $letters[0]} * 10 + $colours{lc $letters[1]}) * 10**$colours{lc $letters[2]};

  print "$value ohms\n";
--- End code ---

magic:
So I am not completely obsoleted by AI yet :phew:

The third attempt could be a working color band decoder, if not for its insistence on looking up single letters in a table indexed by full color names. I'm surprised that it completely missed the meaning of EIA96; the first search hits I get are a few websites with big-ass tables of "code - value" pairs, it should be plenty obvious. I wondered if it would use those tables or perhaps rip-off my shorter solution which I have posted here a few months ago.

tom66:
I think this is because it doesn't actually understand the problem, it just 'checks' its 'database' for a matching pattern.  Someone else has solved this before, and someone else has solved that before, so using natural language parsing, merge the two...

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod