Railway circuit: Difference between revisions

→‎{{header|Wren}}: Replaced existing solution, which apparently was wrong, with a Julia translation.
(→‎{{header|Wren}}: Replaced existing solution, which apparently was wrong, with a Julia translation.)
Line 2,399:
 
=={{header|Wren}}==
{{trans|KotlinJulia}}
{{libheader|Wren-strseq}}
{{libheader|Wren-math}}
Terminal output only.
{{libheader|Wren-fmt}}
{{libheader|Wren-trait}}
Takes over 13.5 minutes to get up to n = 28. I gave up after that.
<lang ecmascript>import "/str" for Str
import "/math" for Nums
import "/fmt" for Fmt
import "/trait" for Stepped
 
A tough task for the Wren interpreter requiring about 7 minutes 48 seconds to run. Unlike the Julia example, I've not attempted the straight track for N = 16 (which I estimate would take about an hour in isolation) and have not tried to go beyond N = 24.
var RIGHT = 1
<lang ecmascript>import "./seq" for Lst
var LEFT = -1
import "./math" for Int, Nums
var STRAIGHT = 0
 
// Returns whether 'a' and 'b' are approximately equal within a tolerance of 'tol'.
var normalize = Fn.new { |tracks|
var IsApprox = Fn.new { |a, b, tol| (a - b).abs <= tol }
var size = tracks.count
var a = List.filled(size, null)
for (i in 0...size) a[i] = "abc"[tracks[i] + 1]
 
// Returns whether a1 < a2 where 'a1' and 'a2' are lists of numbers.
/* Rotate the array and find the lexicographically lowest order
var isLess = Fn.new { |a1, a2|
to allow the hashmap to weed out duplicate solutions. */
varfor norm(pair =in aLst.joinzip(a1, a2)) {
if (pair[0] > pair[1]) return false
(0...size).each { |i|
varif s(pair[0] =< a.join(pair[1]) return true
if (Str.lt(s, norm)) norm = s
var tmp = a[0]
for (j in 1...size) a[j - 1] = a[j]
a[size - 1] = tmp
}
return norma1.count < a2.count
}
 
// Represents a 2D point.
var fullCircleStraight = Fn.new { |tracks, nStraight|
class Point {
if (nStraight == 0) return true
construct new(x, y) {
_x = x
_y = y
}
 
x { _x }
// do we have the requested number of straight tracks
y { _y }
if (tracks.count { |t| t == STRAIGHT } != nStraight) return false
 
+(other) { Point.new(this.x + other.x, this.y + other.y) }
// check symmetry of straight tracks: i and i + 6, i and i + 4
 
var straight = List.filled(12, 0)
==(other) { IsApprox.call(this.x, other.x, 0.01) && IsApprox.call(this.y, other.y, 0.01) }
var i = 0
 
var idx = 0
toString { "(%(_x), %(_y))" }
while (i < tracks.count && idx >= 0) {
if (tracks[i] == STRAIGHT) straight[idx % 12] = straight[idx % 12] + 1
idx = idx + tracks[i]
i = i + 1
}
return !((0..5).any { |i| straight[i] != straight[i + 6] } &&
(0..7).any { |i| straight[i] != straight[i + 4] })
}
 
// A curve section 30 degrees is 1/12 of a circle angle or π/6 radians.
var fullCircleRight = Fn.new { |tracks|
var twelveSteps = List.filled(12, null)
// all tracks need to add up to a multiple of 360
for (a in 0..11) twelveSteps[a] = Point.new((Num.pi * (a+1)/6).sin, (Num.pi * (a+1)/6).cos)
if (Nums.sum(tracks.map { |t| t * 30 }) % 360 != 0) return false
 
// A straight section 90 degree angle is 1/4 of a circle angle or π/2 radians.
// check symmetry of right turns: i and i + 6, i and i + 4
var rTurnsfourSteps = List.filled(124, 0null)
for (a in 0..3) fourSteps[a] = Point.new((Num.pi * (a+1)/2).sin, (Num.pi * (a+1)/2).cos)
var i = 0
 
var idx = 0
// Returns whether 'turns' and 'groupMember' are in an equivalence group.
while (i < tracks.count && idx >= 0) {
var isInEquivalenceGroup = Fn.new { |turns, groupMember, reversals|
if (tracks[i] == RIGHT) rTurns[idx % 12] = rTurns[idx % 12] + 1
if (Lst.areEqual(groupMember, turns)) return true
idx = idx + tracks[i]
var iturns2 = i + 1turns.toList
for (i in 1...turns.count) {
if (Lst.areEqual(groupMember, Lst.rshift(turns2, 1))) return true
}
var invTurns = turns.map { |e| (e == 0) ? 0 : -e }.toList
if (Lst.areEqual(groupMember, invTurns)) return true
for (i in 1...invTurns.count) {
if (Lst.areEqual(groupMember, Lst.rshift(invTurns, 1))) return true
}
if (reversals) {
var revTurns = turns[-1..0]
if (Lst.areEqual(groupMember, revTurns)) return true
var revTurns2 = revTurns.toList
for (i in 1...revTurns.count) {
if (Lst.areEqual(groupMember, Lst.rshift(revTurns2, 1))) return true
}
invTurns = revTurns.map { |e| (e == 0) ? 0 : -e }.toList
if (Lst.areEqual(groupMember, invTurns)) return true
for (i in 1...invTurns.count) {
if (Lst.areEqual(groupMember, Lst.rshift(invTurns, 1))) return true
}
}
return false
return !((0..5).any { |i| rTurns[i] != rTurns[i + 6] } &&
(0..7).any { |i| rTurns[i] != rTurns[i + 4] })
}
 
// Returns the maximum member of the equivalence group containing 'turns'.
class PermutationsGen {
var maximumOfSymmetries = Fn.new { |turns, groupsFound, reversals|
construct new(numPositions, choices) {
var maxOfGroup = turns.toList
_indices = List.filled(numPositions, 0)
for (i in 0...turns.count) {
_sequence = List.filled(numPositions, 0)
_carryvar t = 0Lst.rshift(turns.toList, i)
_choicesgroupsFound[t.toString] = choicestrue
if (isLess.call(maxOfGroup, t)) maxOfGroup = t
}
var invTurns = turns.map { |e| (e == 0) ? 0 : -e }
 
for (i in 0...invTurns.count) {
next {
_carryvar t = 1Lst.rshift(invTurns.toList, i)
groupsFound[t.toString] = true
/* The generator skips the first index, so the result will always start
if (isLess.call(maxOfGroup, t)) maxOfGroup = t
with a right turn (0) and we avoid clockwise/counter-clockwise
}
duplicate solutions. */
if (reversals) {
var i = 1
whilevar (irevTurns <= _indicesturns[-1..count && _carry > 0) {]
for (i in 0...revTurns.count) {
_indices[i] = _indices[i] + _carry
_carryvar t = 0Lst.rshift(revTurns.toList, i)
if (_indicesgroupsFound[it.toString] == _choices.count) {true
if (isLess.call(maxOfGroup, t)) _carrymaxOfGroup = 1t
_indices[i] = 0}
var revInvTurns = revTurns.map { |e| (e == 0) ? 0 : -e }
for (i = iin +0...revInvTurns.count) 1{
var t = Lst.rshift(revInvTurns.toList, i)
groupsFound[t.toString] = true
if (isLess.call(maxOfGroup, t)) maxOfGroup = t
}
for (j in 0..._indices.count) _sequence[j] = _choices[_indices[j]]
return _sequence
}
return maxOfGroup
 
hasNext { _carry != 1 }
}
 
// Returns true if the path of 'turns' returns to starting point, and on that return is
var getPermutationsGen = Fn.new { |nCurved, nStraight|
// moving in a direction opposite to the starting direction.
if ((nCurved + nStraight - 12) % 4 != 0) Fiber.abort("input must be 12 + k * 4")
var isClosedPath = Fn.new { |turns, straight, start|
var trackTypes = (nStraight == 0) ? [RIGHT, LEFT] :
if ((Nums.sum(turns) % (straight ? 4 : 12)) != 0) return false
(nCurved == 12) ? [RIGHT, STRAIGHT] : [RIGHT, LEFT, STRAIGHT]
var angle = 0
return PermutationsGen.new(nCurved + nStraight, trackTypes)
var point = Point.new(start.x, start.y)
}
if (straight) {
for (turn in turns) {
var report = Fn.new { |sol, numC, numS|
var size angle = sol.countangle + turn
point = point + fourSteps[angle % 4]
Fmt.print("\n$d solution(s) for C$d,$d", size, numC, numS)
if (numC <= 20) {}
} else {
sol.values.each { |tracks|
for tracks.each { |t| Fmt.write("$2dturn ",in tturns) }{
System.print()angle = angle + turn
point = point + twelveSteps[angle % 12]
}
}
return point == start
}
 
// Finds and returns all valid circuits on the following basis.
var circuits = Fn.new { |nCurved, nStraight|
//
var solutions = {}
// Count the complete circuits by their equivalence groups. Show the unique
var gen = getPermutationsGen.call(nCurved, nStraight)
// highest sorting lists from each equivalence group if verbose.
while (gen.hasNext) {
//
var tracks = gen.next
// Use 30 degree curved track if straight is false, otherwise straight track.
if (!fullCircleStraight.call(tracks, nStraight)) continue
//
if (!fullCircleRight.call(tracks)) continue
// Allow reversed circuits if otherwise in another grouup if reversals is false,
solutions[normalize.call(tracks)] = tracks.toList
// otherwise do not consider reversed order lists unique.
var allValidCircuits = Fn.new { |n, verbose, straight, reversals|
var found = []
var groupMembersFound = {}
var t1 = straight ? "straight" : "curved"
var t2 = (reversals ? "excl" : "incl") + "uding reversed curves: "
System.print("\nFor N of %(n) and %(t1) track, %(t2)")
for (i in 0..(straight ? 3.pow(n)-1 : 2.pow(n)-1)) {
var turns
if (straight) {
var digs = Int.digits(i, 3)[-1..0]
if (digs.count < n) digs = digs + ([0] * (n - digs.count))
turns = digs.map { |d| (d == 0) ? 0 : ((d == 1) ? 1 : -1) }.toList
} else {
var digs = Int.digits(i, 2)[-1..0]
if (digs.count < n ) digs = digs + ([0] * (n - digs.count))
turns = digs.map { |d| (d == 0) ? 1 : -1 }.toList
}
if (isClosedPath.call(turns, straight, Point.new(0, 0)) &&
!groupMembersFound.containsKey(turns.toString)) {
if (found.isEmpty || found.all { |t| !isInEquivalenceGroup.call(turns, t, false) }) {
var canon = maximumOfSymmetries.call(turns, groupMembersFound, reversals)
if (verbose) System.print(canon)
found.add(canon)
}
}
}
System.print("Found %(found.count) unique valid circuit(s).")
report.call(solutions, nCurved, nStraight)
return found
}
 
var n = 4
for (n in Stepped.new(12..24, 4)) circuits.call(n, 0)
while (n <= 24) {
circuits.call(12, 4)</lang>
for (rev in [false, true]) {
for (str in [false, true]) {
if (str && n > 14) continue
allValidCircuits.call(n, !str, str, rev)
}
}
n = n + 2
}</lang>
 
{{out}}
Note that the solutions for C20,0 are in a different order to the Kotlin entry.
<pre>
For N of 4 and curved track, including reversed curves:
1 solution(s) for C12,0
Found 0 unique valid circuit(s).
1 1 1 1 1 1 1 1 1 1 1 1
 
For N of 4 and straight track, including reversed curves:
Found 1 unique valid circuit(s).
 
For N of 4 and curved track, excluding reversed curves:
Found 0 unique valid circuit(s).
 
For N of 4 and straight track, excluding reversed curves:
Found 1 unique valid circuit(s).
 
For N of 6 and curved track, including reversed curves:
Found 0 unique valid circuit(s).
 
For N of 6 and straight track, including reversed curves:
Found 1 unique valid circuit(s).
 
For N of 6 and curved track, excluding reversed curves:
Found 0 unique valid circuit(s).
 
For N of 6 and straight track, excluding reversed curves:
Found 1 unique valid circuit(s).
 
For N of 8 and curved track, including reversed curves:
Found 0 unique valid circuit(s).
 
For N of 8 and straight track, including reversed curves:
Found 7 unique valid circuit(s).
 
For N of 8 and curved track, excluding reversed curves:
Found 0 unique valid circuit(s).
 
For N of 8 and straight track, excluding reversed curves:
Found 7 unique valid circuit(s).
 
For N of 10 and curved track, including reversed curves:
Found 0 unique valid circuit(s).
 
For N of 10 and straight track, including reversed curves:
Found 23 unique valid circuit(s).
 
For N of 10 and curved track, excluding reversed curves:
Found 0 unique valid circuit(s).
 
For N of 10 and straight track, excluding reversed curves:
Found 15 unique valid circuit(s).
 
For N of 12 and curved track, including reversed curves:
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
Found 1 unique valid circuit(s).
 
For N of 12 and straight track, including reversed curves:
Found 141 unique valid circuit(s).
 
For N of 12 and curved track, excluding reversed curves:
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
Found 1 unique valid circuit(s).
 
For N of 12 and straight track, excluding reversed curves:
Found 95 unique valid circuit(s).
 
For N of 14 and curved track, including reversed curves:
Found 0 unique valid circuit(s).
 
For N of 14 and straight track, including reversed curves:
Found 871 unique valid circuit(s).
 
For N of 14 and curved track, excluding reversed curves:
Found 0 unique valid circuit(s).
 
For N of 14 and straight track, excluding reversed curves:
Found 465 unique valid circuit(s).
 
For N of 16 and curved track, including reversed curves:
[1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1]
Found 1 unique valid circuit(s).
 
For N of 16 and curved track, excluding reversed curves:
[1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1]
Found 1 unique valid circuit(s).
 
For N of 18 and curved track, including reversed curves:
[1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1]
Found 1 unique valid circuit(s).
 
For N of 18 and curved track, excluding reversed curves:
[1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1]
Found 1 unique valid circuit(s).
 
For N of 20 and curved track, including reversed curves:
[1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1]
[1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1]
[1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1]
[1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1]
[1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1]
[1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1]
Found 6 unique valid circuit(s).
 
For N of 20 and curved track, excluding reversed curves:
1 solution(s) for C16,0
[1, 1, 1, 1, 1 , 1 , 1 , 1, -1, -1, 1, 1, 1, 1 , 1 , 1 , 1 , 1, -1, -1 ]
[1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1]
[1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1]
[1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1]
[1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1]
[1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1]
Found 6 unique valid circuit(s).
 
For N of 22 and curved track, including reversed curves:
6 solution(s) for C20,0
[1 , 1, 1, 1 , 1 , 1 , 1, -1, -1, 1, 1, -1, 1, 1, -1 , 1 , 1 , 1 , 1 , 1, -1 1, -1 ]
[1, 1, 1, 1, 1 , 1, -1, -1 , 1 , 1, -1, -1 , 1, -1 , 1 , 1 , 1 , 1, -1 , 1, -1, -1 ]
[1, 1, 1, 1, 1 , 1, -1 , 1 , 1, -1 , 1 , 1, -1 , 1, -1 , 1 , 1 , 1 , 1 , 1, -1, -1 ]
[1, 1, 1, 1, 1, -1, 1 , 1 , 1, -1, 1, 1 , 1, -1 , 1 , 1 , 1 , 1 1 , 1, -1 1 , 1, -1 ]
[1, 1, 1, 1, 1, -1, 1 , 1, -1 , 1, 1, 1 , 1, -1 , 1 , 1 , 1 1 , 1, -1 , 1 1 , 1, -1 ]
Found 5 unique valid circuit(s).
1 1 1 1 -1 1 1 1 1 -1 1 1 1 1 -1 1 1 1 1 -1
 
For N of 22 and curved track, excluding reversed curves:
40 solution(s) for C24,0
[1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1]
[1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1]
[1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1]
[1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1]
Found 4 unique valid circuit(s).
 
For N of 24 and curved track, including reversed curves:
243 solution(s) for C28,0
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
[1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1]
[1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1]
[1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1]
[1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1]
[1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1]
[1, 1, 1, 1, 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, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1]
[1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1]
[1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1]
[1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1]
[1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1]
Found 40 unique valid circuit(s).
 
For N of 24 and curved track, excluding reversed curves:
4 solution(s) for C12,4
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 01, 1, 01, 1, 1 , 1, 1, 1 , 1 , 1 , 1, 0 0 1]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 01, 1, -1, -1, 0-1, -1, -1, -1, -1, -1, -1, -1, -1, 0 -1 0 ]
[1, 1, 1, 1, 1, 1, 01, 1, 1, -1, -1, -1, 1, 1, 01, 1, 1 , 1, 1, 1 0 , 1, -1, -1, -1 0 ]
[1, 1, 1, 1, 1, 1, 1, 1, 0-1, 1, -1, -1, 1, 1, 01, 1, 1 , 1, 1, 1, -1 0 , 1, -1, -1 0 ]
[1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1]
[1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1]
[1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1]
[1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1]
[1, 1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1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1]
[1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1]
[1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1]
[1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1]
[1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1]
Found 27 unique valid circuit(s).
</pre>
 
9,476

edits