Skip to content

Instantly share code, notes, and snippets.

View afrieirham's full-sized avatar
🏠
Working from home

Afrie Irham afrieirham

🏠
Working from home
View GitHub Profile
@afrieirham
afrieirham / projecteuler4.py
Last active January 26, 2019 07:05
Solution to Project Euler #4
def isPalindrome(number):
string = str(number)
list = []
revList = []
i = 0;
while i<len(string):
list.append(string[i])
i += 1
@afrieirham
afrieirham / projecteuler1.java
Created January 26, 2019 07:06
Solution for Project Euler #1
public static void problem1(){
Set<Integer> multiples = new HashSet<Integer>();
for(int i=1; i<1000; i++){
if(i%3==0 || i%5==0){
multiples.add(i);
}
}
Integer[] numbers = multiples.toArray(new Integer[multiples.size()]);
@afrieirham
afrieirham / projecteuler2.java
Created January 26, 2019 07:10
Solution to Project Euler #2
public static void problem2(){
int a = 1;
int b = 2;
int c = 0;
List<Integer> even = new ArrayList<Integer>();
do{
c = a + b;
if(b%2==0){
@afrieirham
afrieirham / projecteuler5.py
Created January 26, 2019 08:37
Solution for Project Euler #5
def problem5():
i=20
while(True):
print(i)
if i%20==0 and i%19==0 and i%18==0 and i%17==0 and i%16==0 and i%15==0 and i%14==0 and i%13==0 and i%12==0 and i%11==0:
print(i)
break
i+= 20
@afrieirham
afrieirham / projecteuler6.py
Created January 26, 2019 09:00
Solution for Project Euler #6
def sumOfSqure(number):
total = 0
for i in range(1, number + 1):
total += i*i
return total
def squareOfSum(number):
total = 0
for i in range(1, number + 1):
total += i
@afrieirham
afrieirham / projecteuler7.py
Created January 26, 2019 09:36
Solution for Project Euler #7
def problem7():
i=2
count = 0
while(True):
if(isPrime(i)):
count += 1
if(count==10001):
print(i)
break
i += 1
@afrieirham
afrieirham / answer.js
Last active February 9, 2019 08:25
Basic JavaScript: Using Objects for Lookups #FCC
// Setup
function phoneticLookup(val) {
var result = "";
let lookup = {
alpha: 'Adams',
bravo: 'Boston',
charlie: 'Chicago',
delta: 'Denver',
echo: 'Easy',
@afrieirham
afrieirham / answer.js
Created February 9, 2019 08:36
Basic JavaScript: Testing Objects for Properties #FCC
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
//Check if the Object has that property, not check the value.
@afrieirham
afrieirham / answer.js
Created February 9, 2019 13:05
Basic JavaScript: Profile Lookup #FCC
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
@afrieirham
afrieirham / index.js
Created May 21, 2019 16:09
Digi-X Section 2
// Question 1
var i=0;
var mulArr = [];
while(i<=100){
if(i%3 == 0 || i%5 == 0){
mulArr.push(i)
}
i++;
}