Skip to content

Instantly share code, notes, and snippets.

@syrm
Last active March 14, 2021 13:00
Show Gist options
  • Save syrm/ccb7e278942474e467007d87c170ae3d to your computer and use it in GitHub Desktop.
Save syrm/ccb7e278942474e467007d87c170ae3d to your computer and use it in GitHub Desktop.
Love compatibility test
<?php
/**
* Made in 2000 on a TI-92
* Executed again lots of years after for fun (in 2019) with a result of 99% compatibility with my wife.
* So i decided to retranscript it on PHP.
*/
class Person
{
public string $firstname;
public string $lastname;
}
$firstPerson = new Person();
$secondPerson = new Person();
echo "#############\n";
echo "# Love teSt #\n";
echo "#############\n\n";
echo "Première personne\n";
echo "=================\n";
$firstPerson->firstname = readline("Prénom : ");
$firstPerson->lastname = readline("Nom : ");
echo "\n";
echo "Seconde personne\n";
echo "=================\n";
$secondPerson->firstname = readline("Prénom : ");
$secondPerson->lastname = readline("Nom : ");
echo "\n";
$namesToCompute =
$firstPerson->firstname
. $firstPerson->lastname
. $secondPerson->firstname
. $secondPerson->lastname;
$charactersFound = [];
$charactersFrequencyOrdered = [];
$charactersFrequency = count_chars($namesToCompute, 1);
foreach (str_split($namesToCompute, 1) as $character) {
$charactersFrequencyOrdered[$character] = $charactersFrequency[ord($character)];
}
$numbers = array_values($charactersFrequencyOrdered);
$i = 0;
while (count($numbers) > 2) {
$i++;
$computedNumbers = [];
for ($offset = 0; $offset < count($numbers)-1; $offset++) {
$computedNumber = $numbers[$offset] + $numbers[$offset + 1];
if ($computedNumber > 9) {
$computedNumber = ((string) $computedNumber)[0] + ((string) $computedNumber)[1];
}
$computedNumbers[] = $computedNumber;
}
$numbers = $computedNumbers;
}
echo "Compatibilité : " . implode("", $numbers) . "%\n";
exit;
love()
Prgm
setGraph("Axes","OFF")
setMode("Exact/Approx","EXACT")
Loop
1->b
Dialog
Title "Love teSt"
Text ""
Text " nom prénom"
Request "Prénom",p1
Request "Nom",nom1
Request "Prénom",p2
Request "Nom",nom2
Text ""
EndDlog
If ok=0 Then
setGraph("Axes","ON")
setMode("Exact/Approx","APPROXIMATE")
Exit
EndIf
p1&nom1&p2&nom2->copy
""->l1
ClrDraw
PxlHorz 12
PxlHorz 27
PxlHorz 40
PxlText p1&" "&nom1,16,round((237-(dim(nom1)+dim(p1))*7)/2,0)
PxlText p2&" "&nom2,30,round((237-(dim(nom2)+dim(p2))*7)/2,0)
PxlHorz 50
PxlHorz 61
While dim(copy)>1
left(copy,1)->erf
0->b
1->z
Lbl lope
inString(copy,erf,z)->z
If z=0 Then
©right(copy,dim(copy)-1)->copy
Goto suite
EndIf
left(copy,z-1)&right(copy,dim(copy)-z)->copy
b+1->b
PxlText " ",52,0
PxlText copy,52,when(round((238-dim(copy)*7)/2,0)<0,0,round((238-dim(copy)*7)/2,0))
If z<dim(copy):Goto lope
Lbl suite
l1&string(b)->l1
EndWhile
l1&"1"->l1
1->h
1->k
While dim(l1)>2
""->l2
For a,1,dim(l1)-1
string(expr(mid(l1,a,1))+expr(mid(l1,a+1,1)))->gh
If dim(gh)=2:string(expr(mid(gh,1,1))+expr(mid(gh,2,1)))->gh
l2&gh->l2
EndFor
l2->l1
""->l2
If dim(l1)>2 Then
PxlText " ",52,0
PxlText l1,52,round((238-dim(l1)*8)/2,0)
EndIf
EndWhile
PxlText "<--|--> "&l1&" % <--|-->",52,59
If expr(l1)=69:PxlText " MagicCCCCCCCCCCCCCaaaaalllllll numberr",67,1
Pause
setGraph("Axes","OFF")
EndLoop
EndPrgm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment