Identical symbols Go Lang
Budget: €8 – €30 EUR
How can I do the following from this code:
func main() {
n1 := new(big.Int)
n1.SetString("1000000", 10)
n2 := new(big.Int)
n2.SetString("1000011110", 10)
one := big.NewInt(1)
for i := n1; i.Cmp(n2) < 0; i.Add(i, one) {
fmt.Println(i)
}
}
I want to convert n1 from decimal to hexadecimal and check if there are more than 4 same symbols next to each other in hex.
Example:
n1 = 65536 -> hex = 10000 <-- 4 identical symbols execute for i := n1; i.Cmp(n2) < 0; i.Add(i, one) {...}
n1 = 65552 -> hex = 10010 <-- no 4 symbols are the same - keep counting till find next with 4 identical symbols then execute for i := n1; i.Cmp(n2) < 0; i.Add(i, one) {...}
n1 = 1114112 -> hex = 110000 <-- 4 identical symbols execute for i := n1; i.Cmp(n2) < 0; i.Add(i, one) {...}
and etc ...
It should also check if there is more than one pair of 4 identical symbols in a hex. If there is, let the counting continue.
Example:
n1 hex = 1000010000 <-- continue counting because there is 2 times 4 identical symbols
n1 hex = 1000011110 - there are 4x0000 and 4x1111 but they are different so execute for i := n1; i.Cmp(n2) < 0; i.Add(i, one) {...}
func main() {
n1 := new(big.Int)
n1.SetString("1000000", 10)
n2 := new(big.Int)
n2.SetString("1000011110", 10)
one := big.NewInt(1)
for i := n1; i.Cmp(n2) < 0; i.Add(i, one) {
fmt.Println(i)
}
}
I want to convert n1 from decimal to hexadecimal and check if there are more than 4 same symbols next to each other in hex.
Example:
n1 = 65536 -> hex = 10000 <-- 4 identical symbols execute for i := n1; i.Cmp(n2) < 0; i.Add(i, one) {...}
n1 = 65552 -> hex = 10010 <-- no 4 symbols are the same - keep counting till find next with 4 identical symbols then execute for i := n1; i.Cmp(n2) < 0; i.Add(i, one) {...}
n1 = 1114112 -> hex = 110000 <-- 4 identical symbols execute for i := n1; i.Cmp(n2) < 0; i.Add(i, one) {...}
and etc ...
It should also check if there is more than one pair of 4 identical symbols in a hex. If there is, let the counting continue.
Example:
n1 hex = 1000010000 <-- continue counting because there is 2 times 4 identical symbols
n1 hex = 1000011110 - there are 4x0000 and 4x1111 but they are different so execute for i := n1; i.Cmp(n2) < 0; i.Add(i, one) {...}