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.

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.