diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5b1d307..f6ce98a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -11,9 +11,7 @@
-
-
-
+
@@ -56,7 +54,7 @@
-
+
@@ -197,6 +195,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -301,6 +309,7 @@
+
@@ -325,59 +334,59 @@
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
@@ -394,24 +403,13 @@
-
+
-
+
-
-
-
-
- file://$PROJECT_DIR$/day22/day22.go
- 115
-
-
-
-
-
\ No newline at end of file
diff --git a/day23/day23.go b/day23/day23.go
new file mode 100644
index 0000000..d662dfa
--- /dev/null
+++ b/day23/day23.go
@@ -0,0 +1,107 @@
+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)
+
+ for _, val := range input{
+ number,_ := strconv.Atoi(string(val))
+ cups[number] = &Cup{Number: number}
+ }
+ for id, val := range input {
+ number,_ := strconv.Atoi(string(val))
+ nextNumber, _ := strconv.Atoi(string(input[(id+1)%len(input)]))
+ cups[number].Next = cups[nextNumber]
+ }
+
+ var inputNumbers []int
+ for _, val := range input{
+ number,_ := strconv.Atoi(string(val))
+ inputNumbers = append(inputNumbers,number)
+ }
+
+ min, max := minMax(inputNumbers)
+ iteration := 0
+ currentCup := cups[inputNumbers[0]]
+ for iteration < 100 {
+ fmt.Println(currentCup.Number)
+ 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++
+ }
+ s := ""
+ cup := cups[1].Next
+ for cup != cups[1] {
+ s += fmt.Sprint(cup.Number)
+ 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
+}
diff --git a/helper/helper.go b/helper/helper.go
index 4767ea1..aa18baf 100644
--- a/helper/helper.go
+++ b/helper/helper.go
@@ -81,3 +81,12 @@ func Equal(a, b []int) bool {
}
return true
}
+
+func Contains(elem int, array []int) bool{
+ for _, val := range array{
+ if val == elem{
+ return true
+ }
+ }
+ return false
+}