Skip to content
TheChatArchiveThe Chat Archive
gpt-4.1-mini-2025-04-14· OpenAIHugging Face LMArena Human Preference 140K

napisz funkcję dodawania macierzy

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Googlegemma-3-27b-it’s answer.
  1. User

    napisz funkcję dodawania macierzy

  2. Assistant

    Jasne! Oto przykładowa funkcja w Pythonie, która dodaje dwie macierze:

    def dodaj_macierze(A, B):
        # Sprawdzenie, czy macierze mają ten sam rozmiar
        if len(A) != len(B) or len(A[0]) != len(B[0]):
            raise ValueError("Macierze muszą mieć ten sam rozmiar")
        
        # Tworzymy nową macierz wynikową
        wynik = []
        for i in range(len(A)):
            wiersz = []
            for j in range(len(A[0])):
                wiersz.append(A[i][j] + B[i][j])
            wynik.append(wiersz)
        
        return wynik
    
    # Przykład użycia:
    A = [[1, 2, 3],
         [4, 5, 6]]
    
    B = [[7, 8, 9],
         [10, 11, 12]]
    
    print(dodaj_macierze(A, B))
    # Wynik: [[8, 10, 12], [14, 16, 18]]
    

    Jeśli chcesz, mogę też napisać wersję w innym języku programowania.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.