Day23 Part 2

This commit is contained in:
Karl Spickermann 2020-12-23 22:32:12 +01:00
parent e572ed1862
commit 39ce3a0dea
2 changed files with 68 additions and 44 deletions

View File

@ -11,9 +11,8 @@
</component>
<component name="ChangeListManager">
<list default="true" id="400bdf61-8921-41d3-8f98-a0a1b0877f46" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/day23/day23.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/helper/helper.go" beforeDir="false" afterPath="$PROJECT_DIR$/helper/helper.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/day23/day23.go" beforeDir="false" afterPath="$PROJECT_DIR$/day23/day23.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -334,59 +333,59 @@
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="WindowStateProjectService">
<state x="351" y="0" width="1092" height="1040" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1608757578032">
<state x="351" y="0" width="1092" height="1040" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1608759053757">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="-1472" y="103" key="#com.intellij.execution.impl.EditConfigurationsDialog/-1920.0.1920.1040/0.0.1920.1040@-1920.0.1920.1040" timestamp="1607019292652" />
<state x="351" y="0" width="1092" height="1040" key="#com.intellij.execution.impl.EditConfigurationsDialog/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608757578032" />
<state x="351" y="0" width="1092" height="1040" key="#com.intellij.execution.impl.EditConfigurationsDialog/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608759053757" />
<state x="661" y="322" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1606836882379">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="661" y="322" key="#com.intellij.fileTypes.FileTypeChooser/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1606836882379" />
<state width="552" height="466" key="DebuggerActiveHint" timestamp="1608757330340">
<state width="552" height="466" key="DebuggerActiveHint" timestamp="1608758945640">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="552" height="466" key="DebuggerActiveHint/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608757330340" />
<state width="552" height="466" key="DebuggerActiveHint/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608758945640" />
<state x="739" y="287" key="FileChooserDialogImpl" timestamp="1607278759015">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="739" y="287" key="FileChooserDialogImpl/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1607278759015" />
<state width="1161" height="235" key="GridCell.Tab.0.bottom" timestamp="1608757569304">
<state width="1158" height="235" key="GridCell.Tab.0.bottom" timestamp="1608759039619">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="386" key="GridCell.Tab.0.bottom/-1920.0.1920.1040/0.0.1920.1040@-1920.0.1920.1040" timestamp="1607708629475" />
<state width="1161" height="235" key="GridCell.Tab.0.bottom/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608757569304" />
<state width="1161" height="235" key="GridCell.Tab.0.center" timestamp="1608757569304">
<state width="1158" height="235" key="GridCell.Tab.0.bottom/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608759039619" />
<state width="1158" height="235" key="GridCell.Tab.0.center" timestamp="1608759039619">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="386" key="GridCell.Tab.0.center/-1920.0.1920.1040/0.0.1920.1040@-1920.0.1920.1040" timestamp="1607708629474" />
<state width="1161" height="235" key="GridCell.Tab.0.center/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608757569304" />
<state width="1161" height="235" key="GridCell.Tab.0.left" timestamp="1608757569304">
<state width="1158" height="235" key="GridCell.Tab.0.center/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608759039619" />
<state width="1158" height="235" key="GridCell.Tab.0.left" timestamp="1608759039619">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="386" key="GridCell.Tab.0.left/-1920.0.1920.1040/0.0.1920.1040@-1920.0.1920.1040" timestamp="1607708629474" />
<state width="1161" height="235" key="GridCell.Tab.0.left/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608757569304" />
<state width="1161" height="235" key="GridCell.Tab.0.right" timestamp="1608757569304">
<state width="1158" height="235" key="GridCell.Tab.0.left/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608759039619" />
<state width="1158" height="235" key="GridCell.Tab.0.right" timestamp="1608759039619">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="386" key="GridCell.Tab.0.right/-1920.0.1920.1040/0.0.1920.1040@-1920.0.1920.1040" timestamp="1607708629475" />
<state width="1161" height="235" key="GridCell.Tab.0.right/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608757569304" />
<state width="938" height="425" key="GridCell.Tab.1.bottom" timestamp="1608757429346">
<state width="1158" height="235" key="GridCell.Tab.0.right/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608759039619" />
<state width="938" height="425" key="GridCell.Tab.1.bottom" timestamp="1608758953021">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="938" height="425" key="GridCell.Tab.1.bottom/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608757429346" />
<state width="938" height="425" key="GridCell.Tab.1.center" timestamp="1608757429346">
<state width="938" height="425" key="GridCell.Tab.1.bottom/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608758953021" />
<state width="938" height="425" key="GridCell.Tab.1.center" timestamp="1608758953021">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="938" height="425" key="GridCell.Tab.1.center/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608757429346" />
<state width="938" height="425" key="GridCell.Tab.1.left" timestamp="1608757429346">
<state width="938" height="425" key="GridCell.Tab.1.center/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608758953021" />
<state width="938" height="425" key="GridCell.Tab.1.left" timestamp="1608758953021">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="938" height="425" key="GridCell.Tab.1.left/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608757429346" />
<state width="938" height="425" key="GridCell.Tab.1.right" timestamp="1608757429346">
<state width="938" height="425" key="GridCell.Tab.1.left/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608758953021" />
<state width="938" height="425" key="GridCell.Tab.1.right" timestamp="1608758953021">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="938" height="425" key="GridCell.Tab.1.right/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608757429346" />
<state width="938" height="425" key="GridCell.Tab.1.right/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608758953021" />
<state x="782" y="240" key="RollbackChangesDialog" timestamp="1608474837005">
<screen x="0" y="0" width="1920" height="1040" />
</state>
@ -407,9 +406,30 @@
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="593" y="141" width="585" height="801" key="find.popup/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608756195388" />
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup" timestamp="1608654442412">
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup" timestamp="1608759036944">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608654442412" />
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1608759036944" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/day23/day23.go</url>
<line>40</line>
<option name="timeStamp" value="8" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/day23/day23.go</url>
<line>28</line>
<option name="timeStamp" value="9" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/day23/day23.go</url>
<line>34</line>
<option name="timeStamp" value="14" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>

View File

@ -17,27 +17,28 @@ func main() {
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)
}
_, 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 < 100 {
fmt.Println(currentCup.Number)
for iteration < 10000000 {
threeCupStart := currentCup.Next
threeCupEnd := threeCupStart.Next.Next
currentCup.Next = threeCupEnd.Next
@ -60,13 +61,16 @@ func main() {
currentCup = currentCup.Next
iteration++
}
s := ""
cup := cups[1].Next
for cup != cups[1] {
s += fmt.Sprint(cup.Number)
cup = cup.Next
}
fmt.Println(s)
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){