package main

import (
	"crypto/rand"
	"fmt"
	"math/big"
)

func notmain() {

	//understanding pointers...
	var i int = 1
	var iArray [1]int
	p := &i
	iArray[0] = *p
	i = 2
	fmt.Println(iArray[0])
	fmt.Println(i)

	//understanding sclices...
	var arr [5]int
	arr[0] = 0
	arr[1] = 1
	arr[2] = 2
	arr[3] = 3
	arr[4] = 4
	fmt.Println(arr[:1])
	fmt.Println(arr[1:3]) // = [lower:upper)

	//later this will be taken from application, this is only for testing
	var topicsOfInterest []int
	var lenTopicList = 100
	//creates fake topicOfInterest if client has no interests
	//creates random length with max being len(topicList)
	if len(topicsOfInterest) == 0 {
		maxLength := lenTopicList / 2
		if maxLength == 0 {
			value, err := rand.Int(rand.Reader, big.NewInt(int64(lenTopicList+1)))
			if err != nil {
				panic(err)
			}
			maxLength = int(value.Int64())
		}
		fmt.Println("MaxLength: ", maxLength)
		lengthBig, err := rand.Int(rand.Reader, big.NewInt(int64(maxLength+1)))
		if err != nil {
			panic(err)
		}
		length := int(lengthBig.Int64())
		fmt.Println("Actual length: ", length)
		if length == 0 {
			length++
		}
		fakeTopicsOfInterest := make([]int, length)

		//fills the array with unique random ascending values in range with len(topicList)
		for index := 0; index < length; index++ {
			min := (index * (lenTopicList / length)) + 1
			max := ((index + 1) * (lenTopicList / length))
			if max == lenTopicList-1 {
				max++
			}
			bigNumber, err := rand.Int(rand.Reader, big.NewInt(int64(max-min+1)))
			if err != nil {
				panic(err)
			}
			var number int = int(bigNumber.Int64()) + min

			fakeTopicsOfInterest[index] = number

			fmt.Println("Min: ", min, " Max: ", max, " Value chosen: ", fakeTopicsOfInterest[index])
		}
	}
}
