day 21 go+python solution
This commit is contained in:
		
							parent
							
								
									cb4b8295e1
								
							
						
					
					
						commit
						c46feecce9
					
				
							
								
								
									
										1
									
								
								day21/expr.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								day21/expr.py
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2037
									
								
								day21/input
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2037
									
								
								day21/input
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										2047
									
								
								day21/sol.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2047
									
								
								day21/sol.go
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										26
									
								
								day21/sol.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								day21/sol.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,26 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
 | 
					import z3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					x = z3.Int('x')
 | 
				
			||||||
 | 
					def mul(a,b): return a*b
 | 
				
			||||||
 | 
					def div(a,b):
 | 
				
			||||||
 | 
					    quo = a / b
 | 
				
			||||||
 | 
					    return z3.If(z3.Or(a % b == 0, a >= 0),
 | 
				
			||||||
 | 
					                 quo,
 | 
				
			||||||
 | 
					                 z3.If(b >= 0, quo + 1, quo - 1))
 | 
				
			||||||
 | 
					def add(a,b): return a+b
 | 
				
			||||||
 | 
					def sub(a,b): return a-b
 | 
				
			||||||
 | 
					def num(a): return z3.IntVal(a)
 | 
				
			||||||
 | 
					def eql(a,b): return a==b
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					z = eval(open("expr.py").read())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					s = z3.Solver()
 | 
				
			||||||
 | 
					s.add(z)
 | 
				
			||||||
 | 
					print(s.check())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					m = s.model()
 | 
				
			||||||
 | 
					print(m)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										2054
									
								
								day21/sol2.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2054
									
								
								day21/sol2.go
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user