minami
This commit is contained in:
@@ -84,8 +84,8 @@ struct Register : Comparable, CustomStringConvertible {
|
|||||||
|
|
||||||
func possibleAs(fromB5 b5Suffix: Int) -> [Register] {
|
func possibleAs(fromB5 b5Suffix: Int) -> [Register] {
|
||||||
let choices: [Register] = (0b000...0b111).compactMap { aSuffix in
|
let choices: [Register] = (0b000...0b111).compactMap { aSuffix in
|
||||||
let aShift = aSuffix ^ 1
|
let aShift = aSuffix ^ 1 // Replace this with first XOR literal
|
||||||
let b4 = aShift ^ 5
|
let b4 = aShift ^ 5 // Replace this with second XOR literal
|
||||||
let a = Register(value: (b4^b5Suffix) << aShift, mask: 0b111 << aShift)
|
let a = Register(value: (b4^b5Suffix) << aShift, mask: 0b111 << aShift)
|
||||||
return a.combine(with: Register(value: aSuffix, mask: 0b111))
|
return a.combine(with: Register(value: aSuffix, mask: 0b111))
|
||||||
}
|
}
|
||||||
|
29
day17/minami.swift
Normal file
29
day17/minami.swift
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
2,4, 1,5, 7,5, 1,6, 0,3, 4,1, 5,5, 3,0
|
||||||
|
bst 4 // B = A % 8
|
||||||
|
bxl 5 // B = B ^ 5
|
||||||
|
cdv 5 // C = A >> B
|
||||||
|
bxl 6 // B = B ^ 6
|
||||||
|
adv 3 // A = A >> 3
|
||||||
|
bxc 1 // B = B ^ C
|
||||||
|
out 5 // print(B % 8)
|
||||||
|
jnz 0 // loop while A != 0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
var A = 44374556
|
||||||
|
var B = 0
|
||||||
|
var C = 0
|
||||||
|
while true {
|
||||||
|
B = A % 8
|
||||||
|
B = B ^ 0b101
|
||||||
|
C = A >> B
|
||||||
|
B = B ^ 0b110
|
||||||
|
A = A >> 3
|
||||||
|
B = B ^ C
|
||||||
|
print(B % 8, terminator: ",")
|
||||||
|
if A == 0 { break }
|
||||||
|
}
|
||||||
|
print()
|
||||||
|
|
Reference in New Issue
Block a user