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
| def FizzBuzz(n: Int, rules: List[Int], says: List[String]): Unit = { | |
| def checker(rule: Int, say: String): (Int) => String = (k: Int) => if(k % rule == 0) say else "" | |
| val guards = (for { | |
| i <- 0 until rules.length | |
| } yield checker(rules(i), says(i))).toList | |
| def stringGen(k: Int, gs: List[(Int) => String]): String = if(!gs.isEmpty) gs.head(k) + stringGen(k, gs.tail) else "" | |
| for (i <- 1 to n) { | |
| val s = stringGen(i, guards) | |
| if(s != "") println(s) | |
| else println(i) |
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 scala.annotation.tailrec | |
| def gugu(max: Int): Unit = { | |
| @tailrec | |
| def go(i:Int, j:Int): Unit = { | |
| if(i > max) return | |
| else if(j > max) return go(i+1, 1) | |
| else { | |
| println("%d * %d = %d".format(i, j, i*j)) | |
| go(i, j+1) |
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
| for (year <- 1999 to 2019 if year % 4 == 0 if ((year % 100 != 0) || (year % 400 == 0))) println(year) |
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
| def rot13(s: String) = s.map(x => x match { | |
| case c if 'A' to 'Z' contains c => ('A' to 'Z')(((c.toInt - 'A') + 13) % 26) | |
| case z if 'a' to 'z' contains z => ('a' to 'z')(((z.toInt - 'a') + 13) % 26) | |
| case other => other | |
| }) | |
| println(rot13("Hello World!!!!!!!")) // Uryyb Jbeyq!!!!!!! |
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
| def qsort(lst: List[Int]): List[Int] = lst match { | |
| case Nil => Nil | |
| case x :: xs => qsort(xs.filter(_ <= x)) ::: List(x) ::: qsort(xs.filter(_ > x)) | |
| } | |
| println(qsort(List(15, 3, 6, 7, 9, 1))) // List(1, 3, 6, 7, 9, 15) |
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 java.io._ | |
| import java.math._ | |
| import java.security._ | |
| import java.text._ | |
| import java.util._ | |
| import java.util.concurrent._ | |
| import java.util.function._ | |
| import java.util.regex._ | |
| import java.util.stream._ |
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 java.io._ | |
| import java.math._ | |
| import java.security._ | |
| import java.text._ | |
| import java.util._ | |
| import java.util.concurrent._ | |
| import java.util.function._ | |
| import java.util.regex._ | |
| import java.util.stream._ |
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 selenium import webdriver | |
| from selenium.webdriver.common.keys import Keys | |
| # download chromedriver to source code path | |
| # python main.py | |
| def login(): | |
| driver.get("https://ideone.com") | |
| driver.find_element_by_class_name("icon-signin").find_element_by_xpath("..").click() |
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
| #define _CRT_SECURE_NO_WARNINGS | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <malloc.h> | |
| typedef struct _student { | |
| int number; | |
| int score[3]; | |
| int sum; | |
| double avg; |
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
| ; (dolist (char-regexp alist) | |
| ; (set-char-table-range composition-function-table (car char-regexp) | |
| ; `([,(cdr char-regexp) 0 font-shape-gstring])))) | |
| (require 'package) | |
| (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) | |
| (package-initialize) | |
| (custom-set-variables | |
| ;; custom-set-variables was added by Custom. | |
| ;; If you edit it by hand, you could mess it up, so be careful. | |
| ;; Your init file should contain only one such instance. |