@@ -11,54 +11,30 @@ import {
11
11
describe ( 'alphabet' , ( ) => {
12
12
describe ( '.indexAt()' , ( ) => {
13
13
it ( 'should return 0 when the value is A' , ( ) => {
14
- assert . equal ( indexAt ( 'A' ) , 0 ) ;
14
+ assert . equal ( indexAt ( 'A' ) , 1 * 26 ** 0 - 1 ) ;
15
15
} ) ;
16
- it ( 'should return 25 when the value is Z ' , ( ) => {
17
- assert . equal ( indexAt ( 'Z ' ) , 25 ) ;
16
+ it ( 'should return 27 when the value is AB ' , ( ) => {
17
+ assert . equal ( indexAt ( 'AB ' ) , 1 * 26 ** 1 + 2 * 26 ** 0 - 1 ) ;
18
18
} ) ;
19
- it ( 'should return 26 when the value is AA ' , ( ) => {
20
- assert . equal ( indexAt ( 'AA ' ) , 26 ) ;
19
+ it ( 'should return 730 when the value is ABC ' , ( ) => {
20
+ assert . equal ( indexAt ( 'ABC ' ) , 1 * 26 ** 2 + 2 * 26 ** 1 + 3 * 26 ** 0 - 1 ) ;
21
21
} ) ;
22
- it ( 'should return 52 when the value is BA' , ( ) => {
23
- assert . equal ( indexAt ( 'BA' ) , 52 ) ;
24
- } ) ;
25
- it ( 'should return 54 when the value is BC' , ( ) => {
26
- assert . equal ( indexAt ( 'BC' ) , 54 ) ;
27
- } ) ;
28
- it ( 'should return 78 when the value is CA' , ( ) => {
29
- assert . equal ( indexAt ( 'CA' ) , 78 ) ;
30
- } ) ;
31
- it ( 'should return 26 * 26 when the value is ZA' , ( ) => {
32
- assert . equal ( indexAt ( 'ZA' ) , 26 * 26 ) ;
33
- } ) ;
34
- it ( 'should return 26 * 26 + 26 when the value is AAA' , ( ) => {
35
- assert . equal ( indexAt ( 'AAA' ) , ( 26 * 26 ) + 26 ) ;
22
+ it ( 'should return 19009 when the value is ABCD' , ( ) => {
23
+ assert . equal ( indexAt ( 'ABCD' ) , 1 * 26 ** 3 + 2 * 26 ** 2 + 3 * 26 ** 1 + 4 * 26 ** 0 - 1 ) ;
36
24
} ) ;
37
25
} ) ;
38
26
describe ( '.stringAt()' , ( ) => {
39
27
it ( 'should return A when the value is 0' , ( ) => {
40
- assert . equal ( stringAt ( 0 ) , 'A' ) ;
41
- } ) ;
42
- it ( 'should return Z when the value is 25' , ( ) => {
43
- assert . equal ( stringAt ( 25 ) , 'Z' ) ;
44
- } ) ;
45
- it ( 'should return AA when the value is 26' , ( ) => {
46
- assert . equal ( stringAt ( 26 ) , 'AA' ) ;
47
- } ) ;
48
- it ( 'should return BC when the value is 54' , ( ) => {
49
- assert . equal ( stringAt ( 54 ) , 'BC' ) ;
50
- } ) ;
51
- it ( 'should return CB when the value is 78' , ( ) => {
52
- assert . equal ( stringAt ( 78 ) , 'CA' ) ;
28
+ assert . equal ( stringAt ( 1 * 26 ** 0 - 1 ) , 'A' ) ;
53
29
} ) ;
54
- it ( 'should return ZA when the value is 26 * 26 ' , ( ) => {
55
- assert . equal ( stringAt ( 26 * 26 ) , 'ZA ' ) ;
30
+ it ( 'should return AB when the value is 27 ' , ( ) => {
31
+ assert . equal ( stringAt ( 1 * 26 ** 1 + 2 * 26 ** 0 - 1 ) , 'AB ' ) ;
56
32
} ) ;
57
- it ( 'should return Z when the value is 26 * 26 + 1 ' , ( ) => {
58
- assert . equal ( stringAt ( ( 26 * 26 ) + 1 ) , 'ZB ' ) ;
33
+ it ( 'should return ABC when the value is 730 ' , ( ) => {
34
+ assert . equal ( stringAt ( 1 * 26 ** 2 + 2 * 26 ** 1 + 3 * 26 ** 0 - 1 ) , 'ABC ' ) ;
59
35
} ) ;
60
- it ( 'should return AAA when the value is 26 * 26 + 26 ' , ( ) => {
61
- assert . equal ( stringAt ( ( 26 * 26 ) + 26 ) , 'AAA ' ) ;
36
+ it ( 'should return ABCD when the value is 19009 ' , ( ) => {
37
+ assert . equal ( stringAt ( 1 * 26 ** 3 + 2 * 26 ** 2 + 3 * 26 ** 1 + 4 * 26 ** 0 - 1 ) , 'ABCD ' ) ;
62
38
} ) ;
63
39
} ) ;
64
40
describe ( '.expr2xy()' , ( ) => {
0 commit comments