Do the golfathon in a 1777 folder instead of over Git
This commit is contained in:
parent
01ac5d8237
commit
5ed7e884ba
9 changed files with 144 additions and 2 deletions
|
@ -4,7 +4,7 @@ Welcome to our code golf hackathon! You can either create new hackathon problems
|
|||
|
||||
## Create
|
||||
|
||||
To create a new problem, make a folder named after the problem and write the problem statement in the `README.md` inside the folder. See `pund/README.md` for an example.
|
||||
To create a new problem, make a folder named after the problem, `chmod 1777` it, and write the problem statement in the `README.md` inside the folder. See `pund/README.md` for an example.
|
||||
|
||||
## Answer
|
||||
|
||||
|
|
96
cell-voronoi/README
Normal file
96
cell-voronoi/README
Normal file
|
@ -0,0 +1,96 @@
|
|||
// inspired by gpn-tron
|
||||
|
||||
## Rule Part 1
|
||||
|
||||
On a uniform 2D grid, where distance is calculated by taxicab distance (normal snake game moves)
|
||||
For every grid point, the capital letter (snake head) that is closest to it owns it.
|
||||
In case of a tie, no one owns that grid point.
|
||||
|
||||
The grid is rectangular.
|
||||
|
||||
## Problem Statement 1
|
||||
|
||||
Given the grid size, and the coordinates of each capital letter,
|
||||
calculate for each capital letter, how many grid points does it own.
|
||||
|
||||
## Example 1
|
||||
|
||||
Below, you have a 3x1 grid. `.` is an empty grid point.
|
||||
|
||||
A . B
|
||||
|
||||
A and B are on grid points.
|
||||
|
||||
A and B each own 1 grid point.
|
||||
|
||||
The middle grid point has a tie, so it is owned by no one.
|
||||
|
||||
### input
|
||||
3 1
|
||||
2
|
||||
A 0 0
|
||||
B 2 0
|
||||
|
||||
### output
|
||||
A 1
|
||||
B 1
|
||||
|
||||
## Example 2
|
||||
|
||||
Below, you have a 4x1 grid.
|
||||
|
||||
A . . B
|
||||
|
||||
A and B are on grid points.
|
||||
|
||||
A and B each own 2 grid point.
|
||||
|
||||
### input
|
||||
4 1
|
||||
2
|
||||
A 0 0
|
||||
B 3 0
|
||||
|
||||
### output
|
||||
A 2
|
||||
B 2
|
||||
|
||||
## Rule Part 2
|
||||
|
||||
As it turns out, the grid wraps around like a torus.
|
||||
|
||||
The Problem remains the same.
|
||||
|
||||
## Rule Part 3
|
||||
|
||||
Oh now we have walls. Distance calculation becomes a bit tricky here. Distance calculations don't go through walls.
|
||||
|
||||
`#` represent walls.
|
||||
|
||||
A # .
|
||||
. # B
|
||||
. . .
|
||||
|
||||
### input
|
||||
3 3
|
||||
4
|
||||
A 0 0
|
||||
B 2 1
|
||||
# 1 0
|
||||
# 1 1
|
||||
|
||||
### output
|
||||
A 2
|
||||
B 2
|
||||
|
||||
|
||||
For your viewing pleasure:
|
||||
|
||||
A # .
|
||||
. # B
|
||||
a . b
|
||||
|
||||
## Checking your answers
|
||||
idk. i don't have ready-to-be-used examples.
|
||||
if you write a random grid layout generator, edit this section to mention it.
|
||||
if the grid is as small as 5x5, you can count the numbers by hand. that's how i can verify my algorithms.
|
19
pund/iacore-notes
Normal file
19
pund/iacore-notes
Normal file
|
@ -0,0 +1,19 @@
|
|||
0
|
||||
1 2 5 8
|
||||
6 9
|
||||
|
||||
end mid
|
||||
4 Y Y 1 2 5 8
|
||||
6 Y N 1 2 5 8 6 9
|
||||
5 N Y 0 1 2 5 8
|
||||
7 N N 0 1 2 5 8 6 9
|
||||
|
||||
4
|
||||
6
|
||||
6*5
|
||||
6*7
|
||||
6*7*5
|
||||
6*7*7
|
||||
6*7*7*5
|
||||
6*7*7*7
|
||||
|
22
pund/iacore.py
Normal file
22
pund/iacore.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
def c():
|
||||
yield 1,['1258']
|
||||
a=['125689']
|
||||
b=['01258','125689']
|
||||
while 1:
|
||||
yield 0,a
|
||||
yield 1,b
|
||||
a=['0125689']+a
|
||||
b.insert(1, '0125689')
|
||||
def p(d):
|
||||
y=1
|
||||
for x in d:y*=len(x)
|
||||
return y
|
||||
k=int(__import__('sys').argv[1])-1
|
||||
s=lambda x:len(x[0])*s(x[1:])if x else 1
|
||||
for rp, ds in c():
|
||||
l=s(ds)
|
||||
if k>=l:k-=l
|
||||
else:break
|
||||
digits=''
|
||||
for d in ds:digits+=d[k%len(d)];k//=len(d)
|
||||
print(digits[:0 if rp else None:-1]+digits)
|
|
@ -1,3 +1,3 @@
|
|||
# rquine
|
||||
|
||||
Write a program that prints out its own source code... backwards!
|
||||
Write a program that prints out its own source code... backwards, with all characters in reverse order!
|
||||
|
|
0
rquine/iacore.sh
Executable file
0
rquine/iacore.sh
Executable file
1
rquine/nvpie.sh
Executable file
1
rquine/nvpie.sh
Executable file
|
@ -0,0 +1 @@
|
|||
rev $0
|
3
segfault/README.md
Normal file
3
segfault/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# segfault
|
||||
|
||||
Do exactly as the name suggests: your program must segfault.
|
1
segfault/a.cpp
Normal file
1
segfault/a.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
main(){*(int*)0=0;}
|
Loading…
Reference in a new issue