Skip to content

Instantly share code, notes, and snippets.

View nsmaciej's full-sized avatar
🙂
o awen pona

Maciej Goszczycki nsmaciej

🙂
o awen pona
View GitHub Profile
@nsmaciej
nsmaciej / .config
Created February 9, 2013 15:00
My i3-wm config file.
#Build ins
bindsym Mod4+Shift+c reload
bindsym Mod4+Shift+r restart
#Modes
mode "resize" {
bindsym h resize shrink width 5 px
bindsym j resize grow height 5 px
@nsmaciej
nsmaciej / tree.hs
Created February 16, 2013 00:58
A tree printing script for code golfing.
r=replicate;main=(\x->mapM_ putStrLn[r(x-l)' '++r(l+l-1)'*'|l<-[1..x]++[1]])=<<(readLn::IO Int)
isPrime :: Int -> Bool
isPrime u
| u < 2 = False
| u == 2 = True
| otherwise = not $ maximum [ mod u x == 0 | x <- [2..s]] where s = u - 1
main = do y <- readLn :: IO Int
mapM_ print $ filter (\x -> mod y x == 0 && isPrime x) [1..y]
@nsmaciej
nsmaciej / q1.c
Created February 24, 2013 16:21
My aipo 2013 solutions
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
unsigned t(char a){
return (unsigned)(a-48);
}
int main(void){
char d[13];
@nsmaciej
nsmaciej / sign.c
Created March 21, 2013 21:13
My signature in C.
main(int i) {for(i =7;
i--; printf( "_____ " ))
;puts (""); for( i=7;i
--; printf( "%c%s%c " ,
i>2| i&1?'|' :' ', i==6?
" | " :i==1| i==4 ?" "
:"___" ,i>3 ?(i& 1?' '
:'|') :i&1? ' ': '/'));
puts( ""); for(i =7;i
--; printf("%c%s " ,i>
@nsmaciej
nsmaciej / program1.py
Last active December 15, 2015 08:19
My first ever python program.
import sys
import random
coin = 't'
texts = {"t": "tail", "h": "head"}
def start():
while True:
toss = random.randint(0,1)
guessed = raw_input("Choose [h]ead or [t]ail or [q]uit: ")
@nsmaciej
nsmaciej / parse.c
Last active December 15, 2015 13:38
Sample parser - by James Crook
#include <stdio.h>
char * pSource;
int bDone;
int bOpMatched;
int iNestDepth;
int iNumber;
extern int atoi();
@nsmaciej
nsmaciej / stuff.lisp
Created June 15, 2013 19:21
My experimental lisp file
;;Guess my number REPL game
(defun guess-my-number ()
(ash (+ *small* *big*) -1)
)
(defun smaller ()
(setf *big* (1- (guess-my-number))) ;(1+ x) is same us (+ 1 x)
(guess-my-number)
)
@nsmaciej
nsmaciej / lockers.rb
Last active December 20, 2015 17:09
100 (and more) doors in ruby using threading.
Size = ARGV.first.to_i
doors = Array.new(Size, false)
(1..Size).each do |pass|
(0...Size).each do |pos|
doors[pos] = !doors[pos] if (pos+1) % pass == 0
end
end
doors.each_with_index {|val, pos| puts pos+1 if val}
@nsmaciej
nsmaciej / sign.c
Created September 22, 2013 17:07
'mgoszcz2' printing program 2.0. * Uses magic numbers to store data. * Smaller than it's output * Only two warning using gcc and none using tcc
D[]={1593024318,64462,1343508809,49681,1214537545,45313,1149521993,34961,1593019977,64463,0},*d=D,c;main(){while(*d){while(*d>1)printf("%c",*d%2?42:32),*d/=2;++c%2?:puts(""),d++;}return 0;}