Kod yazdırma (LeetCode problemi)
Bilmeyenler için LeetCode, yazılım geliştiricilere kodlama pratiği yapma imkânı sunan popüler bir platformdur. İçerisinde yer alan çeşitli zorluk seviyelerindeki problemler, kullanıcıların algoritma ve veri yapıları konusundaki becerilerini geliştirmelerine yardımcı olur.
Biz de LeetCode platformunda yer alan bir problemi yapay zeka modelleri ile çözmeye çalıştık.
- OpenAI GPT-4’ün yazdığı kod:
class Solution {
func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
var numToIndex = [Int: Int]()
for (index, num) in nums.enumerated() {
let complement = target - num
if let complementIndex = numToIndex[complement] {
return [complementIndex, index]
}
numToIndex[num] = index
}
// Since the problem guarantees exactly one solution, we should never reach here.
return []
}
}
Kod testi geçti. LeetCode tarafından kabul edildi.
- OpenAI O1’ün yazdığı kod:
class Solution {
func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
// Create a dictionary to map each number to its index
var indexMap = [Int: Int]()
// Iterate over the array
for (index, value) in nums.enumerated() {
let complement = target - value
// Check if the complement value is already in the dictionary
if let complementIndex = indexMap[complement] {
// If so, return the indices
return [complementIndex, index]
}
// Add the current number and its index to the dictionary
indexMap[value] = index
}
// In theory, the problem guarantees a solution, so this should never execute.
return []
}
}
Kod testi geçti. LeetCode tarafından kabul edildi.
- Google Gemini 1.5 Pro’nun yazdığı kod:
class Solution {
func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
var numIndices = [Int: Int]() // Dictionary to store number and its index
for (index, num) in nums.enumerated() {
let complement = target - num
if let complementIndex = numIndices[complement] {
return [complementIndex, index]
}
numIndices[num] = index
}
return [] // Should never reach here as per problem statement
}
}
Kod testi geçti. LeetCode tarafından kabul edildi.
- Google Gemini 2.0 Flash’ın yazdığı kod:
class Solution {
func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
var numMap = [Int: Int]()
for (index, num) in nums.enumerated() {
let complement = target - num
if let complementIndex = numMap[complement] {
return [complementIndex, index]
}
numMap[num] = index
}
return []
}
}
Kod testi geçti. LeetCode tarafından kabul edildi.
- Anthropic Claude 3.5’un yazdığı kod:
class Solution {
func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
// Dictionary to store complement values and their indices
var numDict = [Int: Int]()
// Iterate through the array
for (index, num) in nums.enumerated() {
// Calculate the complement needed
let complement = target - num
// If complement exists in dictionary, we found our pair
if let complementIndex = numDict[complement] {
return [complementIndex, index]
}
// Store current number and its index
numDict[num] = index
}
// This line should never be reached given the problem constraints
return []
}
}
Kod testi geçti. LeetCode tarafından kabul edildi.
- Grok 2’nin yazdığı kod:
class Solution {
func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
// Use a dictionary to store the complement of each number
var numToIndex = [Int: Int]()
for (index, num) in nums.enumerated() {
// Calculate the complement
let complement = target - num
// If the complement exists in the dictionary, we found our pair
if let complementIndex = numToIndex[complement] {
return [complementIndex, index]
}
// Add the current number and its index to the dictionary
numToIndex[num] = index
}
// If no solution is found, which shouldn't happen given the problem constraints
return [] // This line should never be reached according to the problem statement
}
}
Kod testi geçti. LeetCode tarafından kabul edildi.
- DeepSeek R1’in yazdığı kod:
class Solution {
func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
var dict = [Int: Int]()
for (index, num) in nums.enumerated() {
let complement = target - num
if let complementIndex = dict[complement] {
return [complementIndex, index]
}
dict[num] = index
}
return []
}
}
Kod testi geçti. LeetCode tarafından kabul edildi.
- DeepSeek V3’ün yazdığı kod:
class Solution {
func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
var numMap = [Int: Int]() // Stores number to index mapping
for (index, num) in nums.enumerated() {
let complement = target - num
if let complementIndex = numMap[complement] {
return [complementIndex, index]
}
numMap[num] = index
}
return [] // This line will never be reached as per problem statement
}
}
Kod testi geçti. LeetCode tarafından kabul edildi.
- Kimi K1.5’un yazdığı kod:
class Solution {
func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
var map = [Int: Int]()
for (i, num) in nums.enumerated() {
let complement = target - num
if let complementIndex = map[complement] {
return [complementIndex, i]
}
map[num] = i
}
return []
}
}
Kod testi geçti. LeetCode tarafından kabul edildi.
Final
Bu içeriğimizde OpenAI GPT-4o, OpenAI O1, Google Gemini 1.5 Pro, Google Gemini 2.0 Flash, Anthropic Claude 3.5, DeepSeek V3, DeepSeek R1 ve Kimi K1.5’u karşılaştırdık. Peki en iyi yapay zeka dil modeli hangisi?
Metin yazdırma testimizde belirlediğimiz karakterler hikayede başarıyla yer aldı. Ancak OpenAI O1 dışında hiçbir model, 300 kelime sınırına uymadı. YKS AYT matematik ve Türkçe paragraf testinde ise hepsi başarılı oldu. Bu kod yazdırma (LeetCode problemi çözdürme) için de geçerliyken İngilizce’den Türkçe’ye çeviri yapma kısmında ufak bir fark var.
Çeviri kısmında genel olarak hepsi başarılıyken Google Gemini 2.0 Flash ve Grok 2’nin virgül kullanımı konusunda daha dikkatli olduğunu söyleyebilmek mümkün.
Peki siz bu konu hakkında neler düşünüyorsunuz? Sizce en iyi yapay zeka dil modeli hangisi? Görüşlerinizi aşağıdaki Yorumlar kısmından bizimle paylaşabilirsiniz.
Yani tamam yapmak istediginiz sey guzel ama en kolay leetcode problemini sormussunuz, bu modeller icin cerez bir soru
Iyi bir yazilimci olarak soyleyebilecegim set, leetcode un gidip en basit sorusunu alip sormussunuz, boyle karsilastirmalarda kolaydan zora bir kac soru alip hepsini sorup kac tanesini cozebildigine bakmaniz gerekir. Boyle bir ise girismeniz iyi ama daha kayda deger bir karsilastirma yapmak istiyorsaniz, yaptiginiz her testte kucuk iyilestirmelere ihtiyaciniz var.
Sen daha klavyene türkçe karakter ekleyememişsin, kolaydan zora kendini, bilgi birikimini sorgula.
içerik sahibi dayanamayıp patlamış sonunda 🙂
yani tamamda bir doçent doktor olarak şunu söylemek istiyorum leetcode un en basitini sormuşsunuz
BEBCE TAVBŞJŞR DE CHAT GPT NWDEN DİTE SORACAK olursanız akıllı olması iye yanıt veririm diğeri sanki oyuncak gib i derim.
Deep Seek ve ChatGPT’yi karşılaştırdığımda aradaki fark inanılmazdı. ChatGPT, her biri destansı detaylara sahip uzun ve anlamlı hikayeler üretirken, Deep Seek ise basit, tek kelimelik başlıklarla 100 karakterlik yüzeysel metinler oluşturdu. ChatGPT’nin yanında Deep Seek, tam anlamıyla “Çin malı” benzetmesini hak eden, yanına bile yaklaşamayacak seviyede kaldı.
DeepSeek bazı alanlarda ChatGPT’den iyi ama ChatGPT ücretli sürümlerini deneyip aradaki farkı görmek lazım
chatgpt nin yerini hiç bir şey tutamaz şimdilik istediğim programı yaptırıyorum diğerlerini aynı şey yapmasını istediklerimde saçma sapan betikler sunuyorlar
çok basit test çok anlamsız sorular. kimse 300 den ne 1 az ne 1 fazla kelime içeren bir hikaye istemez, bu çok anlamsız. kod da çok basit burdaki tüm yapay zekaların veri setinde 500 tane aynı örnek var zaten. biraz iq gerektiren şeyler sorun, şaşırtmacalı şeyler sorun, tüm tyt sözel ve ayt sözeli çözdürün mesela soyut düşünme becerisini ölçün
deepseek güzellmesi yapmıssın.