# Basic word problem error

The questions in each code block comment were posted in OpenAI API. The answer given by this solution is 7. It should be 6. Further, the logic used to solve the problem seems very far afield from other word problem solutions I have seen.

``````/* Jack has 5 oranges. Jill has 2 oranges. If Jack takes one orange from Jill how many does Jill have? */
var jack = 5;
var jill = 2;
var jacksOranges = jack;
var jillsOranges = jill;
while (jillsOranges > 0) {
jillsOranges--;
jacksOranges++;
}
console.log(jillsOranges);
``````

In fact, a more difficult problem of “The birthday question” is solved correctly.

``````/* in a random group of 23 people what is the chance two people have the same birthday */
var birthdays = [];
for (var i = 0; i < 23; i++) {
birthdays.push(Math.floor(Math.random() * 365));
}
var uniqueBirthdays = [];
for (var i = 0; i < birthdays.length; i++) {
if (uniqueBirthdays.indexOf(birthdays[i]) === -1) {
uniqueBirthdays.push(birthdays[i]);
}
}
var chance = 1;
for (var i = 0; i < uniqueBirthdays.length; i++) {
chance *= (365 - i) / 365;
}
console.log(chance);
``````

The console output here is 0.5243046923374497

1 Like

I don’t see any controls in the sandbox to adjust model settings. Is there something I missed?

1 Like

Here’s something funny.

``````/* rotate it counterclockwise forever */
var rotate = document.createElement('div');
rotate.innerHTML = '<img src="http://i.imgur.com/QqfQz.gif" style="-webkit-animation: spin 2s linear infinite;">';
document.body.appendChild(rotate);
``````

what is this book and why is it here?

2 Likes

I don’t exactly remember the instruction I typed in sandbox, but it was similar to “Draw an image of how do you feel.” and it gave this exact image.

1 Like