Skip to content

Instantly share code, notes, and snippets.

View andrealaforgia's full-sized avatar

Andrea Laforgia andrealaforgia

View GitHub Profile

Prova Language Specification

Version 0.4 (draft). Status: design complete for a v1 compiler; open items listed in section 15. Changes from 0.1 are recorded in Appendix B, from 0.2 in Appendix C, and from 0.3 in Appendix D.

1. Purpose and founding principle

Prova is a programming language designed for code generation by large language models. Its founding principle:

A Prova program is a claim plus its evidence. The compiler rejects claims without evidence.

import kotlin.random.Random
class Node(var value: Int) {
var left: Node? = null
var right: Node? = null
}
class BinaryTree {
var root: Node? = null
class Node:
def __init__(self, name):
self.adjacent_nodes = []
self.name = name
self.traversed = 0
def add_adjacent_node(self, adjacent_node):
self.adjacent_nodes.append(adjacent_node)
def is_small_cave(self):
class Node:
def __init__(self, name):
self.adjacent_nodes = []
self.name = name
self.traversed = 0
def add_adjacent_node(self, adjacent_node):
self.adjacent_nodes.append(adjacent_node)
def is_small_cave(self):
@andrealaforgia
andrealaforgia / day11_2.py
Created December 11, 2021 20:07
day11_2.py
def within_bounds(_y, _x, matrix):
return 0 <= _y < len(matrix) and 0 <= _x < len(matrix[0])
def adjacent_cells(y, x, matrix):
for _y in range(y - 1, y + 2):
for _x in range(x - 1, x + 2):
if within_bounds(_y, _x, matrix):
yield _y, _x
from functools import reduce
def calc_basin_size(y, x, matrix, fill_matrix, size):
fill_matrix[y][x] = 1
up_size = 0
dn_size = 0
lf_size = 0
rt_size = 0
if y > 0 and fill_matrix[y - 1][x] == 0 and matrix[y-1][x] != 9:
def contains_all(str, set):
return 0 not in [c in str for c in set]
def find_digits(input_parts):
digits = [""] * 10
cands960 = set()
cands532 = set()
for input_part in input_parts:
if len(input_part) == 2:
@andrealaforgia
andrealaforgia / avd-hardware-profile-huawei-mate-20x.xml
Created July 10, 2021 21:46 — forked from mouselangelo/avd-hardware-profile-huawei-mate-20x.xml
Android: Basic AVD Hardware profile for the Huawei Mate 20 X phone
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<d:devices xmlns:d="http://schemas.android.com/sdk/devices/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<d:device>
<d:name>HUAWEI Mate 20 X</d:name>
<d:manufacturer>HUAWEI</d:manufacturer>
<d:meta/>
<d:hardware>
<d:screen>
<d:screen-size>large</d:screen-size>
<d:diagonal-length>7.20</d:diagonal-length>
package com.company;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class Main {
@Test
void shouldCompressAndDecompress() throws IOException {
whenCompressingData();
thenDataIsCompressed();
thenCompressedDataShouldBeCorrectlyDecompressed();
thenTheCompressionRatioIsPrintedOut();
}
private void thenTheCompressionRatioIsPrintedOut() {
long inputSize = TEST_DATA.getBytes().length;