Please don’t rely on this Gitea instance being around forever. If any of your build scripts use 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 for there, tell me to migrate it.

I dont even know

master
Arranun 3 years ago
parent ce7044ecf1
commit f89d165c94

@ -9,11 +9,28 @@ main = do
let asteroids = map fst (filter(\(x,y) -> y == '#' ) points)
--let sortedAsteroids = sortBy sortDistance asteroids
--let view = length (getViews (asteroids) (3,4))
let result = List.maximum(map(\x-> length(getViews (asteroids) x)) (asteroids))
--let result = List.maximum(map(\x-> length(getViews (asteroids) x)) (asteroids))
let views = (getViews asteroids (2,2))
let lines = map reduce(map(\(x,y)-> ((x-2),(y-2))) (getBorder (2,2) 4))
let order = destroyOrders asteroids lines (2,2) []
--let destroyed = destroyOrder views lines []
--mapM putStrLn (map(\(x,y)->(show x ) ++(show y)) asteroids)
--mapM putStrLn (map(\(x,y)->(show x ) ++(show y)) sortedAsteroids)
putStrLn ( show result)
mapM putStrLn (map show (layers))
-- putStrLn ( show result)
--mapM putStrLn ( map show views)
mapM putStrLn ( map show order)
--mapM putStrLn (map show (layers))
--mapM putStrLn ( map show destroyed)
destroyOrders :: [(Int,Int)] ->[(Int,Int)] -> (Int,Int) -> [(Int,Int)] -> [(Int,Int)]
destroyOrders ast laser station out
|length ast > 0 = do
let views = getViews ast station
let destroyed = destroyOrder views laser []
let newout = out ++ destroyed
let newast = ast \\ destroyed
destroyOrders newast laser station newout
|otherwise = out
mapInd :: (a -> Int -> b) -> [a] -> [b]
mapInd f l = zipWith f l [0..]
@ -33,3 +50,34 @@ getView xs y
reduce :: (Int,Int) -> (Int,Int)
reduce (a,b) = ((div a (gcd a b)),(div b (gcd a b)))
destroyOrder :: [(Int,Int)] -> [(Int,Int)] -> [(Int,Int)] -> [(Int,Int)]
destroyOrder ast (x:xs) out
| length xs > 0 = do
let asteroid = getLineAst ast x
if length asteroid /= 0
then do
let newast = delete (head asteroid) ast
let newout = out ++ asteroid
destroyOrder newast xs newout
else
destroyOrder ast xs out
| length xs == 0 = do
let asteroid = getLineAst ast x
if length asteroid /= 0
then out ++ asteroid
else out
getLineAst :: [(Int,Int)] -> (Int,Int) -> [(Int,Int)]
getLineAst xs r =
filter(\x->reduce(x) == r) xs
getBorder :: (Int,Int) -> Int -> [(Int,Int)]
getBorder (a,b) l = do
let p1 = [(i,0) | i <- [a..l]]
let p2 = [(l,j) | j <- [1..l]]
let p3 = [(i,l) | i <- reverse [0..(l-1)]]
let p4 = [(l,j) | j <- [(l-1)..0]]
let p5 = [(0,j) | j <- reverse [0..(l-1)]]
let p6 = [(i,0) | i <- [0..(a-1)]]
p1 ++ p2 ++ p3 ++ p4 ++ p5 ++ p6

Loading…
Cancel
Save