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.util.*; | |
class AddNotAssoc { | |
public static void main( String... args ) { | |
int N = 1000; | |
int errs=0; | |
Random rng = new Random(0); | |
double x,y,z; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
name: divisible by 3 | |
source code: |- | |
# A TM to duplicate a string. | |
# (That is, compute f(w) = ww.) | |
# | |
# @author: ibarland@radford.edu | |
# run this at: https://turingmachine.io/?import-gist=7732e683354339c9993fb0fe5390af90 | |
# assignment: https://www.radford.edu/itec420/2020fall-ibarland/Homeworks/hw06.html | |
# | |
input: 'abbab' |
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
name: palindrome | |
source code: | | |
# https://turingmachine.io/ can run this TM format. | |
# Starting with a^m b^n where m>n, compute a^m b^m | |
# (that is: add b's at the end, to end up with equal a's,b's.) | |
# From Rich (Ch17a slides, slide 13) | |
# | |
input: '_aaaabb' | |
blank: '_' # or try: '␣' '❏' | |
start state: 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
; Improve how OS's "copy" interacts with evil mode. | |
; We want yank'd/kill'd text to be added to the system clipboard, w/o explicit visual text-selection (via mouse-drag, say). | |
; | |
; The problem: | |
; While 'select-enable-clipboard' works find for non-evil emacs users, | |
; it interferes with evil/vim's `evil-change` and relatives: | |
; E.g. you want to replace a couple words with the clipboard, | |
; so you try typing "c2w cmd-V" -- BUT the c2w itself changes the clipboard | |
; (if `select-enable-clipboard` is set), so you end up pasting in exactly the two words | |
; you wanted to replace. |
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
#! /usr/bin/env python3 | |
import os | |
def chownIf(path, targetUid, replacementUid ): | |
"""If the owner of `path` is `targetUid`, then change the owner to `replacementUid`. | |
(UID's are numeric, not string.) | |
BUG -- this doesn't work: Also, if a link is owned by root(0), change it to `replacementUid` as well. | |
""" | |
ownerUid = os.stat(path).st_uid |
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
(define numbers-in-languages '#hash( | |
; (language . #[ 0 1 2 3 4 5 6 7 8 9 10 ]) | |
(english . #[ zero one two three four five six seven eight nine ten ]) | |
(spanish . #[ cero uno dos tres quatro cinqo seis siete ocho nueve dies ]) | |
(italian . #[ zero uno due tre quattro cinque sei sette otto nove dieci ]) | |
(german . #[ null eins zwei drei vier fuenf sechs sieben acht neun zehn ]) | |
(dutch . #[ nul een twee drie vier vijf zes zeven acht negen tien ]) | |
(croatian . #[ nula jedan dva tri cetiri pet sest sedam osam devet deset ]) | |
(hungarian . #[ nulla egy ketto harom negy ot hat het nyolc kilenc tiz ]) | |
(finnish . #[ nolla yksi kaksi kolme nelja viisi kuusi seitseman kahdeksan yhdeksan |
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
# Data definition: A list is either | |
# - [], OR | |
# put( {someItem}, {someList} ) (that is: one item "put" onto the front of some existing (slightly shorter) list) | |
#### helper functions for lists (which we represent internally as the python-builtin-list-type, unsurprisingly). | |
# put: T, list<T> → list<T> (constructor) | |
# Construct a new list, by adding one item to the front of an existing list |
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
assert Arrays.deepEquals( | |
rotateMatrix( new String[][]{ {" ", "X", " "} | |
{" ", "X", "X"}, | |
{" ", " ", " "} } ), | |
new String[][]{ {" ", " ", " "} | |
{" ", "X", "X"}, | |
{" ", "X", " "} } ) |
NewerOlder