YAPC::EU 2018 Glasgow Update!
This commit is contained in:
parent
22f33d4004
commit
4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions
25
Task/Guess-the-number/ABAP/guess-the-number.abap
Normal file
25
Task/Guess-the-number/ABAP/guess-the-number.abap
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
REPORT guess_the_number.
|
||||
|
||||
DATA prng TYPE REF TO cl_abap_random_int.
|
||||
|
||||
cl_abap_random_int=>create(
|
||||
EXPORTING
|
||||
seed = cl_abap_random=>seed( )
|
||||
min = 1
|
||||
max = 10
|
||||
RECEIVING
|
||||
prng = prng ).
|
||||
|
||||
DATA(number) = prng->get_next( ).
|
||||
|
||||
DATA(field) = VALUE i( ).
|
||||
|
||||
cl_demo_input=>add_field( EXPORTING text = |Choice one number between 1 and 10| CHANGING field = field ).
|
||||
cl_demo_input=>request( ).
|
||||
|
||||
WHILE number <> field.
|
||||
cl_demo_input=>add_field( EXPORTING text = |You miss, try again| CHANGING field = field ).
|
||||
cl_demo_input=>request( ).
|
||||
ENDWHILE.
|
||||
|
||||
cl_demo_output=>display( |Well Done| ).
|
||||
|
|
@ -1,12 +1,9 @@
|
|||
import 'dart:math';
|
||||
void main()
|
||||
{
|
||||
int y=5;
|
||||
int max=11,min=1;
|
||||
var x= new Random();
|
||||
x=x.nextInt(max-min);
|
||||
if (y==x)
|
||||
print("WON");
|
||||
else
|
||||
print('Try Again');
|
||||
import 'dart:io';
|
||||
|
||||
main() {
|
||||
final n = (1 + new Random().nextInt(10)).toString();
|
||||
print("Guess which number I've chosen in the range 1 to 10");
|
||||
do { stdout.write(" Your guess : "); } while (n != stdin.readLineSync());
|
||||
print("\nWell guessed!");
|
||||
}
|
||||
|
|
|
|||
6
Task/Guess-the-number/Emacs-Lisp/guess-the-number.l
Normal file
6
Task/Guess-the-number/Emacs-Lisp/guess-the-number.l
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(let ((num (1+ (random 10))))
|
||||
(princ "Guess the no")
|
||||
(loop
|
||||
(setq guess (read))
|
||||
(if (eq guess num)
|
||||
(progn(princ-list "Guess was right! " num) (return)) (print "Wrong, try again.") ) ) )
|
||||
|
|
@ -1,16 +1,8 @@
|
|||
// version 1.0.5-2
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val rand = java.util.Random()
|
||||
val n = 1 + rand.nextInt(10)
|
||||
var guess: Int
|
||||
println("Guess which number I've chosen in the range 1 to 10\n")
|
||||
while (true) {
|
||||
print(" Your guess : ")
|
||||
guess = readLine()!!.toInt()
|
||||
if (n == guess) {
|
||||
println("\nWell guessed!")
|
||||
return
|
||||
}
|
||||
}
|
||||
val n = (1 + java.util.Random().nextInt(10)).toString()
|
||||
println("Guess which number I've chosen in the range 1 to 10\n")
|
||||
do { print(" Your guess : ") } while (n != readLine())
|
||||
println("\nWell guessed!")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue