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
def compress(s): | |
compressed_string ="" | |
length=0 | |
ch=re.findall(r"(\w)\1*", s) | |
for z in ch: | |
m=re.search(r'{}*'.format(z), s) | |
length = len(m.group(0)) | |
compressed_string ="{}{}{}".format(compressed_string,z,length) | |
s =s[length:] | |
return compressed_string.replace("1","") |
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
//format date in JS | |
let d = new Date(2010, 7, 5); | |
function formatted_date(d){ | |
let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d); | |
let mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(d); | |
let da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d); | |
return `${da}-${mo}-${ye}`; | |
} | |
formatted_date(d); |
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
var timer = document.getElementById("timer"); | |
var idealTimer = document.getElementById("ideal"); | |
var runningId; | |
var idealId; | |
var value = "0:0"; | |
var Idealvalue = "00:00"; | |
function startTimer(m, s) { | |
value = m + ":" + s; | |
if (s == 60) { | |
m = m + 1; |
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
# 1 -> 2 -> 3 -> 5 -> 2 -> 1 | |
sample_input_graph_dict_1={ | |
"1":["2"], | |
"2":["3","1"], | |
"3":["5"], | |
"4":[], | |
"5":["2"], | |
"6":[], | |
} | |
# 1 -> 3 -> 5 -> 6 -> 4 -> 5 -> 2 -> 6 |
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
const datums = this.S.PlutusList.new(); | |
const datum = this.S.PlutusData.new_constr_plutus_data( | |
this.S.ConstrPlutusData.new( | |
this.S.Int.new_i32(1), | |
this.S.PlutusList.new() | |
) | |
); | |
datums.add(datum); | |
console.log("datums", datums); |
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
//using cardano-serialization-lib | |
const plutusList = CSL.PlutusList.new(); | |
plutusList.add(CSL.PlutusData.new_bytes(Buffer.from('3f7826896a48c593598465a096d63606ceb8206', 'hex'))); | |
plutusList.add(CSL.PlutusData.new_integer(CSL.BigInt.from_str('1888'))); | |
plutusList.add(CSL.PlutusData.new_integer(CSL.BigInt.from_str('1'))); | |
CSL.PlutusData.new_constr_plutus_data(CSL.ConstrPlutusData.new(CSL.Int.new_i32(0), plutusList)); | |
''' | |
{ | |
"constructor":0, |
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
#this is complex | |
thickness = 9 | |
c = 'H' | |
for i in range(thickness): | |
print((c*i).rjust(thickness-1)+c+(c*i).ljust(thickness-1)) | |
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
# Read input from STDIN. Print output to STDOUT | |
# Size: 7 x 21 | |
# ---------.|.--------- | |
# ------.|..|..|.------ | |
# ---.|..|..|..|..|.--- | |
# -------WELCOME------- | |
# ---.|..|..|..|..|.--- | |
# ------.|..|..|.------ | |
# ---------.|.--------- |
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 matplotlib.pyplot as plt | |
p1 = [1, 1] | |
p2 = [5, 3] | |
p3 = [2, 3] | |
x_values = [p1[0], p2[0]] | |
y_values = [p1[1], p2[1]] | |
plt.plot(x_values, y_values, 'bo', linestyle="--") | |
plt.xlim(0, 6), plt.ylim(0, 6) |
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
# Given an integer, , print the following values for each integer from to : | |
# Decimal | |
# Octal | |
# Hexadecimal (capitalized) | |
# Binary | |
hexa_digit = { | |
0: 0, | |
1: 1, |
OlderNewer