File tree Expand file tree Collapse file tree 5 files changed +67
-1
lines changed
solution/1800-1899/1812.Determine Color of a Chessboard Square Expand file tree Collapse file tree 5 files changed +67
-1
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ class Solution:
80
80
``` java
81
81
class Solution {
82
82
public boolean squareIsWhite (String coordinates ) {
83
- return (coordinates. charAt(0 ) + coordinates. charAt(1 )) % 2 == 1 ;
83
+ return (coordinates. charAt(0 ) + coordinates. charAt(1 )) % 2 == 1 ;
84
84
}
85
85
}
86
86
```
@@ -118,6 +118,33 @@ var squareIsWhite = function (coordinates) {
118
118
};
119
119
```
120
120
121
+ ### ** TypeScript**
122
+
123
+ ``` ts
124
+ function squareIsWhite(coordinates : string ): boolean {
125
+ return ((coordinates .charCodeAt (0 ) + coordinates .charCodeAt (1 )) & 1 ) === 1 ;
126
+ }
127
+ ```
128
+
129
+ ### ** Rust**
130
+
131
+ ``` rust
132
+ impl Solution {
133
+ pub fn square_is_white (coordinates : String ) -> bool {
134
+ let s = coordinates . as_bytes ();
135
+ s [0 ] + s [1 ] & 1 == 1
136
+ }
137
+ }
138
+ ```
139
+
140
+ ### ** C**
141
+
142
+ ``` c
143
+ bool squareIsWhite (char * coordinates) {
144
+ return (coordinates[ 0] + coordinates[ 1] ) & 1;
145
+ }
146
+ ```
147
+
121
148
### **...**
122
149
123
150
```
Original file line number Diff line number Diff line change @@ -100,6 +100,33 @@ var squareIsWhite = function (coordinates) {
100
100
};
101
101
```
102
102
103
+ ### ** TypeScript**
104
+
105
+ ``` ts
106
+ function squareIsWhite(coordinates : string ): boolean {
107
+ return ((coordinates .charCodeAt (0 ) + coordinates .charCodeAt (1 )) & 1 ) === 1 ;
108
+ }
109
+ ```
110
+
111
+ ### ** Rust**
112
+
113
+ ``` rust
114
+ impl Solution {
115
+ pub fn square_is_white (coordinates : String ) -> bool {
116
+ let s = coordinates . as_bytes ();
117
+ s [0 ] + s [1 ] & 1 == 1
118
+ }
119
+ }
120
+ ```
121
+
122
+ ### ** C**
123
+
124
+ ``` c
125
+ bool squareIsWhite (char * coordinates) {
126
+ return (coordinates[ 0] + coordinates[ 1] ) & 1;
127
+ }
128
+ ```
129
+
103
130
### **...**
104
131
105
132
```
Original file line number Diff line number Diff line change
1
+ bool squareIsWhite (char * coordinates ) {
2
+ return (coordinates [0 ] + coordinates [1 ]) & 1 ;
3
+ }
Original file line number Diff line number Diff line change
1
+ impl Solution {
2
+ pub fn square_is_white ( coordinates : String ) -> bool {
3
+ let s = coordinates. as_bytes ( ) ;
4
+ s[ 0 ] + s[ 1 ] & 1 == 1
5
+ }
6
+ }
Original file line number Diff line number Diff line change
1
+ function squareIsWhite ( coordinates : string ) : boolean {
2
+ return ( ( coordinates . charCodeAt ( 0 ) + coordinates . charCodeAt ( 1 ) ) & 1 ) === 1 ;
3
+ }
You can’t perform that action at this time.
0 commit comments