Skip to content

Instantly share code, notes, and snippets.

View LuxXx's full-sized avatar

David LuxXx

View GitHub Profile
@LuxXx
LuxXx / samp_settime.ahk
Created February 14, 2017 15:43
Set Time for SAMP AHK
; sets the ingame hour (day/night)
; @author luxdav aka David_Luchs
; @param hour the time between 0 and 23
setTime(hour)
{
if(!checkHandles())
return
; disable gta setTime function
VarSetCapacity(nop, 6, 0)
Loop 6 {
@LuxXx
LuxXx / digitat.java
Created February 17, 2017 22:06
digitat (left to right)
public static int digitAt(int n, int i) {
// (n mod 10^i)/(10^i-1)
int a = n % (int) Math.pow(10,i); // a = n modulo 10^i
int b = (int) Math.pow(10,i-1); // b 10^-1
return (int) Math.floor(a/b);
}
@LuxXx
LuxXx / EnumToClass.java
Last active April 6, 2017 13:58
What is actually an enum? It is actually just a class.
/*
* I wanted to understand the inner of an enum better, therefore I tried to build my own enumeration class
* that does exactly the same
* This code equals to
* public enum Enum {
* A, B, C;
* }
*/
import java.lang.reflect.Field;
@LuxXx
LuxXx / sierpinski.js
Created April 8, 2017 18:19
the sierpinski carpet
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sierpinski</title>
</head>
<body>
<canvas id="canvas" width="1000" height="1000" style="border:1px solid #FF0000;"></canvas>
<script type="text/javascript">
let c = document.getElementById('canvas');
@LuxXx
LuxXx / euler.java
Created April 14, 2017 02:15
Project Euler - Problem 3
package euler;
public class Prime {
public static void main(String[] args) {
int n = 100000;
// initially assume all integers are prime
boolean[] isPrime = new boolean[n+1];
for (int i = 2; i <= n; i++) {
@LuxXx
LuxXx / euler.java
Created April 14, 2017 02:15
Project Euler - Problem 4
package euler;
import java.util.Comparator;
import java.util.PriorityQueue;
public class Pal {
public static void main(String[] args) {
System.out.println(isPalindrome(1221));
System.out.println(isPalindrome(1234));
@LuxXx
LuxXx / euler.java
Created April 14, 2017 02:22
Project Euler - Problem 5
package euler;
public class Divisible {
public static void main(String[] args) {
for (long i = 0; i < Long.MAX_VALUE; i++) {
if (isDivisible(i)) System.out.println(i);
}
}
public static boolean isDivisible(long n) {
@LuxXx
LuxXx / euler.java
Created April 14, 2017 11:40
Project Euler - Problem 6
package euler;
public class Square {
public static void main(String[] args) {
System.out.println(sum2(100) - sum(100));
}
public static int sum(int n) {
return n*(n+1)*(2*n+1)/6;
@LuxXx
LuxXx / euler.java
Created April 14, 2017 15:30
Project Euler - Problem 8
package euler;
import java.util.Comparator;
import java.util.PriorityQueue;
public class AdjacentDigits {
private static String n = "731671765313306249192251196744265747423553491949349698352031277450632623957831801698480186947885184385861560789112949495459501737958331952853208805511125406987471585238630507156932909632952274430435576689664895044524452316173185640309871112172238311362229893423380308135336276614282806444486645238749303589072962904915604407723907138105158593079608667017242712188399879790879227492190169972088809377665727333001053367881220235421809751254540594752243525849077116705560136048395864467063244157221553975369781797784617406495514929086256932197846862248283972241375657056057490261407972968652414535100474821663704844031998900088952434506585412275886668811642717147992444292823086346567481391912316282458617866458359124566529476545682848912883142607690042242190226710556263211111093705442175069416589604080719840385096245544436298123098787992724428490918884580156166097919133875499200524063
@LuxXx
LuxXx / euler.java
Created April 14, 2017 15:35
Project Euler - Problem 9
package euler;
public class Triplet {
public static void main(String[] args) {
int n = 1000;
for (int a = 1; a < n; a++) {
for (int b = a; b < n; b++) {
for (int c = b; c < n; c++) {
if (a*a + b*b == c*c && a+b+c == n) {
System.out.println(a*b*c);