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 kotlinx.coroutines.* | |
fun main() = runBlocking { | |
val job = launch { | |
try { | |
repeat(1000) { i -> | |
println("Job: I'm working $i...") | |
delay(500L) | |
println("at end of try") | |
} | |
} finally { |
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 kotlinx.coroutines.* | |
import kotlinx.coroutines.flow.* | |
fun main() = runBlocking { | |
val userFlow = MutableStateFlow("User 1") | |
val settingsFlow = MutableStateFlow("Dark Mode") | |
// Combine two flows | |
userFlow.combine(settingsFlow) { user, settings -> | |
"User: $user, Settings: $settings" |
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
from fsrs import * | |
from datetime import datetime | |
def print_scheduling_cards(scheduling_cards): | |
print("again.card:", scheduling_cards[Rating.Again].card.__dict__) | |
print("again.review_log:", scheduling_cards[Rating.Again].review_log.__dict__) | |
print("hard.card:", scheduling_cards[Rating.Hard].card.__dict__) | |
print("hard.review_log:", scheduling_cards[Rating.Hard].review_log.__dict__) | |
print("good.card:", scheduling_cards[Rating.Good].card.__dict__) | |
print("good.review_log:", scheduling_cards[Rating.Good].review_log.__dict__) | |
print("easy.card:", scheduling_cards[Rating.Easy].card.__dict__) |
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
fun getPrime(n:Int){ | |
val numArray = BooleanArray(n) {_ -> true} | |
var i = 2 | |
while(i * i < n) { | |
//for each prime number less than square root of n : | |
if (numArray[i]) { | |
var j = i | |
while (j * i < n) { | |
//mark the multiples of that prime number as false . do this below n | |
numArray[j * i] = false |
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
main () | |
{ | |
var computer = 1; | |
var player = 10; | |
if (computer > player) | |
{ | |
print ("my number is higher"); | |
} | |
if (computer < player) | |
{ |
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 'package:flutter/material.dart'; | |
void main() | |
{ | |
runApp(new HelloWorld()); | |
} | |
class HelloWorld extends StatefulWidget { | |
@override | |
_HelloWorldState createState() => _HelloWorldState(); | |
} |
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
void main(){ | |
var x = 1; | |
while (x < 101) | |
{ | |
print (x); | |
x = x + 1; | |
} | |
} | |
1,2,fizz,4,5,fizz,7,8,fizz |
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:io'; | |
import 'dart:math'; | |
main () | |
{ | |
Random r = Random (); | |
int computer = r.nextInt(11); | |
print ("please start guessing number"); | |
while (true) | |
{ | |
String playerstring = stdin.readLineSync (); |
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'; | |
import 'dart:io'; | |
main () | |
{ | |
Random r = Random (); | |
int computer = r.nextInt (11); | |
String playerstr = stdin.readLineSync(); | |
int player = int.parse (playerstr); | |
if (computer > player) |
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:io'; | |
class harryclass | |
{ | |
dance () | |
{ | |
print ("dance"); | |
} | |
} | |
main () |
NewerOlder