I realized having to host this potentially indefinitely might not be the best idea, so I am going to shut down this gitea instance eventually.
You’ll have time, at least until the end of 2022, probably longer, but please just get all your stuff somewhere safe in case we ever disappear.
If any of your build scripts rely on my (kageru’s) projects hosted here, check my Github or IEW on Github for encoding projects. If you can’t find what you’re looking there, tell me to migrate it.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
2.3 KiB

package main
import (
"fmt"
"os"
"strconv"
)
type Cup struct {
Number int
Next *Cup
}
func main() {
args := os.Args[1:]
input := args[0]
var cups = make(map[int]*Cup)
fmt.Println(input)
var inputNumbers []int
for _, val := range input{
number,_ := strconv.Atoi(string(val))
inputNumbers = append(inputNumbers,number)
}
_, maxInput := minMax(inputNumbers)
length := len(inputNumbers)
for i := 0; i < 1000000-length; i++ {
inputNumbers = append(inputNumbers, maxInput+1+i)
}
for _, val := range inputNumbers{
cups[val] = &Cup{Number: val}
}
for id, val := range inputNumbers {
number := val
nextNumber := inputNumbers[(id+1)%len(inputNumbers)]
cups[number].Next = cups[nextNumber]
}
min, max := minMax(inputNumbers)
iteration := 0
currentCup := cups[inputNumbers[0]]
for iteration < 10000000 {
threeCupStart := currentCup.Next
threeCupEnd := threeCupStart.Next.Next
currentCup.Next = threeCupEnd.Next
destination := currentCup.Number-1
for {
if destination < min {
destination = max
}
if destination != threeCupStart.Number &&
destination != threeCupStart.Next.Number &&
destination != threeCupEnd.Number {
break
}
destination--
}
destinationCup := cups[destination]
destinationNext := destinationCup.Next
destinationCup.Next = threeCupStart
threeCupEnd.Next = destinationNext
currentCup = currentCup.Next
iteration++
}
fmt.Println("Fineshed")
firstCup := cups[1]
fmt.Println(firstCup.Next.Number)
fmt.Println(firstCup.Next.Next.Number)
//s := ""
//cup := cups[1].Next
//for cup != cups[1] {
// cup = cup.Next
//}
//fmt.Println(s)
}
func runRound(cups *[]int){
}
func moveElement(cups *[]int, from int, to int) {
indexToRemove := from
indexWhereToInsert := to
val := (*cups) [indexToRemove]
(*cups) = append((*cups)[:indexToRemove], (*cups)[indexToRemove+1:]...)
fmt.Println("cups:", (*cups))
newSlice := make([]int, indexWhereToInsert+1)
copy(newSlice,(*cups)[:indexWhereToInsert])
newSlice[indexWhereToInsert]=val
fmt.Println("newSlice:", newSlice)
fmt.Println("cups:", (*cups))
(*cups) = append(newSlice, (*cups)[indexWhereToInsert:]...)
fmt.Println("cups:", (*cups))
}
func minMax(input[]int) (int, int){
var max int
var min int
for i, val := range input {
if i==0 || val < min {
min = val
}
if i==0 || val > max {
max = val
}
}
return min,max
}