Skip to content

Instantly share code, notes, and snippets.

View eric-taix's full-sized avatar
🚀

Eric Taix eric-taix

🚀
View GitHub Profile
@eric-taix
eric-taix / gist:e97600883a71140c6985
Created February 21, 2015 17:03
gc-power-of-thor
import 'dart:io';
import 'dart:math';
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
Point lightOfPowerPoint;
Point thorPoint;
<link rel="import" href="../../salesforce/s1-elements/scaffold/s1AppScaffold.html">
<link rel="import" href="../../salesforce/s1-elements/scaffold/s1PageContainer.html">
<link rel="import" href="../../salesforce/s1-elements/s1StagedNavigationStageLeft.html">
<link rel="import" href="../../salesforce/s1-elements/s1StagedNavigationNotifications.html">
<link rel="import" href="../../salesforce/s1-elements/s1AnchorLightDefault.html">
<link rel="import" href="../../salesforce/s1-elements/s1ListWithLabels.html">
<link rel="import" href="../../salesforce/s1-elements/s1AnchorDark.html">
<link rel="import" href="../../salesforce/s1-elements/s1IndicatorDotsLightBackground.html">
<link rel="import" href="../../salesforce/s1-elements/s1ButtonGroups.html">
<link rel="import" href="../../salesforce/s1-elements/scaffold/s1DetailView.html">
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
@eric-taix
eric-taix / gc-stock-exchange
Created February 14, 2014 17:35
Codingame Stock Exchange challenge solution in Dart
// Codingame Stock Exchange challenge solution in Dart
// Eric Taix
import 'dart:io';
void main() {
stdin.readLineSync();
int min = 0;
stdin.readLineSync().split(' ').map((s) => int.parse(s)).fold(null, (r, v) {
if (r == null) return v;
import 'dart:io';
import 'dart:math';
double toRadian(degree) => PI * degree / 180;
double parseDouble(string) => double.parse(string.replaceAll(',','.'));
void main() {
List<double> userLocation = new List<double>.generate(2, (index) => PI * double.parse(stdin.readLineSync().replaceAll(',','.')) / 180);
List defibrillators = new List
.generate(int.parse(stdin.readLineSync()), (index) => stdin.readLineSync().split(';'))
@eric-taix
eric-taix / gc-racing-horses
Created February 14, 2014 13:39
Codingame Racing Horses challenge solution in Dart
// Codingame Racing Horses challenge solution in Dart
// Eric Taix
import 'dart:io';
void main() {
int min = 20000000;
List values = new List.generate(int.parse(stdin.readLineSync()), (_) => int.parse(stdin.readLineSync()))..insert(0, min)..sort((i,j) => i.compareTo(j));
values.reduce((p,n) {
min = (p - n).abs() < min ? (p - n).abs() : min;
@eric-taix
eric-taix / cg-mime-types
Created February 14, 2014 12:40
Codingame MIME types challenge solution in Dart
// Codingame MIME types challenge solution in Dart
// Eric Taix
import 'dart:io';
void main() {
int nbAsso = int.parse(stdin.readLineSync());
int nbFile = int.parse(stdin.readLineSync());
Map mimes = new List.generate(nbAsso, (_) => stdin.readLineSync()).map((s) => s.split(' ')).fold({}, (r, s) => r ..[s[0].toLowerCase()] = s[1]);
@eric-taix
eric-taix / cg-ascii-art
Created February 14, 2014 12:05
Codingame ASCII Art challenge solution in Dart
import 'dart:io';
void main() {
int width = int.parse(stdin.readLineSync());
int height = int.parse(stdin.readLineSync());
List chars = stdin.readLineSync().split('').map((c) => c.toUpperCase()).map((c) => c.codeUnits[0]).toList();
List dots = new List.generate(height, (_) => stdin.readLineSync().codeUnits.fold([], (d,i) => d..add(i))).fold([], (r,l) => r..addAll(l));
@eric-taix
eric-taix / cg-temperature
Created February 14, 2014 10:31
Codingame temperature challenge solution in Dart
// Codingame temperature challenge solution in Dart
// Eric Taix
import 'dart:io';
void main() {
print(int.parse(stdin.readLineSync()) == 0 ? 0 : stdin.readLineSync().split(' ').map((s) => int.parse(s))
.fold(10000,(r,i) => i.abs() == r.abs() ? (i > r ? i : r) : i.abs().compareTo(r.abs()) == -1 ? i : r));
}
@eric-taix
eric-taix / Chuck Norris
Last active August 29, 2015 13:56
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);
})