This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package yk.aoc2024; | |
import org.junit.Test; | |
import yk.aoc2024.utils.AocUtils2D; | |
import yk.jcommon.fastgeom.Vec2i; | |
import yk.jcommon.fastgeom.yfor.YForVec2i; | |
import yk.ycollections.Tuple; | |
import yk.ycollections.YList; | |
import yk.ycollections.YSet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FloatValue { | |
public boolean dirty = true; | |
public float baseValue; //before any buffs | |
public float value; //with all buffs | |
transient private YSet<FloatAffector> affectors = hs(); | |
public void recalc() { | |
float mul = affectors.reduce(0f, (cur, affector) -> cur + affector.mul); | |
float add = affectors.reduce(0f, (cur, affector) -> cur + affector.add); | |
value = baseValue * mul + add; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public float getProj(O4Obj mdA, O4Obj mdB) { | |
return mdA.pos.sub(mdB.pos).normalized().complexDiv1(mdA.impulse).x / mdA.mass; | |
} | |
float getProjOptimized(O4Obj mdA, O4Obj mdB) { | |
float newVar_4_x = (mdA.pos.x - mdB.pos.x); | |
float newVar_4_y = (mdA.pos.y - mdB.pos.y); | |
float forPare_42 = STANDARD.sqrt((newVar_4_x * newVar_4_x + newVar_4_y * newVar_4_y)); | |
float newVar_3_x = newVar_4_x / forPare_42; | |
float newVar_3_y = newVar_4_y / forPare_42; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Round 1: unoptimized version | |
// 1.685 | |
// 1.633 | |
// 1.669 | |
// 1.667 | |
// | |
// Round 2: unoptimized version (again!) | |
// 1.684 | |
// 1.693 | |
// 1.668 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Round 1: unoptimized version | |
// why is here first cycle is too short and rest are too long? | |
// 1.639 | |
// 3.333 | |
// 3.298 | |
// 3.289 | |
// | |
// Round 2: unoptimized version (again!) | |
// why each cycle takes longer than first cycle of first round? | |
// and less than others? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Test of the automatic program optimization generator. | |
//Here is function multiply44 is deeply inlined and optimized. | |
//It uses just one call with constant parameters and it resolves to series of recursive inlines, | |
// constants calculations and other optimizations. | |
public static void set(int ww, float[] data, int row, int column, float d) { | |
data[(row-1) * ww + column-1] = d; | |
} | |
public static float get(int ww, float[] data, int row, int column) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package common.search; | |
import yk.Util; | |
import java.util.*; | |
import static yk.Util.list; | |
import static yk.Util.map; | |
public class Lift { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package simple; | |
import par.ParParser; | |
import java.util.List; | |
import java.util.Map; | |
import static yk.Util.copy; | |
import static yk.Util.list; | |
import static yk.Util.map; |