Last active
August 29, 2015 13:56
-
-
Save eric-taix/8979187 to your computer and use it in GitHub Desktop.
Solution of CodinGame January in Dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// More concise solution and without multiple split/join which are not useful | |
import 'dart:io'; | |
void main() { | |
String result = ''; | |
stdin.readLineSync().codeUnits.fold([], (r,i) { | |
List str = i.toRadixString(2).split(''); | |
return r ..addAll(new List.generate(7-str.length, (_) => '0')) ..addAll(str); | |
}) | |
.fold(null,(r,c) { | |
result = c != r ? '${result} ${c=="0" ? "00" : "0"} 0' : '${result}0'; | |
return c; | |
}); | |
print(result.substring(1)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment