Skip to content

Instantly share code, notes, and snippets.

View rekursed's full-sized avatar

Mohammad Hassan rekursed

  • 101ways
  • London
  • 11:15 (UTC +01:00)
View GitHub Profile
@rekursed
rekursed / longest_increasing_subsequence.py
Created April 13, 2020 11:37
Solution for longest increasing subsequence using Dynamic Programming technique (DP)
sequence = [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15]
n = len(sequence)
lis = [[] for i in range(n)]
lis[0].append(sequence[0])
for x in range(1,n):
for y in range(x):
if sequence[x]> sequence[y] and len(lis[x])< len(lis[y])+1:
lis[x]=lis[y].copy()
lis[x].append(sequence[x])
@rekursed
rekursed / console-save.js
Created August 14, 2020 09:35
Saving Console log variable
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'
@rekursed
rekursed / README.md
Created January 5, 2024 14:11
Fruit Machine

Fruit machine

We are going to create a virtual fruit machine. To make things easier instead of symbols we are going to use colours: black, white, green, yellow.

Each time a player plays our fruit machine we display four 'slots' each with a randomly selected colour in each slot.

If the colours in each slot are the same then the player wins the jackpot which is all of the money that is currently in the machine.

Implement a basic machine, along with the concept of a player who has a fixed amount of money to play the machine.