text_plain_output_1.png
import json

import re # Regular expressions

def flattener(pred):
    str_pred = str([row for row in pred])
    str_pred = str_pred.replace(', ', '')
    str_pred = str_pred.replace('[[', '|')
    str_pred = str_pred.replace('][', '|')
    str_pred = str_pred.replace(']]', '|')
    return str_pred

testDirectory = '/kaggle/input/abstraction-and-reasoning-challenge/test/'

def readTaskFile(filename):
    f = open(filename, 'r')
    data = json.loads(f.read())
    data['id'] = re.sub('(.*/)|(\\.json)', '', filename)
    f.close()
    return data

filename = testDirectory + '3b4c2228.json'
readTaskFile(filename)

def getNoopAnswer(filename):
    data = readTaskFile(filename)
    testSection = data['test']
    ident = data['id']
    numTests = len(testSection)
    answer = {}
    for i in range(numTests):
        answer[ident + '_' + str(i)] = flattener(testSection[i]['input'])
    return answer

filename = testDirectory + '3b4c2228.json'
getNoopAnswer(filename)