This would be the best way. Unfortunately they made it the other way around. A screen at the door shows the code, and you scan it with the app.
In my previous gym the code was on the app, but I’m not sure anymore if it was static or it changed over time. But the reader on the door was awful, I used to spend a good 3 minutes trying different angles with my phone to make it recognize the code.
Ohh. This is exactly the side project idea I’ve had on the back of my mind for a few years now. Something minimal and straightforward, just to sharpen my programming skills and learn a couple of things along the way. Maybe I’ll get around to building it some day.
Yeah I’ve been saying this to people. Don’t get mad at GDPR, get mad at companies who harvest your data
I like to use cash. Used it all the time. But now I’ve fallen for the bank-card convenience… (especially self-checkout counters).
I’ve been considering to start using cash more again, but also I’ve noticed a bunch of places that don’t take cash anymore :/
“Your friends and family understand what you do”
Sounds like JavaScript
Yes I was surprised too! It runs smooth and physical condition is great. The battery is dead tho haha
And I think it doesn’t have a parallel port unfortunately.
Avoided recursion by having an array of “pending paths”. Whenever I hit a splitter, I follow one of the paths straight away, and push the starting point and direction of the other path to the array.
First time I ran it, hit an infinite loop. Handled it by skipping “|” and “-” if they have been visited already.
Part 2 is the same code as part 1 but I just check all the possible starting points.
package main
import (
"bufio"
"fmt"
"os"
)
type Direction int
const (
UP Direction = 0
DOWN Direction = 1
LEFT Direction = 2
RIGHT Direction = 3
)
type LightPoint struct {
row int
col int
dir Direction
}
func solve(A [][]rune, start LightPoint) int {
m := len(A)
n := len(A[0])
visited := make([]bool, m*n)
points := []LightPoint{}
points = append(points, start)
for len(points) > 0 {
current := points[0]
points = points[1:]
i := current.row
j := current.col
dir := current.dir
for {
if i < 0 || i >= m || j < 0 || j >= n {
break
}
if visited[i*n+j] && (A[i][j] == '-' || A[i][j] == '|') {
break
}
visited[i*n+j] = true
if A[i][j] == '.' ||
(A[i][j] == '-' && (dir == LEFT || dir == RIGHT)) ||
(A[i][j] == '|' && (dir == UP || dir == DOWN)) {
switch dir {
case UP:
i--
case DOWN:
i++
case LEFT:
j--
case RIGHT:
j++
}
continue
}
if A[i][j] == '\\' {
switch dir {
case UP:
dir = LEFT
j--
case DOWN:
dir = RIGHT
j++
case LEFT:
dir = UP
i--
case RIGHT:
dir = DOWN
i++
}
continue
}
if A[i][j] == '/' {
switch dir {
case UP:
dir = RIGHT
j++
case DOWN:
dir = LEFT
j--
case LEFT:
dir = DOWN
i++
case RIGHT:
dir = UP
i--
}
continue
}
if A[i][j] == '-' && (dir == UP || dir == DOWN) {
points = append(points, LightPoint{row: i, col: j + 1, dir: RIGHT})
dir = LEFT
j--
continue
}
if A[i][j] == '|' && (dir == LEFT || dir == RIGHT) {
points = append(points, LightPoint{row: i + 1, col: j, dir: DOWN})
dir = UP
i--
}
}
}
energized := 0
for _, v := range visited {
if v {
energized++
}
}
return energized
}
func part1(A [][]rune) {
start := LightPoint{row: 0, col: 0, dir: RIGHT}
energized := solve(A, start)
fmt.Println(energized)
}
func part2(A [][]rune) {
m := len(A)
n := len(A[0])
max := -1
for i := 0; i < m; i++ {
start := LightPoint{row: i, col: 0, dir: RIGHT}
energized := solve(A, start)
if energized > max {
max = energized
}
start = LightPoint{row: 0, col: n - 1, dir: LEFT}
energized = solve(A, start)
if energized > max {
max = energized
}
}
for j := 0; j < n; j++ {
start := LightPoint{row: 0, col: j, dir: DOWN}
energized := solve(A, start)
if energized > max {
max = energized
}
start = LightPoint{row: m - 1, col: j, dir: UP}
energized = solve(A, start)
if energized > max {
max = energized
}
}
fmt.Println(max)
}
func main() {
// file, _ := os.Open("sample.txt")
file, _ := os.Open("input.txt")
defer file.Close()
scanner := bufio.NewScanner(file)
var lines []string
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
var A [][]rune
for _, line := range lines {
A = append(A, []rune(line))
}
// part1(A)
part2(A)
}
I crafted a simple counter-example (single letters for brevity). The way the sequence goes totally depends on the instructions, and we don’t have any guarantees on that. It could be anything. Of course, looking at the input data we could find what the instructions are, but the assumption doesn’t hold in general.
A = (B, X)
B = (C, X)
C = (X, Z)
Z = (A, C)
X = (X, X)
L L R L L L R R R -> A B C Z A B C Z C Z
L L R R R L L L R -> A B C Z C Z A B C Z
Here the distance of Z cycling back into itself could be 2 or 4, depending on what the instruction string is doing.
Yeah I got annoyed too. Because this is not implied in the problem statement and it definitely doesn’t hold up in general…
JavaScript and TypeScript too
Why would the joker remain unused? The problem clearly says joker acts as the card that makes the hand strongest, so in this case, 5 of a kind.
Pretty straightforward. The only optimization I did is that the pairs are symmetric (3ms hold and 4ms travel is the same as 4ms hold and 3ms travel).
file, _ := os.Open("input.txt")
defer file.Close()
scanner := bufio.NewScanner(file)
scanner.Scan()
times := strings.Fields(strings.Split(scanner.Text(), ":")[1])
scanner.Scan()
distances := strings.Fields(strings.Split(scanner.Text(), ":")[1])
n := len(times)
countProduct := 1
for i := 0; i < n; i++ {
t, _ := strconv.Atoi(times[i])
d, _ := strconv.Atoi(distances[i])
count := 0
for j := 0; j <= t/2; j++ {
if j*(t-j) > d {
if t%2 == 0 && j == t/2 {
count++
} else {
count += 2
}
}
}
countProduct *= count
}
fmt.Println(countProduct)
file, _ := os.Open("input.txt")
defer file.Close()
scanner := bufio.NewScanner(file)
scanner.Scan()
time := strings.ReplaceAll(strings.Split(scanner.Text(), ":")[1], " ", "")
scanner.Scan()
distance := strings.ReplaceAll(strings.Split(scanner.Text(), ":")[1], " ", "")
t, _ := strconv.Atoi(time)
d, _ := strconv.Atoi(distance)
count := 0
for j := 0; j <= t/2; j++ {
if j*(t-j) > d {
if t%2 == 0 && j == t/2 {
count++
} else {
count += 2
}
}
}
fmt.Println(count)
I’ve always had this question. When I login with Google, I know what data the website will get from my Google account. But what data can Google get from the website and my usage of it, if any? (besides, of course, that I have an account on said website).
Oh man I hadn’t seen a git checkout -b
in years haha since they introduced switch
and restore
, never looked back
You need to add the repository to fdroid
Been using it for over 6 months and I’ve found it’s everything I personally needed. I’ll be buying the lifetime plan next.
If you’re asking about the encryption, they publish a whitepaper on their website with the details. I can’t really comment on that since I’m no expert. But I did a quick online search back then and found good comments so decided to trust them.
Wait, so it’s either targeted ads or pay? Damn… Silly me thinking if you don’t pay you still could opt out of targeted ads.
But yeah, isn’t this against GDPR?
“I no longer build software; I now make furniture out of wood”
Legendary