Skip to content

Instantly share code, notes, and snippets.

@joeyadams
Created March 15, 2011 15:01
Show Gist options
  • Save joeyadams/870827 to your computer and use it in GitHub Desktop.
Save joeyadams/870827 to your computer and use it in GitHub Desktop.
Plain-text alternative to long division test suite
22
----
56|1234
112
---
114
112
---
2
83501
-------
12|1002012
96
---
42
36
--
60
60
--
12
12
--
1
-
1|1
1
-
0
-
1|0
10
--
1|10
1
-
100
---
1|100
1
-
300
---
1|300
3
-
33
---
3|100
9
--
10
9
--
1
10
---
10|100
10
--
1
---
100|100
100
---
0
---
1000|100
0
-
7|1
1
--
7|10
7
--
3
14
---
7|100
7
--
30
28
--
2
142
----
7|1000
7
--
30
28
--
20
14
--
6
1428
-----
7|10000
7
--
30
28
--
20
14
--
60
56
--
4
14285
------
7|100000
7
--
30
28
--
20
14
--
60
56
--
40
35
--
5
1428571428
-----------
7|10000000000
7
--
30
28
--
20
14
--
60
56
--
40
35
--
50
49
--
10
7
--
30
28
--
20
14
--
60
56
--
4
14285714285714285714285714285714285714285714285714285714285714285714285
------------------------------------------------------------------------
7|100000000000000000000000000000000000000000000000000000000000000000000000
7
--
30
28
--
20
14
--
60
56
--
40
35
--
50
49
--
10
7
--
30
28
--
20
14
--
60
56
--
40
35
--
50
49
--
10
7
--
30
28
--
20
14
--
60
56
--
40
35
--
50
49
--
10
7
--
30
28
--
20
14
--
60
56
--
40
35
--
50
49
--
10
7
--
30
28
--
20
14
--
60
56
--
40
35
--
50
49
--
10
7
--
30
28
--
20
14
--
60
56
--
40
35
--
50
49
--
10
7
--
30
28
--
20
14
--
60
56
--
40
35
--
50
49
--
10
7
--
30
28
--
20
14
--
60
56
--
40
35
--
50
49
--
10
7
--
30
28
--
20
14
--
60
56
--
40
35
--
50
49
--
10
7
--
30
28
--
20
14
--
60
56
--
40
35
--
50
49
--
10
7
--
30
28
--
20
14
--
60
56
--
40
35
--
50
49
--
10
7
--
30
28
--
20
14
--
60
56
--
40
35
--
5
0
-
13|1
0
--
13|10
7
---
13|100
91
---
9
76
----
13|1000
91
---
90
78
--
12
7692307692307692307692307692307692307692307692307692307692307692307692
------------------------------------------------------------------------
13|100000000000000000000000000000000000000000000000000000000000000000000000
91
---
90
78
--
120
117
---
30
26
--
40
39
--
100
91
---
90
78
--
120
117
---
30
26
--
40
39
--
100
91
---
90
78
--
120
117
---
30
26
--
40
39
--
100
91
---
90
78
--
120
117
---
30
26
--
40
39
--
100
91
---
90
78
--
120
117
---
30
26
--
40
39
--
100
91
---
90
78
--
120
117
---
30
26
--
40
39
--
100
91
---
90
78
--
120
117
---
30
26
--
40
39
--
100
91
---
90
78
--
120
117
---
30
26
--
40
39
--
100
91
---
90
78
--
120
117
---
30
26
--
40
39
--
100
91
---
90
78
--
120
117
---
30
26
--
40
39
--
100
91
---
90
78
--
120
117
---
30
26
--
40
39
--
100
91
---
90
78
--
120
117
---
30
26
--
4
1001001
---------
123|123123123
123
---
123
123
---
123
123
---
1000001000001
---------------
123|123000123000123
123
---
123
123
---
123
123
---
1008131089431902440032
------------------------
123|124000124000124000124000
123
---
1000
984
----
161
123
---
382
369
---
134
123
---
1100
984
----
1160
1107
----
531
492
---
392
369
---
234
123
---
1110
1107
----
300
246
---
541
492
---
492
492
---
400
369
---
310
246
---
64
0
-
9999999|1
0
-------
9999999|1000000
1000000
--------------
9999999|10000000000000
9999999
--------
1000000
10000001
---------------
9999999|100000000000000
9999999
--------
10000000
9999999
--------
1
10000001000000
---------------------
9999999|100000000000000000000
9999999
--------
10000000
9999999
--------
1000000
10000001000000100000010000001000000100000010000001000000100000010
------------------------------------------------------------------------
9999999|100000000000000000000000000000000000000000000000000000000000000000000000
9999999
--------
10000000
9999999
--------
10000000
9999999
--------
10000000
9999999
--------
10000000
9999999
--------
10000000
9999999
--------
10000000
9999999
--------
10000000
9999999
--------
10000000
9999999
--------
10000000
9999999
--------
10
100000010000001000000100000010000001000000100000010000001000000100
------------------------------------------------------------------------
9999999|999999999999999999999999999999999999999999999999999999999999999999999999
9999999
-------
9999999
9999999
-------
9999999
9999999
-------
9999999
9999999
-------
9999999
9999999
-------
9999999
9999999
-------
9999999
9999999
-------
9999999
9999999
-------
9999999
9999999
-------
9999999
9999999
-------
99
999999999999999999999999999999999999999999999999999999999999999999999999
------------------------------------------------------------------------
1|999999999999999999999999999999999999999999999999999999999999999999999999
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
9
9
-
1234 56
1002012 12
1 1
0 1
10 1
100 1
300 1
100 3
100 10
100 100
100 1000
1 7
10 7
100 7
1000 7
10000 7
100000 7
10000000000 7
100000000000000000000000000000000000000000000000000000000000000000000000 7
1 13
10 13
100 13
1000 13
100000000000000000000000000000000000000000000000000000000000000000000000 13
123123123 123
123000123000123 123
124000124000124000124000 123
1 9999999
1000000 9999999
10000000000000 9999999
100000000000000 9999999
100000000000000000000 9999999
100000000000000000000000000000000000000000000000000000000000000000000000 9999999
999999999999999999999999999999999999999999999999999999999999999999999999 9999999
999999999999999999999999999999999999999999999999999999999999999999999999 1
#!/bin/bash
cat input | while read nd; do
js long-division.js $nd |
sed 's/\s*$//' | sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba'
done > output
diff -u expected output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment