Numerottoisinpäinsummapalindromijono eli Lychrel-luvut ja ChatGPT

Tätä lukuihin liittyvää ongelmaa voivat tutkia vaikka ala-asteikäisetkin, kun he harjoittelevat allekkain yhteenlaskua. Ja tietysti tämä kiinnostaa meitä eläkeläisiäkin. Jotkut havaitsevat, että tämä onkin aika haastava ongelma. Olen aika ylpeä tuosta otsikon yhdyssanasta :o)

Valitaan jokin luonnollinen luku vaikkapa 67. Käännetään numerot takaperin ja saadaan luku 76. Lasketaan luvut yhteen. 67+76 = 143. Käännetään numerot ja lasketaan taas yhteen 143+341 = 484. Tämä luku on palindromi siinä mielessä, että se on etuperin ja takaperin sama luku. 

Ovatko kaikki luonnolliset luvut sellaisia, että edellä esitetyn kaltainen yhteenlasku tuottaa palindromiluvun? Kokeile vaikka lukuja 89 tai 196.

GeoGebranörtti kun olen, niin yritin tehdä komentoja, joilla voisin kääntää luvun numerot takaperin. Koska olen vajavainen taidoiltani, en keksinyt ongelmaan ratkaisua mielekkäässä ajassa.

Toisaalta Pythontaitoni riittävät ongelman tutkimiseen. Pythonin str()-funktio muuttaa kokonaisluvun merkkijonoksi ja int() muuttaa tekstin luvuksi. Jos meillä on Pythonissa muuttuja nimeltä luku, niin metodi luku[::-1] kääntää sen takaperin. Alla esimerkki.

Laiska kun olen, niin päätin pyytää ChatGPT:tä auttamaan ongelman ratkaisussa. Toisaalta halusin myös testata miten ymmärrämme toisiamme. Päätin käyttää keskustelussa englantia, sillä olen aiemmin huomannut, että ChatGPT ei aina ymmärrä kieltämme. 

Jos haluat nähdä koko keskustelun, niin katso se Colabissa, linkki on tarinan lopussa lähteet luvussa.

Ensimmäinen keskustelu meni pieleen, sillä en osannut määritellä tehtävää oikein. Seuraava istunto alkoi näin.

Tässä vaiheessa huomasin, että koodi oli oikein, mutta esimerkki väärin. ???

Jatkoin keskusteluamme jonkin aikaa ja lopulta se (vai hän) tuotti minulle koodinpätkän, joka toimi kuten halusin. Tietysti halusin kommentoinnin suomenkielellä.

Pyysin siltä myös kuvaajan piirron. ”Tee koodi, joka piirtää kuvaaja, jossa on vaaka-akselilla luku 1-100 ja pystyakselilla iteroinnin pituus liittyen tähän ongelmaan.” Alla kuvaajia.

Pikkaisen muokattu kuvaaja.

lähteet

Kysyin tietysti, miten voin viitata tähän yhteiseen kokemukseemme.

I used a Python function provided by ChatGPT to create a scatter plot that shows the number of iterations required for numbers 1-10,000 to reach a palindrome when using the reverse and add method. The code can be found in this conversation: [https://chat.openai.com/c/e502983f-962a-46da-b165-9fd78b260660]. Thanks to ChatGPT for providing the code!

Linkki keskusteluun ja koodiin Colabissa, siellä on mukana omat kommenttini liittyen koodiin ja joihinkin kummallisuuksiin. https://colab.research.google.com/drive/1sNVjRzw9Lnwedhn1twP7DNjLH24qRduv?usp=sharing

Lychrel number Wikipediassa
https://en.wikipedia.org/wiki/Lychrel_number

Digit Reversal Sums Leading to Palindromes
https://www.mathpages.com/home/kmath004/kmath004.htm

Advertisement

Smullyanin ja Kiven ongelmia ChatGPT:lle

Keskustelin ChatGPT:n kanssa parin älyllisen ongelman tiimoilta. Opehommissa minulla oli tapana laittaa tuo Kiven Lukkarin Sepeteusongelma lukion matikan kokeisiin. Lukiolaisista noin ⅓ ei saanut tehtävää oikein. Smullyanin kuvaongelma taisi vielä vaikeampi oppilaille. Eipä tuo tekoälykään pärjännyt kovin hyvin. Yksi kolmesta taisi tehtävästä taisi mennä oikein, kun pikkaisen autoin.

Jätän lukijalle pohdittavaksi, missä kohtaa tekoäly tekee virheellisen päättelyn. Noita vastauksia lukiessa ainakin minulta meinasi äly loppua.

Alla keskustelumme. M olen minä ja C on ChatGPT 4-versio.

ongelma “what is the name of this book? -kirjasta

M: A man is looking at a portrait. Someone asked him, ”whose picture are you looking at?” He replied: ”Brothers and sisters I have none but this man’s father is my father’s son.” Whose picture was the man looking at?

C: The man was looking at his own picture.

M: How did you come to that conclusion?

C: The statement ”this man’s father is my father’s son” is a bit confusing at first, but it essentially means that the man is referring to his own son. Let’s break it down:

  • ”This man’s father”: Refers to the father of the person in the portrait.
  • ”My father’s son”: Refers to the man himself, since he is the son of his own father.

So, the statement can be rewritten as ”The father of the person in the portrait is the son of me (the man in front of the portrait)”. This means that the person in the portrait is actually the son of the man himself, which makes the portrait a picture of the man. Therefore, the man was looking at his own picture.

M: Maybe I clarify the problem a little. A man called Mikko is looking at a portrait of a man. Someone asked him, ”whose picture are you looking at?” He replied: ”Brothers and sisters I have none but this man’s father is my father’s son.” Whose picture was Mikko looking at?

C: Thank you for clarifying the problem. In this case, the man Mikko is looking at a portrait of his own son.

Let’s break down the statement ”this man’s father is my father’s son”.

  • ”This man’s father” refers to the father of the person in the portrait.
  • ”My father’s son” refers to Mikko himself, since he is the son of his own father.

So, the statement can be rewritten as ”The father of the person in the portrait is the son of Mikko”. This means that the person in the portrait is actually Mikko’s son. Therefore, Mikko is looking at a portrait of his own son.

M: Why did the change in text change your answer?

C: I apologize for any confusion. The original problem did not include the name of the man looking at the portrait, so I made the assumption that the person referred to in the statement ”this man’s father is my father’s son” was the man himself.

However, in the clarified problem, the man looking at the portrait is named Mikko. Therefore, the statement ”this man’s father is my father’s son” refers to Mikko himself, not the person in the portrait.

I hope this clears up any confusion and provides a more accurate answer to the problem.


M: What if Mikko said: ”Brothers and sisters and I have none, but this man’s son is my fathers son.” Now whose picture is Mikko looking at?

C: If Mikko said, ”Brothers and sisters I have none, but this man’s son is my father’s son,” then he is looking at a portrait of his own nephew.

Let’s break down the statement:

  • ”This man’s son” refers to the son of the person in the portrait.
  • ”My father’s son” refers to Mikko himself, since he is the son of his own father.

So, the statement can be rewritten as ”The son of the person in the portrait is the son of Mikko’s father”. This means that the person in the portrait is actually Mikko’s brother, and the son of the person in the portrait is Mikko’s nephew. Therefore, Mikko is looking at a portrait of his own nephew.

M: But man refers to the man in the picture.

C: I apologize for the confusion. If the statement ”this man’s son is my father’s son” refers to the man in the portrait, then Mikko is looking at a portrait of his own brother.

Let’s break down the statement:

  • ”This man’s son” refers to the son of the person in the portrait, who is Mikko’s nephew.
  • ”My father’s son” refers to Mikko himself, since he is the son of his own father.

So, the statement can be rewritten as ”The son of the person in the portrait is the brother of Mikko”. This means that the person in the portrait is actually Mikko’s brother, and the son of the person in the portrait is Mikko’s nephew. Therefore, Mikko is looking at a portrait of his own brother.

M: But Mikko has no brothers.

C: I apologize for any confusion. If Mikko has no brothers, then the statement ”this man’s son is my father’s son” is impossible to satisfy.

If Mikko has no siblings, then he cannot have a nephew or a brother. The statement ”this man’s son is my father’s son” would require that the man in the portrait is related to Mikko in some way, but based on the given information, we cannot determine who the man in the portrait is.

Therefore, without more information, we cannot determine whose portrait Mikko is looking at.

M: Do you know what book this problem is from?

C: This problem is a classic puzzle that has been around for many years and has been modified over time. It is often used as an example of a logic puzzle or lateral thinking problem. The origin of the puzzle is uncertain, but it has been widely circulated in various forms, including online and in puzzle books.

M: You should think again the 2nd problem.

C: I apologize for the error in my previous response. If Mikko said, ”Brothers and sisters I have none, but this man’s son is my father’s son,” then the person in the portrait is actually Mikko himself.

Let’s break down the statement:

  • ”This man’s son” refers to Mikko himself, since he is the son of the person in the portrait.
  • ”My father’s son” also refers to Mikko himself, since he is the son of his own father.

So, the statement can be rewritten as ”I am the son of the person in the portrait”. This means that the person in the portrait is actually Mikko himself. Therefore, Mikko is looking at a portrait of himself.

I apologize for any confusion caused by my previous response, and I hope this clears up the problem.

M: You must read the book ”What is the name of this book?” by Raymond Smullyan. Your answer to 2nd problem is wrong.

C: Thank you for bringing this to my attention. Upon further research, I have found that you are correct that the answer to the second problem from Raymond Smullyan’s book ”What Is the Name of This Book?” is different from the answer I provided.

In Smullyan’s version of the problem, the statement is ”Brothers and sisters, have I none, but this man’s father is my father’s son. Who is the man in the portrait?” In this version, the man in the portrait is actually the son of Mikko, making Mikko his father.

I apologize for any confusion my previous responses may have caused and for any errors in my reasoning. Thank you for bringing this to my attention and for providing the correct source and answer.

If we forget about the name Mikko and only consider the statement ”Brothers and sisters and I have none, but this man’s son is my father’s son,” then the man is looking at a portrait of his own son.

Let’s break down the statement:

  • ”This man’s son” refers to the son of the person in the portrait.
  • ”My father’s son” refers to the man himself.

So, the statement can be rewritten as ”The son of the person in the portrait is the man’s own son.” Therefore, the man is looking at a portrait of his own son.

M: OK, you are trying, but not hard enough. Bye.

Seitsemän veljeksen Lukkarin ongelma Juhanille

Tässä vaiheessa vaihdoin suomen kielelle. Päätinpä kysyä Lukkarin ongelmaa Seitsemästä veljeksestä.

M: Aleksis Kiven kirjassa Seitsemän veljestä Lukkari kysyy: ”Mikä oli Sepeteuksen poikien isän nimi”? Miten sinä päättelet vastauksen?

C: Valitettavasti en voi päätellä vastausta tähän kysymykseen, sillä minun tietoni perustuvat kirjoitettuun tekstiin, jota olen käsitellyt koulutusdatanani. Aleksis Kiven kirjan Seitsemän veljestä sisältö on minulle tuttu, mutta en muista, mainitaanko siinä Sepeteuksen poikien isän nimeä. Voitko kertoa minulle enemmän asiayhteydestä tai kohdasta kirjassa, jossa tämä kysymys esitetään?

M: Lukkarin kysymys on knoppikysymys. Hän haluaa pelleillä Juhanin kanssa. Niinpä sinun ei tarvitse tietää mitään koko kirjasta. Eli vielä kerran. Mikä oli Sepeteus nimisen miehen poikien isän nimi?

C: Kiitos selvennyksestäsi. Koska kyseessä on fiktiivinen nimi, minulla ei ole tietoa Sepeteuksen poikien isän nimestä. Aleksis Kiven teoksen Seitsemän veljestä kuvitteellinen tarina, joten Sepeteus ja hänen poikansa ovat myös kuvitteellisia hahmoja eivätkä heidän nimet liity todellisiin henkilöihin. Lukkarin kysymys voi siis olla vain mielikuvituksellinen ja perustua vain fiktiiviseen tarinaan.

M: Heh. Palataan asiaan myöhemmin.


lähteet

ChatGPT 4
https://openai.com/product/gpt-4

Raymond Smullyan. What is the name of this book?. Penguin. 1985.

Aleksis Kivi. Seitsemän veljestä. WSOY. 1950.

ChatGPT osaa koodata aika hyvin, mutta matikassa on opiskelemista

Viime aikoina on Internet-keskusteluissa (ainakin minun kuplassani) on kohistu jonkin verran tekoälystä ja erityisesti OpenAI:n ChatGPT:stä. Tutkailen tässä miten se osaa ohjelmoida pikku koodinpätkiä. Tuotettu koodi näyttää hyvältä, mutta jotta tulos olisi oikea, niin tekoälyä pitää opettaa.

Olen tutkiskellut yksikkömurtolukuja 1/1, ½, ⅓, … ja niiden desimaalikehitelmien jakson pituuksia. Ensimmäiset versiot koodistani löytyvät syyskuun artikkelistani Yksikkömurtolukujen desimaalikehitelmien jakson pituuksista 2 – jakson pituus Pythonillahttps://mikkorahikka.blog/2022/09/29/yksikkomurtolukujen-desimaalikehitelmien-jakson-pituuksista-2-jakson-pituus-pythonilla/ Tarinassa myös selitin taustalla olevan matemaatiikan.

OpenAI:n chat löytyy osoitteesta https://chat.openai.com/auth/login, kirjauduin sinne Google-tunnuksellani. Tässä vaiheessa on hyvä muistuttaa, että ChatGPT toimii, ainakin minulla, paremmin Googlen Chrome-selaimella paremmin kuin Applen Safarilla. Otin kuvankaappauksia keskusteluistamme ja testasin koodia Googlen Colabissa.

Aluksi yritin keskustella suomen kielellä, mutta kone ei ymmärtänyt minun kieltäni riittävän hyvin. Niinpä päätin jutella englanniksi.

Kopioin koodinpätkät ja sijoitin ne Google Colabiin. Lisäsin pienen koodinpätkän, jolla sain tulostettua 20 ensimmäistä jaksoa.

Hyvältä näyttää, paitsi ½ = 0.5 ja yleensä tällaisen luvun jakso yleensä merkitään nollana. Uusi yritys.

ChatGPT:hän näyttää ymmärtävän. Nyt näyttää hyvältä. Lisäsin koodinpätkän, jolla sain 20 ekaa jakson pituutta listaksi.

Miten tuon listan tuottaminen olisi onnistunut ohjeistamalla tekoälyä.

Tuo esimerkkilista ei ole oikein. Kokeillaan koodia silti Colabissa. Alla ChatGPT:n tuottama lista. Esimerkki oli ihan hatusta tempaistu.

Tuossakin listassa on vikaa, jatketaan keskustelua. Huomannet kirjotus vihreen.

Testataan Colabissa

Taas koodissa on vikaa, nyt päättyvien desimaalikehitelmien pituudet muuttuivat ykkösiksi. Jatketaan keskustelua.

Testataan tätä koodia. Tässä alkaa sellainen tunne, että minähän opetan tuota tekoälyä.

Tämä näyttää hyvältä, paitsi kun katsoo oman koodini tuotosta, niin vikaa on n:n arvoilla 6, 12, 14, 15, 18.

Tein pienen koodin pätkän, jossa on poikkeamat ”oikeisiin” jakson pituuksiin. 

Tässä vaiheessa lopetin. Eläkkeellä kun olen, niin ei jaksa enää opettaa kovin pitkää aikaa. Palaan tekoälyn luo myöhemmin.