What the AIs say
All solutions implement the exact same algorithm to handle commas and escaped double quotes correctly. Solutions Gemini 3.1 Flash Lite, Gemini 3.5 Flash, and Gemini 3.8 Flash use a descriptive function name, with Gemini 3.8 Flash having slightly better variable naming, while Nemotron 3 Ultra uses a generic function name 'solve'.
Gemini 3.1 Flash Lite
Google
The function iterates through each character of the string, maintaining an 'inQuotes' state to handle commas inside quoted fields. It correctly processes escaped quotes (double quotes) by skipping the next character if it is also a quote. When a comma is encountered outside of a quoted block, it splits the field. Finally, it pushes the accumulated string into the result array.
function parseCSVLine(line) {
const result = [];
let current = '';
let inQuotes = false;
for (let i = 0; i < line.length; i++) {
const char = line[i];
if (char === '"') {
if (inQuotes && line[i + 1] === '"') {
current += '"';
i++;
} else {
inQuotes = !inQuotes;
}
} else if (char === ',' && !inQuotes) {
result.push(current);
current = '';
} else {
current += char;
}
}
result.push(current);
return result;
}
Gemini 3.5 Flash
Google
Iterates through the input string character by character while keeping track of whether the current position is inside double quotes. Handles escaped quotes (represented as two double quotes in a row) and splits fields by commas only when outside of quoted sections.
function parseCSVLine(line) {
const result = [];
let current = '';
let inQuotes = false;
for (let i = 0; i < line.length; i++) {
const char = line[i];
if (char === '"') {
if (inQuotes && line[i + 1] === '"') {
current += '"';
i++;
} else {
inQuotes = !inQuotes;
}
} else if (char === ',' && !inQuotes) {
result.push(current);
current = '';
} else {
current += char;
}
}
result.push(current);
return result;
}
Gemini 3.8 Flash ★
Google
The function iterates through the input string character by character while tracking whether it is currently inside double quotes. If it encounters a quote inside a quoted section followed immediately by another quote, it treats it as an escaped quote. Unquoted commas act as delimiters, pushing accumulated characters into the fields array and resetting the buffer. Finally, the remaining accumulated field is appended and the resulting array is returned.
function parseCSVLine(line) {
const fields = [];
let current = '';
let inQuotes = false;
for (let i = 0; i < line.length; i++) {
const char = line[i];
if (char === '"') {
if (inQuotes && line[i + 1] === '"') {
current += '"';
i++;
} else {
inQuotes = !inQuotes;
}
} else if (char === ',' && !inQuotes) {
fields.push(current);
current = '';
} else {
current += char;
}
}
fields.push(current);
return fields;
}
Nemotron 3 Ultra
NVIDIA
Parses a single CSV line by iterating characters, toggling quote state on unescaped double quotes, treating commas as delimiters only outside quotes, and handling escaped quotes ("") inside quoted fields. Returns array of field strings.
function solve(line) {
const fields = [];
let field = '';
let inQuotes = false;
for (let i = 0; i < line.length; i++) {
const c = line[i];
if (c === '"') {
if (inQuotes && line[i + 1] === '"') {
field += '"';
i++; // skip escaped quote
} else {
inQuotes = !inQuotes;
}
} else if (c === ',' && !inQuotes) {
fields.push(field);
field = '';
} else {
field += c;
}
}
fields.push(field);
return fields;
}