forked from binodkumar23/IITJ_IDDEDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutput_format.py
45 lines (35 loc) · 952 Bytes
/
output_format.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
"""output_format.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1L5lJxS8homLGeKeA_MlOIPX8-gSTT_Sp
"""
output = ""
def correct_soln(output):
l = output.split(',')
splits = [l[i].split(':') for i in range(len(l))]
distinct = []
distinct_values = []
for j in range(-1,-len(splits)+1,-1):
if splits[j][0] not in distinct:
distinct.append(splits[j][0])
distinct_values.append(splits[j])
distinct_values.remove(distinct_values[0])
return distinct_values
true_soln = correct_soln(output)
def make_vector(true_soln):
out = str(true_soln)
out_real = ''
for i in range(len(out)):
if out[i]=='[':
out_real+='{'
continue
if out[i] == ']':
out_real+='}'
continue
if out[i]=='\'':
out_real+="\""
else:
out_real+=out[i]
return out_real
cpp_vector = make_vector(true_soln)