This file contains 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
""" | |
MIT License | |
Copyright (c) 2023 Aimon Labs Inc. | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
This file contains 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
""" | |
MIT License | |
Copyright (c) 2023 Aimon Labs Inc. | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
This file contains 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 math | |
import numpy as np | |
p = 0.9 | |
d = 10 | |
def sum_series(p, d): | |
# tail recursive helper function | |
def helper(ret, p, d, i): | |
term = math.pow(p, i)/i |
This file contains 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 math | |
def rbo(list1, list2, p=0.9): | |
# tail recursive helper function | |
def helper(ret, i, d): | |
l1 = set(list1[:i]) if i < len(list1) else set(list1) | |
l2 = set(list2[:i]) if i < len(list2) else set(list2) | |
a_d = len(l1.intersection(l2))/i | |
term = math.pow(p, i) * a_d | |
if d == i: | |
return ret + term |
This file contains 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
package com.yahoo.broadway.serving.actors; | |
import java.util.ArrayList; | |
import java.util.List; | |
//Creates duplicates :( | |
class PointEnumeration { | |
static class Point { | |
List<Float> dimensions; //a list of float where index i is the (i+1)'th dimension |
This file contains 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.util.*; | |
/** | |
* nlogn solution to http://www.geeksforgeeks.org/weighted-job-scheduling/ | |
*/ | |
class Solution { | |
public static void main(String[] args) { | |
List<Job> jobs = Arrays.asList(new Job(3, 10, 20),new Job(1, 2, 50), new Job(6, 19, 100),new Job(2, 100, 200)); | |
System.out.println("Max profit = " + findMax(jobs)); |
This file contains 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.util.ArrayList; | |
import java.util.List; | |
public class Solution { | |
public static void main(String args[] ) throws Exception { | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
String line = br.readLine(); |