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 os | |
import sys | |
from groq import Groq | |
import json | |
import time | |
SAVE_FILE = ".groq_chat_history.json" | |
model = "8" | |
args = sys.argv[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
# Example of using custom | operations | |
# Lets say we want to emulate LCEL, a language that uses | as a pipe operator | |
# For this example we will start with an input which is a dictionary | |
# and we want our operator object to read the 'input' key and add a new key 'output' | |
# Our starting data | |
input_data = {'input': "Hello World"} | |
# Our operator object that reverses the input and stores it in the 'output' key |
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 sys | |
import math | |
import random | |
from copy import deepcopy | |
from datetime import datetime | |
winning_states = ( # use tuple instead of list for speed | |
0b111_000_000, 0b000_111_000, 0b000_000_111, | |
0b100_100_100, 0b010_010_010, 0b001_001_001, |
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
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <algorithm> | |
#include <bitset> | |
using namespace std; | |
int main() { |
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 getChoice(choices): | |
message = "Pick one of : " + ", ".join(choices) + " > " | |
choice = "" | |
while choice not in choices: | |
choice = input(message) | |
print() | |
return choice | |
if __name__ == "__main__": |
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 random | |
# Some fun flavour text to start off | |
character_descriptions = ["tall", "short", "sly", "lanky", "blue"] | |
character_gender = ["male","female"] | |
character_race = ["human","goblin"] | |
description = random.choice(character_descriptions) + " " + random.choice(character_gender) + " " + random.choice(character_race) |
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
# -- imports -- | |
import numpy as np | |
import tensorflow as tf | |
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR) | |
# np.set_printoptions(precision=2) reduces np precision output to 2 digit | |
np.set_printoptions(precision=2, suppress=True) | |
# -- constant data -- | |
x = [[0., 0.], [1., 1.], [1., 0.], [0., 1.], [-1., -1.], [-1., 0.], [0., -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
from subprocess import Popen, PIPE | |
import sys | |
player1 = sys.argv[1] | |
player2 = sys.argv[2] | |
def sendReceive(proc, message): | |
proc.stdin.write(message) | |
proc.stdin.flush() | |
return proc.stdout.readline() |
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 time | |
import math | |
import random | |
def randomPolicy(state): | |
while not state.isTerminal(): | |
try: | |
action = random.choice(state.getPossibleActions()) | |
except IndexError: |
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 asSubstring(number): | |
result = [] | |
decimal = False | |
for n in str(number): | |
if n == '.': | |
decimal = True | |
else: | |
result.append(chr(int(n) + 48 + 8272 * decimal)) | |
return u''.join(result) | |
asSubstring(123.456) |
NewerOlder