1- #Problem
1+ es # Problem
22
33Escape Pods
44===========
@@ -67,10 +67,12 @@ Use verify [file] to test your solution and see how it does. When you are finish
6767
6868#Solution
6969
70+ ##Analysis
71+ ###First Example
7072For example, if you have:
71- entrances =[ 0, 1]
72- exits =[ 4, 5]
73- path =[
73+ Entrances =[ 0, 1]
74+ Exits =[ 4, 5]
75+ Path =[
7476 0 1 2 3 4 5
7577[ 0, 0, 4, 6, 0, 0] , # Room 0: Bunnies
7678[ 0, 0, 5, 2, 0, 0] , # Room 1: Bunnies
@@ -82,7 +84,7 @@ path = [
8284[0, 0, 0, 0, 0, 0], # Room 5: Escape pods
8385]
8486
85- Output:6
87+ Output:16
8688
8789Then in each time step, the following might happen:
88900 sends 4/4 bunnies to 2
@@ -97,14 +99,186 @@ Then in each time step, the following might happen:
97993 sends 4/6 bunnies to 4
981003 sends 4/6 bunnies to 5
99101
102+ ###Second Example
103+ Entrances =[ 0]
104+ Exists =[ 3]
105+ Path =[[ 0, 7, 0, 0] ,[ 0, 0 , 6, 0] ,[ 0, 0, 0, 8] ,[ 9, 0, 0, 0]]
106+ Output: 6
107+
108+ [ 0, 7, 0, 0] 0 # Room 0: Bunnies
109+ [ 0, 0, 6, 0] 1 # Room 1: Intermediate room
110+ [ 0, 0, 0, 8] 2 # Room 2: Intermediate room
111+ [ 9, 0, 0, 0] 3 # Room 3: Escape pods
100112
113+ 0 sends 7/6 bunnies to 1
114+ 1 sends 6/8 bunnies to 2
115+ 2 sends 6/9 bunnies to 3
101116
102- ### Second Example
117+ The problem is related to finding the network flow.
103118
104- [ 0] ,[ 3] ,[[ 0, 7, 0, 0] ,[ 0, 0 , 6, 0] ,[ 0, 0, 0, 8] ,[ 9, 0, 0, 0]]
105- Output: 6
119+ ###Theory
120+ - https://algs4.cs.princeton.edu/40graphs
121+ - [ Network Flow Algorithms Starting Here] ( https://www.youtube.com/watch?v=LdOnanfc5TM&list=PLDV1Zeh2NRsDGO4--qE8yH72HFL1Km93P&index=33&t=3s )
122+ - 13 . Incremental Improvement: Max Flow, Min Cut] ( https://www.youtube.com/watch?v=VYZGlgzr_As )
123+ - 14 . https://www.youtube.com/watch?v=8C_T4iTzPCU
124+ - https://www.youtube.com/watch?v=0CdxkgAjsDA
125+ - https://en.wikipedia.org/wiki/Flow_network
126+ - https://en.wikipedia.org/wiki/Max-flow_min-cut_theorem
127+ - https://en.wikipedia.org/wiki/Maximum_flow_problem
128+ - https://www.geeksforgeeks.org/cuts-and-network-flow
129+ - https://www.sciencedirect.com/science/article/pii/002200008590039X
130+ - https://stackoverflow.com/questions/36054690/how-to-use-dinics-algorithm-to-find-min-cut-edges-in-undireted-graph
131+ - Actual Complexity of Max Flow Algorithmshttps://codeforces.com/blog/entry/52714
132+
133+ Functional example:
134+
135+ ``` java
136+
137+ // Source: https://vitaminac.github.io/Google-Foobar-Escape-Pods/
138+
139+ import java.util.List ;
140+ import java.util.Collections ;
141+ import java.util.ArrayList ;
142+ import java.util.ArrayDeque ;
143+ import java.util.Queue ;
144+ import java.util.Arrays ;
145+
146+
147+ public class EscapePods {
148+ private static final int INF = Integer . MAX_VALUE ;
149+
150+ private static int [][]transform (int []sources ,int []sinks ,int [][]network ) {
151+ // transform to a equivalent single-source, single-sink flow network
152+ int length= network. length;
153+ int newLength= length+ 2 ;
154+ int [][] newNetwork= new int [newLength][newLength];
155+ for (int i= 0 ; i< length; i++ ) {
156+ for (int j= 0 ; j< length; j++ ) {
157+ newNetwork[i+ 1 ][j+ 1 ]= network[i][j];
158+ }
159+ }
160+ for (int entrance: sources) {
161+ newNetwork[0 ][entrance+ 1 ]= INF ;
162+ }
163+ for (int exit: sinks) {
164+ newNetwork[exit+ 1 ][newLength- 1 ]= INF ;
165+ }
166+ return newNetwork;
167+ }
168+
169+ private static List<Integer > bfs (int [][]residual_network ) {
170+ // find a path from s to t that every (u, v) in p satisfies c_f(u, v) > 0
171+ int [] parents= new int [residual_network. length];
172+ Arrays . fill(parents,- 1 );
173+ Queue<Integer > queue= new ArrayDeque<> ();
174+ queue. add(0 );
175+ int u;
176+ for (;! queue. isEmpty()&& parents[parents. length- 1 ]== - 1 ; ) {
177+ u= queue. remove();
178+ for (int v= 0 ; v< parents. length; v++ ) {
179+ if (residual_network[u][v]> 0 && parents[v]== - 1 ) {
180+ queue. add(v);
181+ parents[v]= u;
182+ }
183+ }
184+ }
185+ List<Integer > path= new ArrayList<> ();
186+ u= parents[parents. length- 1 ];
187+ while (u!= 0 ) {
188+ if (u== - 1 )return null ;
189+ path. add(u);
190+ u= parents[u];
191+ }
192+ Collections . reverse(path);
193+ return path;
194+ }
195+
196+ private static int solveWithFordFulkerson (int [][]residual_network ) {
197+ // https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm
198+ int max_flow= 0 ;
199+ List<Integer > path;
200+ while ((path= bfs(residual_network))!= null ) {
201+ // calculate residual capacity c_f(p)
202+ int residual_capacity= INF ;
203+ int u= 0 ;
204+ for (int v: path) {
205+ residual_capacity= Math . min(residual_capacity, residual_network[u][v]);
206+ u= v;
207+ }
208+ // increment max flow
209+ max_flow+= residual_capacity;
210+ u= 0 ;
211+ // update residual network
212+ for (int v: path) {
213+ residual_network[u][v]-= residual_capacity;
214+ residual_network[v][u]+= residual_capacity;
215+ u= v;
216+ }
217+ }
218+ return max_flow;
219+ }
220+
221+ public static int solution (int []entrances ,int []exits ,int [][]path ) {
222+ return solveWithFordFulkerson(transform(entrances, exits, path));
223+ }
224+ }
225+ ```
226+
227+ ###Understanding Dinic's
228+ - https://en.wikipedia.org/wiki/Dinic%27s_algorithm
229+ - https://www.youtube.com/watch?v=M6cm8UeeziI&list=PLDV1Zeh2NRsDGO4--qE8yH72HFL1Km93P&index=42
230+ - https://github.com/ADJA/algos/blob/master/Graphs/Dinic.cpp
231+ - https://www.geeksforgeeks.org/dinics-algorithm-maximum-flow
232+ - https://www.hackerearth.com/practice/algorithms/graphs/maximum-flow/tutorial
233+ - https://www.geeksforgeeks.org/dinics-algorithm-maximum-flow
234+ - https://surajshetiya.github.io/Google-foobar/#round-4
235+ - https://github.com/nkapliev/google-foo.bar/blob/master/problems/4.2_escape_pods.py
236+ - http://www.cs.ust.hk/mjg_lib/Classes/COMP572_Fall07/Notes/index.htm
237+
238+
239+
240+ ######Tabs On Brower
241+ - [ ] https://www.hackerearth.com/practice/algorithms/graphs/shortest-path-algorithms/tutorial/
242+ - [ ] https://docs.ioin.in/writeup/www.auxy.xyz/_tutorial_Webkit_Exp_Tutorial_/index.html
243+ - [ ] https://tech.ebayinc.com/engineering/ou-online-analytical-processing/
244+ - [ ] https://www.linkedin.com/pulse/dos-donts-while-preparing-amazon-machine-learning-specialty-semaan/
245+ - [ ] https://www.infoq.com/podcasts/software-architecture-team-topologies
246+ - [ ] https://medium.com/awsblogs/ci-cd-with-kubernetes-3c29e8073c38
247+ - [ ] https://www.infoq.com/presentations/hotspot-graalvm-code-execution
248+ - [ ] https://medium.com/better-programming/modern-day-architecture-design-patterns-for-software-professionals-9056ee1ed977
249+ - [ ] https://www.linkedin.com/learning/cobol-essential-training/cobol-is-alive-and-well
250+ - [ ] https://mailchi.mp/5125b7b5305e/18-dear-architects
251+ - [ ] https://advocacy.vmware.com/member/post/1d9aff34-0610-42ed-9b90-21233cabc9ae?uc=113877&g=df4af070-be59-44be-b7f0-ea2387c55f98&f=2433965
252+ - [ ] https://minimatech.org/from-postgresql-to-neo4j
253+ - [ ] https://www.siddharthsarda.com/p/developer-progression-as-a-function
254+ - [ ] https://www.infoworld.com/article/3563829/jamstack-the-static-website-revolution-upending-web-development.html
255+ - [ ] https://apenwarr.ca/log/20201227 System design
256+ - [ ] https://www.infoq.com/articles/database-audit-system-kafka
257+ - [ ] https://increment.com/remote/committing-to-collaboration-version-control |https://increment.com/remote
258+ - [ ] https://medium.com/neotiv-gmbh/5-design-patterns-every-software-engineer-should-know-470c8b6c0b54
259+ - [ ] https://chromeisbad.com
260+ - [ ] https://vitaminac.github.io/Simple-Bootstrap-Linux-System/
261+ - [ ] https://hbr.org/2018/01/why-people-really-quit-their-jobs
262+ - [ ] https://play.picoctf.org/practice?category=6&page=1
263+ - [ ] https://architectelevator.com/architecture/famous-architects-sketch/
264+ - [ ] https://github.com/topjohnwu/Magisk
265+ - [ ] https://www.8bitmen.com/youtube-database-how-does-it-store-so-many-videos-without-running-out-of-storage-space/
266+ - [ ] https://github.com/facebook/zstd
267+ - [ ] https://github.com/topjohnwu/Magisk
268+ - [ ] https://tolisec.com/ssh-backdoor-botnet-with-research-infection-technique
269+ - [ ] https://www.infoq.com/articles/whats-the-next-step-for-data-management
270+ - [ ] https://opensource.com/
271+ - [ ] https://secret.club/2021/01/14/vbox-escape.html
272+ - [ ] https://www.linuxjournal.com/
273+ - [ ] https://www.weave.works/blog/the-gitops-pipeline
274+ - [ ] https://github.com/kubermatic/
275+ - [ ] https://github.com/open-telemetry/opentelemetry-go/contribute
276+ - [ ] https://github.com/SaturnsVoid/GoBot2
277+ - [ ] https://architectelevator.com/architecture/failure-doesnt-respect-abstraction/
278+ - [ ] Fast polynomial multiplication for programming contests (Java)https://www.davideisenstat.com/simplertimes
279+ - [ ] https://graphics.stanford.edu/~seander/bithacks.html |https://github.com/gibsjose/BitHacks
280+ - [ ] https://www.cs.cmu.edu/~15451-f18/lectures Download
281+ - [ ] https://www.vice.com/en/article/n7vqew/the-hacker-who-archived-parler-explains-how-she-did-it-and-what-comes-next
282+ - [ ] https://github.com/d0nk/parler-tricks
283+ - [ ] https://gist.github.com/Parler-Analysis/2c023fd2e053fba5bc85b09209f606eb
106284
107- [ 0, 7, 0, 0] 0 Entrance/Bunny
108- [ 0, 0, 6, 0] 1
109- [ 0, 0, 0, 8] 2
110- [ 9, 0, 0, 0] 3 Exit/Escape Pod