-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path23-2.cfm
More file actions
29 lines (24 loc) · 811 Bytes
/
23-2.cfm
File metadata and controls
29 lines (24 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<cffunction name="solve" output="false">
<cfargument name="input" required="true" />
<cfset var adventOfCode = CreateObject('component', 'AdventOfCode') />
<cfset var firstEightInputLines = ArrayToList(ArraySlice(ListToArray(arguments.input, Chr(10)), 1, 8), Chr(10)) />
<cfset var runResult = CreateObject('component', 'Day23Program').run(
input = firstEightInputLines,
initialRegisterValues = { a = 1 }
) />
<cfset var h = 0 />
<cfset var b = '' />
<cfloop from="#runResult.registers.b#" to="#runResult.registers.c#" step="17" index="b">
<cfif !adventOfCode.isPrime(b)>
<cfset h++ />
</cfif>
</cfloop>
<cfreturn h />
</cffunction>
<cfset testCases = [
{
input = Trim(FileRead(ExpandPath('23.txt'))),
expectedOutput = 915
}
] />
<cfinclude template="test_runner_include.cfm" />