Guest User

Untitled

a guest
Apr 12th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.98 KB | None | 0 0
  1. # Language Name, N bytes
  2.  
  3. # Ruby, <s>104</s> <s>101</s> 96 bytes
  4.  
  5. sm@+drd1zG
  6.  
  7. implicit: z = input string
  8. m G map each letter (variable d) of the alphabet to:
  9. +drd1 d + upper(d)
  10. @ z filter z for these two letters
  11. s sum, join to a string
  12.  
  13. niveaugourou 0
  14. s=ENTRETONTEXTE()
  15. §2 a=LeCaracNumero()&s *(1)
  16. n=*(1)
  17. costaud i=*(2)/&i infeg NombreDeLettres(&s)/i=+*(1)
  18. b=LeCaracNumero()&s &i
  19. c=&b
  20. d=&a
  21. GOTONULPOURLESNULS %4 }&b sup *(96){
  22. c=-*(32)
  23. §4 GOTONULPOURLESNULS %5 }&a sup *(96){
  24. d=-*(32)
  25. §5 GOTONULPOURLESNULS %1 }&c inf &d{
  26. a=&b
  27. n=&i
  28. §1 faiblard
  29. GOTOPRINTDUTEXTE()&a
  30. s=Marijuana()}BOITEAPINGOUINS()}PrendsUnMorceau()&s *(0) &n{ }PrendsUnMorceau()&s }&n+*(1){ *(0){{ «»
  31. GOTONONNULPOURLESNULS %3 }NombreDeLettres(&s) eg *(1){
  32. GOTOPASMALIN %2
  33. §3 GOTOPRINTDUTEXTE()&s
  34.  
  35. niveaugourou 0 GOTO Allow every keyword to be used
  36. s=ENTRETONTEXTE() GOTO Read from STDIN
  37. §2 a=LeCaracNumero()&s *(1) GOTO Get first char in s
  38. n=*(1)
  39. costaud i=*(2)/&i infeg NombreDeLettres(&s)/i=+*(1) GOTO Loop on every char of s
  40. b=LeCaracNumero()&s &i GOTO b = i-th char
  41. c=&b
  42. d=&a
  43. GOTONULPOURLESNULS %4 }&b sup *(96){ GOTO If b is uppercase, goto §4
  44. c=-*(32) GOTO Get the uppercase ASCII value of b
  45. §4 GOTONULPOURLESNULS %5 }&a sup *(96){ GOTO same as above but with a
  46. d=-*(32)
  47. §5 GOTONULPOURLESNULS %1 }&c inf &d{ GOTO If b is after a in alphabetical order, goto §1 (next loop iteration)
  48. a=&b GOTO Else replace a by b
  49. n=&i
  50. §1 faiblard GOTO End loop
  51. GOTOPRINTDUTEXTE()&a GOTO Print the value of a
  52. t=PrendsUnMorceau()&s *(0) &n GOTO Get the part of s before a
  53. u=PrendsUnMorceau()&s }&n+*(1){ *(0) GOTO Get the part of s after a
  54. e=BOITEAPINGOUINS()&t &u GOTO Create an array of penguins containing the two substrings
  55. s=Marijuana()&e «» GOTO Concatenate the penguins in the array
  56. GOTONONNULPOURLESNULS %3 }NombreDeLettres(&s) eg *(1){ GOTO If s is one char long, goto §3
  57. GOTOPASMALIN %2 GOTO Else goto §2
  58. §3 GOTOPRINTDUTEXTE()&s GOTO Print the last char
  59.  
  60. s*V/LzJ.irG1GJ
  61.  
  62. r=[];t=[];a=s.split('').map(function(x){t[i=parseInt(x,36)]?t[i].push(x):t[i]=[x];return i;});while(l=a.length)r[l-1]=t[a.splice(a.indexOf(Math.max.apply({},a)),1)].pop();console.log(r.join(''))
  63.  
  64. l=[0]*123
  65. for e in raw_input():l[ord(e)]+=1
  66. print''.join(chr(j)*l[j]for i in range(26)for j in(i+65,i+97))
  67.  
  68. << HelloWorldhi
  69. >> deHhillloorW
  70.  
  71. <?php
  72. for($i=65;$i<123;$i++){$v[$i]=chr($i);}foreach(str_split($argv[1])as$c){$a=array_search($c,$v);if($a<97){$p[]=($a+32);$z[]=$a;}else{$p[]=$a;}}foreach($p as$chr){$m=min($p);if($z[0]+32==$m){echo chr($m-32);unset($z[0]);}else{echo chr($m);}unset($p[array_search($m,$p)]);}
  73.  
  74. <?php
  75. $input = $argv[1];
  76. $valueArray = [];
  77. for($i=65;$i<123;$i++) {
  78. $valueArray[$i] = chr($i);
  79. }
  80. $new = str_split($input);
  81. foreach($new as $char) {
  82. if(array_search($char, $valueArray)<97) {
  83. $newArray[] = (array_search($char, $valueArray)+32);
  84. $checkArray[] = array_search($char, $valueArray);
  85. } else {
  86. $newArray[] = array_search($char, $valueArray);
  87. }
  88. }
  89. foreach($newArray as $chr) {
  90. if($checkArray[0]+32 == min($newArray)) {
  91. $string .= chr(min($newArray)-32);
  92. unset($checkArray[0]);
  93. } else {
  94. $string .= chr(min($newArray));
  95. }
  96. $key = array_search(min($newArray), $newArray);
  97. unset($newArray[$key]);
  98. }
  99.  
  100. echo $string;
  101.  
  102. import Data.Char
  103. f y=[c|x<-[' '..],c<-y,toLower c==x]
  104.  
  105. [ |x<-[' '..] ] -- for every x from Space to the last Unicode character
  106. ,c<-y -- loop through all character c from the input string
  107. c ,toLower c==x -- and keep those where the lowercase version equals x
  108.  
  109. z=['']*42
  110. for c in input():z[ord(c)&31]+=c
  111. print(*z,sep='')
  112.  
  113. from itertools import*;print(*min(permutations(input()),key=lambda z:str(z).lower()),sep='')
  114.  
  115. i=input();i,x=map(list,(i,i.lower()))
  116. while x:q=min(x);x.remove(q);q=[q.upper(),q][q in i];i.remove(q);print(q,end="")
  117.  
  118. $a=[char[]]($args[0]);For($u=1;$u-lt$a.Count;$u++){$n=$a[$u];$l=$u;while(($l-gt0)-and((""+$a[$l-1]).CompareTo(""+$n)-gt0)){$a[$l]=$a[$l-1];$l--}$a[$l]=$n};$a-join''
  119.  
  120. PS C:scripts> .sign-word-2.ps1 tTHhis
  121. hHistT
  122.  
  123. $a=[char[]]($args[0]) # Takes command-line argument, recasts as char array
  124. For($u=1;$u-lt$a.Count;$u++){ # Performs a quick-n-dirty insertion sort
  125. $n=$a[$u]
  126. $l=$u
  127. while(($l-gt0)-and((""+$a[$l-1]).CompareTo(""+$n)-gt0)){
  128. # Ugly, ugly code here. String.CompareTo(String) is case-insensitive, but
  129. # because we cast as a char[], Char.CompareTo(Char) is case-sensitive ...
  130. # So, need to do an on-the-fly re-casting as a string with ""+
  131. $a[$l]=$a[$l-1]
  132. $l--
  133. }
  134. $a[$l]=$n
  135. }
  136. $a-join'' # Without the -join'', it would print out the chars with a space between
  137.  
  138. f=s->s>""?(k=indmax([s...]%32);f(s[k+1:end]s[1:k-1])s[k:k]):s
  139.  
  140. x->(f=s->s>""?(k=indmax([s...]%32);f(s[k+1:end]s[1:k-1])s[k:k]):s;print(f(x)))
  141.  
  142. s->(for m=2:endof(s),n=m:-1:2 s[n]%32<s[n-1]%32&&(s=s[[1:n-2,n,n-1,n+1:end]])end;s)
  143.  
  144. s->(k=1;while length(k)>0 k=find(diff([s...]%32).<0);s=s[setdiff(1:end,k)]s[k]end;s)
  145.  
  146. 00000000 b3 82 89 da 8b 07 80 fc 0d 74 12 b9 20 20 09 c1 |.........t.. ..|
  147. 00000010 38 e9 7e 06 86 c4 89 07 31 d2 43 eb e7 85 d2 74 |8.~.....1.C....t|
  148. 00000020 df c6 47 01 24 b4 09 cd 21 c3 |..G.$...!.|
  149. 0000002a
  150.  
  151. org 100h
  152.  
  153. section .text
  154.  
  155. start:
  156. ; bubble sort - external loop
  157. ext:
  158. ; start from the first character (assume bh=0, true on every DOS)
  159. mov bl,82h
  160. ; "not-swapped" flag - 82h => no swaps in current iteration;
  161. ; 0 => a swap happened (the 82h will come in handy later)
  162. mov dx,bx
  163. ; bubble sort - internal loop
  164. int:
  165. ; read 2 characters at time in the full ax
  166. mov ax,word[bx] ; al ah
  167. ; ^[bx] ^[bx+1]
  168. ; check if we are at the end (the command line is CR terminated)
  169. cmp ah,0dh
  170. je skip
  171. ; make uppercase in cx
  172. mov cx,2020h
  173. or cx,ax
  174. ; compare
  175. cmp cl,ch
  176. jle next
  177. ; wrong order - swap and rewrite
  178. xchg al,ah
  179. mov word[bx],ax
  180. ; mark that we did a swap
  181. xor dx,dx
  182. next:
  183. ; next character
  184. inc bx
  185. jmp int
  186. skip:
  187. ; loop as far as we swapped something
  188. test dx,dx
  189. jz ext
  190. end:
  191. ; $-terminate the string
  192. mov byte[bx+1],'$'
  193. ; print
  194. ; dx already contains the location of the string, since that's the
  195. ; flag value we used for "no swaps"
  196. mov ah,9
  197. int 21h
  198. ret
  199.  
  200. @_=/./g;a:{for(0..@_-2){@_[$_,$_+1]=@_[$_+1,$_],redo a if uc$_[$_]gt uc$_[$_+1]}}print@_
  201.  
  202. echo "tThHiIsS" | perl -n sort2.pl
  203.  
  204. hHiIsStT
  205.  
  206. $c=count_chars($argv[1]);$r=str_repeat;for($i=64;++$i<91;)echo$r(chr($i),$c[$i]),$r(chr($i+32),$c[$i+32]);
  207.  
  208. $ php -d error_reporting=0 sign.php qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKasdfJHGFDSAZXCVBNM
  209. AaaBbCcDddEeFffGgHhIiJjKkLlMmNnOoPpQqRrSssTtUuVvWwXxYyZz
  210.  
  211. l=(`mod`32).fromEnum
  212. f=foldr(#)""
  213. e#[]=[e]
  214. e#a@(h:t)|l e<l h=e:a|1<2=h:e#t
  215.  
  216. FcAZ OcQUC_FIa
  217.  
  218. a <- cmdline arg, AZ <- string containing uppercase alphabet (implicit)
  219. FcAZ For each character c in AZ:
  220. FIa Filter characters of a on the following lambda function:
  221. UC_ Uppercase of character...
  222. Qc ... is equal to c
  223. O Output the resulting list, joined on empty string by default
  224.  
  225. dlosc@dlosc:~/pip$ pip -e "FcAZ OcQUC_FIax" "HelLo wOrld"
  226. deHlLloOrw
Add Comment
Please, Sign In to add comment