daily pastebin goal
19%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. abcdefg hijklmn opqrstu vwxyz
  2.    
  3.     |    /
  4.  O  -O   O   O   O   O-  O
  5. /|   |   |   |   |   |   |
  6.  
  7.         |   |    /
  8. -O   O   O-  O   O   O-  O
  9. /   /       /   /   /   /
  10.  
  11.     |    /         |   /
  12. -O  -O  -O  -O- -O   O   O
  13.                    
  14.  
  15.  |    /   /  
  16.  O   O-  O   O-  O-
  17.                
  18.    
  19. This is Code Golf.
  20.    
  21. |      
  22.  O  -O   O  -O
  23.     /   /    
  24.  
  25.      
  26.  O  -O
  27. /    
  28.  
  29.        |    /
  30.  O  -O   O   O
  31.  |       |   |
  32.  
  33.          /  
  34.  O  -O   O   O-
  35.  |     /    |
  36.    
  37. $_=lc<>;map{y/a-z//cd;y/a-z/`HABDPxc0(!x12"$0xa0tnf30x8835x8224x8421x90/;@a=($/)x4;map{$s=ord;$a[$_/3].=substr" \|/-O-/|\",$_==4||$s>>$_-($_>4)&1?$_+1:0,1for 0..8;$_.=" "for@a}split//;print@a}split
  38.    
  39. $_=lc<>;
  40. map{
  41. y/a-z//cd;
  42. y/a-z/`HABDPxc0(!x12"$0xa0tnf30x8835x8224x8421x90/;
  43. @a=($/)x4;
  44. map{
  45. $s=ord;
  46. $a[$_/3].=substr" \|/-O-/|\",$_==4||$s>>$_-($_>4)&1?$_+1:0,1for 0..8;
  47. $_.=" "for@a
  48. }split//;
  49. print@a}split
  50.    
  51. a = 01100000 96 = `
  52. b = 01001000 72 = H
  53. c = 01000001 65 = A
  54. d = 01000010 66 = B
  55. e = 01000100 68 = D
  56. f = 01010000 80 = P
  57. etc...
  58.    
  59. y/a-z/`HABDP..../;
  60.    
  61. println(readLine.filter(c=>c.isLetter||c==' ').toLowerCase.split(" ").map{_.map(q=>("    O    "/:("^@a,6Tr?W*+5Sq9(2Pn%/-47MU"(q-'a')-27+""))((g,x)=>g.updated(x-'0',"\|/-O-/|\"(x-'0'))).grouped(3).toList).transpose.map(_.mkString(" ")).mkString("n")}.mkString("nn"))
  62.    
  63. println(
  64.   readLine.filter(c => c.isLetter || c==' ').
  65.   toLowerCase.
  66.   split(" ").
  67.   map{ s =>
  68.     val lookup = "^@a,6Tr?W*+5Sq9(2Pn%/-47MU".map(c => (c-27).toString)
  69.     s.map(q =>
  70.       ("    O    " /: lookup(q-'a')){(g,x) =>
  71.         g.updated(x-'0', "\|/-O-/|\"(x-'0'))
  72.       }.grouped(3).toList
  73.     ).transpose.map(_.mkString(" ")).mkString("n")
  74.   }.mkString("nn")
  75. )
  76.    
  77. e='abhioptuwycdjmnsqxzfgvklebr'
  78. for w in raw_input().split():
  79.  for i in 0,3,6,9:print' '.join(''.join((' '+'|/-O-/| '[j])[`j`in'4'+'6736031025071568328578162735'[e.find(c):][:2]]for j in range(i,9)[:3])for c in w if c.lower()in e)
  80.    
  81. |/     012
  82. - -  -> 3 5
  83. /|     678
  84.    
  85. 0: ciotuy
  86. 1: djkptv
  87. 2: elquwx
  88. 3: bhopqrs
  89. 5: fjmrwyz
  90. 6: ahiklmn
  91. 7: abcdefg
  92. 8: gnsvxz
  93.    
  94. abhioptuwycdjmnsqxzfgvklebr
  95. 6736031025071568328578162735
  96.    
  97. gets.split.map{|w|puts (0..2).map{|l|w.chars.map{|c|(' '*576+'CAEAEADBCAF DAEBDACAAAI EAFADACAABG BAEAFEL A_ FACABADADAAG AAFBADQ AGX GAFADABAAAAF'.split.zip('\|/-o-/|\'.chars).map{|a,c|(a.chars.zip([' ',c]*9).map{|x,z|[z]*(x.ord-64)}.flatten)}.transpose*''*2)[c.ord*9+3*l,3]}*' '},''}
  98.    
  99. def k(i:Int,d:Int=0):(Int,Int)=if(i<(7-d))(d,i+1)else k(i-(7-d),d+1)
  100. def t(i:Char)=(if(i=='y')i-4 else
  101. if(i=='z')i+2 else
  102. if(i=='j')i+14 else
  103. if(i>='v')i+3 else
  104. if(i>'i')i-1 else i)-'a'
  105. def q(p:(Int,Int),i:Int,c:Char)=if(p._1==i||p._1+p._2==i)""+c else" "
  106. def g(r:Int,c:Char)={val p=k(t(c.toLower))
  107. print((r match{case 1=>q(p,3,'\')+q(p,4,'|')+q(p,5,'/')
  108. case 2=>q(p,2,'-')+"o"+q(p,6,'-')
  109. case 3=>q(p,1,'/')+q(p,0,'|')+q(p,7,'\')})+" ")}
  110. for(w<-readLine.split(" ")){println;for(r<-(1 to 3)){w.map(c=>g(r,c));println}}
  111.    
  112. def toClock (i: Int, depth: Int=0) : (Int, Int) = {
  113.   if (i < (7 - depth)) (depth, i+1) else toClock (i - (7-depth), depth + 1)}
  114.  
  115. def toIdx (i: Char) = {
  116.  (if (i == 'y') i - 4  else
  117.   if (i == 'z') i + 2  else
  118.   if (i == 'j') i + 14 else
  119.   if (i >= 'v') i + 3 else
  120.   if (i > 'i') i - 1 else i ) - 'a'}
  121.  
  122. def p2c (pair: (Int, Int), i: Int, c: Char) = {
  123.  if (pair._1 == i || pair._1 + pair._2 == i) ""+c else " "
  124. }
  125.  
  126. def printGrid (row: Int, c: Char) = {
  127.   val idx = toIdx (c.toLower)
  128.   val pair = toClock (idx)
  129.   row match {
  130.     case 1 => { print(
  131.       p2c (pair, 3, '\') +
  132.       p2c (pair, 4, '|') +
  133.       p2c (pair, 5, '/') + " ")
  134.     }
  135.     case 2 => { print(
  136.       p2c (pair, 2, '-') + "o" +
  137.       p2c (pair, 6, '-') + " ")
  138.     }
  139.     case 3 => { print(
  140.       p2c (pair, 1, '/') +
  141.       p2c (pair, 0, '|') +
  142.       p2c (pair, 7, '\') + " ")
  143.     }
  144.   }
  145. }
  146.  
  147. val worte = "This is Code Golf"
  148. (1 to 3).map (row => {worte.map (c => printGrid (row, c));println})
  149.    
  150. val iis = is.map {i =>
  151.   if (i == 'y') i - 4  else
  152.   if (i == 'z') i + 2  else
  153.   if (i == 'j') i + 14 else
  154.   if (i >= 'v') i + 3 else
  155.   if (i > 'i') i - 1 else i }.map (_ - 'a')
  156.  
  157. iis.zipWithIndex .sortBy (_._1) .map (p => (p._1, ('a' + p._2).toChar))
  158.  
  159. Vector((97,a), (98, b), (99, c), (100,d), (101,e), (102,f), (103,g),
  160.       (104,h), (105,i), (106,k), (107,l), (108,m), (109,n),
  161.       (110,o), (111,p), (112,q), (113,r), (114,s),
  162.       (115,t), (116,u), (117,y), -------
  163.       -------  (120,j), (121,v),
  164.       (122,w), (123,x),
  165.       (124,z))
  166.    
  167. 3 4 5    | /            |
  168. 2   6   - o -    - o   - o
  169. 1 0 7   / |     (2, ) (2,2)
  170.    
  171. def toClock (i: Int, depth: Int=0) : (Int, Int) = {
  172.   if (i < (7 - depth)) (depth, i+1) else toClock (i - (7-depth), depth + 1)}
  173.  
  174. Vector( (0,1), (0,2), (0,3), (0,4), (0,5), (0,6), (0,7),
  175.     (1,1), (1,2), (1,3), (1,4), (1,5), (1,6),
  176.     (2,1), (2,2), (2,3), (2,4), (2,5),
  177.     (3,1), (3,2), (3,3),
  178.            (4,2), (4,3),
  179.     (5,1), (5,2),
  180.     (6,1))
  181.    
  182. import Data.Char
  183. t[x,y]=q[x,mod(y+1)8]
  184. q z@[x,y]|x==y=[x+1,y+2]|0<1=z
  185. x%y=[x,y]
  186. c 65=0%1
  187. c 74=6%4
  188. c 75=1%4
  189. c 79=2%3
  190. c 84=3%4
  191. c 86=4%7
  192. c 87=5%6
  193. c 89=3%6
  194. c 90=6%7
  195. c x=t$c$pred x
  196. _!9='O'
  197. c!n|n`elem`c="|/-\"!!mod n 4|0<1=' '
  198. s x=do n<-[3:4%5,2:9%6,1:0%7];'n':do c<-x;' ':map(c!)n
  199. main=putStr.s.map(c.ord.toUpper)=<<getLine
  200.    
  201. type Clock = [Int]
  202.  
  203. tick :: Clock -> Clock
  204. tick [h, m] = tick' [h, mod (m + 1) 8]
  205.  
  206. tick' :: Clock -> Clock
  207. tick' [h, m]
  208.   | h == m = [h + 1, m + 2]
  209.   | otherwise = [h, m]
  210.  
  211. clock :: Char -> Clock
  212. clock 'a' = [0,1]
  213. clock 'j' = [6,4]
  214. clock 'k' = [1,4]
  215. clock 'o' = [2,3]
  216. clock 't' = [3,4]
  217. clock 'v' = [4,7]
  218. clock 'w' = [5,6]
  219. clock 'y' = [3,6]
  220. clock 'z' = [6,7]
  221. clock c = tick $ clock $ pred c
  222.  
  223. arm :: Int -> Char
  224. arm 0 = '|'
  225. arm 1 = '/'
  226. arm 2 = '-'
  227. arm 3 = '\'
  228.  
  229. drawAt :: Clock -> Int -> Char
  230. drawAt _ 9 = 'O'
  231. drawAt c n = if n `elem` c
  232.   then arm $ n `mod` 4
  233.   else ' '
  234.  
  235. -- showClock is not in golfed code. Just there for debugging.
  236. showClock :: Clock -> String
  237. showClock c = unlines $ map (map $ drawAt c) [
  238.     [3,4,5]
  239.   , [2,9,6]
  240.   , [1,0,7]
  241.   ]
  242.  
  243. showClocks :: [Clock] -> String
  244. showClocks cs = unlines $ map (showClocks' cs) [[3,4,5],[2,9,6],[1,0,7]]
  245.  
  246. showClocks' :: [Clock] -> [Int] -> String
  247. showClocks' cs ns = cs >>= c -> ' ' : map (drawAt c)
  248.  
  249. mainx :: IO ()
  250. mainx = putStr . showClocks . map clock =<< getLine
  251.    
  252. 345    |/                                                          
  253. 2 6 == -O-          -O          tick  -O   ==   O      tick   O   ==  -O
  254. 107    /|          /                 /        /              |      /
  255.              [1,2] or [2,1]    tick [1,2] == [1,3]     tick [0,7] == [1,2]
  256.    
  257. @_=split('', $ARGV[0]);for (@_){print eval{/[ciotuy]/ ?'\':' '}.eval{/[djkptv]/ ?'|':' '}.eval{/[elquwx]/ ?'/':' '}."n".eval{/[bhopqrs]/ ?'-':' '}."0".eval{/[fjmrwyz]/ ?'-':' '}."n".eval{/[ahiklmn]/ ?'/':' '}.eval{/[abcdefg ]/ ?'|':' '}.eval{/[gnsvxz]/ ?'\':' '."n"};}
RAW Paste Data
Top