Sly32

Рейтинг
367
Регистрация
29.03.2012
ArbNet:
Sly32, В вашем курятнике и без меня нормально.
Вы не принимаете участие в решении моих задач так как они для вас сложны, а мне на ваши детские задачки нет смысла тратить своё время, мне и так есть чем заняться, в отличие от вас..

Так и запишем -ArbNet, джуновскую задачку решить не смог )) Отмазки не прокатывают. Я думаю тут всем кто решал - есть чем заняться, однако с радостью включились

ArbNet:
Sly32, in your chicken coop without me normalno.Vy not take part in solving my problems because they are difficult for you and me to your children tasks does not make sense to spend their time, and so I have something to do, unlike you ..

So we write - ArbNet, dzhunovskuyu task could not solve)) Excuses are not rolled. I think here all who decide - to have something to do, but gladly joined

Gerga:
Идет чтение потока до определенного символа либо length параметра

Мне кажется, у тебя в output останется лишняя запятая в конце

Gerga:
Reading flow goes to a certain symbol or length parameter

I think, in your output will be an extra comma at the end of

timo-71:
У меня например, запускалось примерно в таких условиях

Ты б еще мельче скрин выложил)

timo-71:
I for example, to run about in such conditions

You'd even put smaller screen)

ArbNet, Приходи в топик для программистов - порешаем задачки, ждем твое решение)

ArbNet, Come to the topic for programmers - poreshat tasks, waiting for your decision)

Вот полностью рабочий код с посимвольным вычитыванием на Питон


import json
import time


def truncate_row(data):
start = time.time()
with open('res-task-1.json', 'w') as res:
res.write('[') with open(data) as f:
pos = 1
flag = False
js = ''
while pos:
char = f.read(pos)
if char == ']':
break
if char == '{':
flag = True
if flag:
js += char
if char == '}':
flag = False
data = json.loads(js)
if data.get('scores') >= 0.7:
res.write(json.dumps(data)+',')
js = ''
size = res.tell()
res.truncate(size - 1)

with open('res-task-1.json', 'a') as res:
res.write(']')
print(f'Executing time: {time.time() - start}')


truncate_row('task-1.json')

Executing time: 0.2150096893310547

Выходной файл валидный)

Это конечно очень грубо, можно еще оптимизировать

И просьба ко всем - приводить полностью листинг программы, чтобы можно было запустить и почекать время)

---------- Добавлено 15.06.2020 в 10:47 ----------

Gerga:
На php он может быть еще короче, если не читать посимвольно.

Это уже будет нарушением условий задачи)

Here is a fully working code character by character subtraction on Python


import json
import time


def truncate_row (data):
start = time.time ()
with open ( 'res-task-1.json', 'w') as res:
res.write ( '[') with open (data) as f:
pos = 1
flag = False
js = ''
while pos:
char = f.read (pos)
if char == ']':
break
if char == '{':
flag = True
if flag:
js + = char
if char == '}':
flag = False
data = json.loads (js)
if data.get ( 'scores')> = 0.7:
res.write (json.dumps (data) + ',')
js = ''
size = res.tell ()
res.truncate (size - 1)

with open ( 'res-task-1.json', 'a') as res:
res.write ( ']')
print (f'Executing time: {time.time () - start} ')


truncate_row ( 'task-1.json')

Executing time: 0.2150096893310547

The output file is valid)

This course is very tough, can be further optimized

And the request to all - is the full listing of the program to be able to run and pochekat time)

---------- Posted 06.15.2020 at 10:47 ----------

Gerga:
On php it can be even shorter if you do not read character by character.

It will be a violation of the conditions of the problem)

Всего: 7118