Write it with golang. If I have a txt file, there's mutiple lines (over thousands) goes…
- User
Write it with golang. If I have a txt file, there's mutiple lines (over thousands) goes like this format for example: [ca/:1,1,1,3,2,224,136,84,255,183,15,113,90,183,15,113,90,183,15,113,90,0,0,0,0,0,0,0,0,0,0,0,0,3,4,7,10,4,8,2,2,2,26,26,404,404,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0,12,0,13,0,14,0,15,0,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,1,27,0,28,0,29,0,30,0,31,0,32,0,33,0,34,0,35,0,36,0,37,0,38,0,39,0,40,0,41,0,42,0,43,0,44,0,45,0,46,0,47,0,48,0,49,0,50,0,51,0,52,0,53,0,54,0,55,0,56,0,57,0,58,0,59,0,60,0,61,0,62,0,63,0,64,0,65,0,66,0,67,0,68,0,69,0,70,0,71,0,72,0,73,0,74,0,75,0,76,0,77,0,78,0,79,0,80,0,81,0,82,0,83,0,84,0,85,0,86,0,87,0,88,0,89,0,90,0,91,0,92,0,93,0,94,0,95,0,96,0,97,0,98,0,99,0,100,0,26] [ca/:2,2,1,2,1,246,149,117,255,180,218,198,255,180,218,198,255,0,0,0,0,180,218,198,255,180,218,198,255,180,218,198,255,9,9,2,3,2,4,7,4,4,404,404,89,89,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0,12,0,13,0,14,0,15,0,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,0,29,0,30,0,31,0,32,0,33,0,34,0,35,0,36,0,37,0,38,0,39,0,40,0,41,0,42,0,43,0,44,0,45,0,46,0,47,0,48,0,49,0,50,0,51,0,52,0,53,0,54,0,55,0,56,0,57,0,58,0,59,0,60,0,61,0,62,0,63,0,64,0,65,0,66,0,67,0,68,0,69,0,70,0,71,0,72,0,73,0,74,0,75,0,76,0,77,0,78,0,79,0,80,0,81,0,82,0,83,0,84,0,85,0,86,0,87,0,88,0,89,1,90,0,91,0,92,0,93,0,94,0,95,0,96,0,97,0,98,0,99,0,100,0,89] Let's called the format: [ca/:A1,A2,A3,A4,....,A247] A1 is the line's ID. I want to randomly grab two lines, line1's (A2,A3) should = (1,1) and line2's (A2,A3) should != (1,1). If not, regrab until the condition fits. Then, read the txt file and grab the maxID and plus 1 and newID to output [ca/:maxID+1, ->this line stands for offspring line's start back into the same txt file in a new line. Not yet, randomly picked one out of four ( line1's (A2,A3) and line2's (A2,A3)) as offspring line's A2, if offspring's A2 is from line1 then offspring's A3 can't be from line 1 (so offspring's A3 will randomly picked out of line2's A2, A3), if offspring's A2 is from line2 then offspring's A3 can't be from line 2 (so offspring's A3 will randomly picked out of line1's A2, A3). Output it after [ca/:maxID+1, to be [ca/:maxID+1,A1,A2
- Assistant
- User
Will reading all the lines cost lots of memories? If so, can I read [ca/: in order to pick lines? I pick lines because I want to pick two different IDs and their A1-A247 only.
- Assistant
- User
Yes, let you know!
- Assistant
- User
Is there a better way for me to handle A1-A247 and apply different groupings and rules to it? My offspring line will also have [ca/:A1,...A247], which will apply different rules to A1-A247 of parent1 and A1-A247 of parent2, a bit like dealing with DNA, where A[i] of parent1 and A[i] of parent2 affect A[i] of offspring accordingly. For example, A1-A2 is a rule, A3-A4 is a rule, and A5-A8 is a rule.
- Assistant
- User
Yes, help me refactor the code I already have to adopt this design!
- Assistant