Created
May 15, 2020 11:55
-
-
Save geektutor/3e295ee2b90b1d29c9bdaf786e43b8b2 to your computer and use it in GitHub Desktop.
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
import 'dart:math'; | |
void main() { | |
Taxi(2); | |
} | |
int Taxi(k) { | |
/* I HATE THIS TASK. Taxi was on its own and you decided to be using it to create function mtcheeeew. And DartPad keeps crashing so I cant test more than 2 | |
Function to find the nth taxi cab number*/ | |
List store = []; | |
var a = 1, b = 2; | |
while (a < k + 1) { | |
var check = [ | |
for (int i = 1; i < pow(b, 1 / 3); i++) | |
for (int j = 1; j < pow(b, 1 / 3); j++) | |
if (i * i * i + j * j * j == b && i >= j) [i, j] | |
]; | |
if (check.length == a) { | |
store.add(b); | |
a += 1; | |
} | |
b += 1; | |
} | |
print(store.last); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment