Skip to content

Instantly share code, notes, and snippets.

@eric-taix
Last active August 29, 2015 13:56
Show Gist options
  • Save eric-taix/8979187 to your computer and use it in GitHub Desktop.
Save eric-taix/8979187 to your computer and use it in GitHub Desktop.
Solution of CodinGame January in Dart
// 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