Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Language Name, N bytes
- # Ruby, <s>104</s> <s>101</s> 96 bytes
- sm@+drd1zG
- implicit: z = input string
- m G map each letter (variable d) of the alphabet to:
- +drd1 d + upper(d)
- @ z filter z for these two letters
- s sum, join to a string
- niveaugourou 0
- s=ENTRETONTEXTE()
- §2 a=LeCaracNumero()&s *(1)
- n=*(1)
- costaud i=*(2)/&i infeg NombreDeLettres(&s)/i=+*(1)
- b=LeCaracNumero()&s &i
- c=&b
- d=&a
- GOTONULPOURLESNULS %4 }&b sup *(96){
- c=-*(32)
- §4 GOTONULPOURLESNULS %5 }&a sup *(96){
- d=-*(32)
- §5 GOTONULPOURLESNULS %1 }&c inf &d{
- a=&b
- n=&i
- §1 faiblard
- GOTOPRINTDUTEXTE()&a
- s=Marijuana()}BOITEAPINGOUINS()}PrendsUnMorceau()&s *(0) &n{ }PrendsUnMorceau()&s }&n+*(1){ *(0){{ «»
- GOTONONNULPOURLESNULS %3 }NombreDeLettres(&s) eg *(1){
- GOTOPASMALIN %2
- §3 GOTOPRINTDUTEXTE()&s
- niveaugourou 0 GOTO Allow every keyword to be used
- s=ENTRETONTEXTE() GOTO Read from STDIN
- §2 a=LeCaracNumero()&s *(1) GOTO Get first char in s
- n=*(1)
- costaud i=*(2)/&i infeg NombreDeLettres(&s)/i=+*(1) GOTO Loop on every char of s
- b=LeCaracNumero()&s &i GOTO b = i-th char
- c=&b
- d=&a
- GOTONULPOURLESNULS %4 }&b sup *(96){ GOTO If b is uppercase, goto §4
- c=-*(32) GOTO Get the uppercase ASCII value of b
- §4 GOTONULPOURLESNULS %5 }&a sup *(96){ GOTO same as above but with a
- d=-*(32)
- §5 GOTONULPOURLESNULS %1 }&c inf &d{ GOTO If b is after a in alphabetical order, goto §1 (next loop iteration)
- a=&b GOTO Else replace a by b
- n=&i
- §1 faiblard GOTO End loop
- GOTOPRINTDUTEXTE()&a GOTO Print the value of a
- t=PrendsUnMorceau()&s *(0) &n GOTO Get the part of s before a
- u=PrendsUnMorceau()&s }&n+*(1){ *(0) GOTO Get the part of s after a
- e=BOITEAPINGOUINS()&t &u GOTO Create an array of penguins containing the two substrings
- s=Marijuana()&e «» GOTO Concatenate the penguins in the array
- GOTONONNULPOURLESNULS %3 }NombreDeLettres(&s) eg *(1){ GOTO If s is one char long, goto §3
- GOTOPASMALIN %2 GOTO Else goto §2
- §3 GOTOPRINTDUTEXTE()&s GOTO Print the last char
- s*V/LzJ.irG1GJ
- 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(''))
- l=[0]*123
- for e in raw_input():l[ord(e)]+=1
- print''.join(chr(j)*l[j]for i in range(26)for j in(i+65,i+97))
- << HelloWorldhi
- >> deHhillloorW
- <?php
- 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)]);}
- <?php
- $input = $argv[1];
- $valueArray = [];
- for($i=65;$i<123;$i++) {
- $valueArray[$i] = chr($i);
- }
- $new = str_split($input);
- foreach($new as $char) {
- if(array_search($char, $valueArray)<97) {
- $newArray[] = (array_search($char, $valueArray)+32);
- $checkArray[] = array_search($char, $valueArray);
- } else {
- $newArray[] = array_search($char, $valueArray);
- }
- }
- foreach($newArray as $chr) {
- if($checkArray[0]+32 == min($newArray)) {
- $string .= chr(min($newArray)-32);
- unset($checkArray[0]);
- } else {
- $string .= chr(min($newArray));
- }
- $key = array_search(min($newArray), $newArray);
- unset($newArray[$key]);
- }
- echo $string;
- import Data.Char
- f y=[c|x<-[' '..],c<-y,toLower c==x]
- [ |x<-[' '..] ] -- for every x from Space to the last Unicode character
- ,c<-y -- loop through all character c from the input string
- c ,toLower c==x -- and keep those where the lowercase version equals x
- z=['']*42
- for c in input():z[ord(c)&31]+=c
- print(*z,sep='')
- from itertools import*;print(*min(permutations(input()),key=lambda z:str(z).lower()),sep='')
- i=input();i,x=map(list,(i,i.lower()))
- while x:q=min(x);x.remove(q);q=[q.upper(),q][q in i];i.remove(q);print(q,end="")
- $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''
- PS C:scripts> .sign-word-2.ps1 tTHhis
- hHistT
- $a=[char[]]($args[0]) # Takes command-line argument, recasts as char array
- For($u=1;$u-lt$a.Count;$u++){ # Performs a quick-n-dirty insertion sort
- $n=$a[$u]
- $l=$u
- while(($l-gt0)-and((""+$a[$l-1]).CompareTo(""+$n)-gt0)){
- # Ugly, ugly code here. String.CompareTo(String) is case-insensitive, but
- # because we cast as a char[], Char.CompareTo(Char) is case-sensitive ...
- # So, need to do an on-the-fly re-casting as a string with ""+
- $a[$l]=$a[$l-1]
- $l--
- }
- $a[$l]=$n
- }
- $a-join'' # Without the -join'', it would print out the chars with a space between
- f=s->s>""?(k=indmax([s...]%32);f(s[k+1:end]s[1:k-1])s[k:k]):s
- x->(f=s->s>""?(k=indmax([s...]%32);f(s[k+1:end]s[1:k-1])s[k:k]):s;print(f(x)))
- 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)
- s->(k=1;while length(k)>0 k=find(diff([s...]%32).<0);s=s[setdiff(1:end,k)]s[k]end;s)
- 00000000 b3 82 89 da 8b 07 80 fc 0d 74 12 b9 20 20 09 c1 |.........t.. ..|
- 00000010 38 e9 7e 06 86 c4 89 07 31 d2 43 eb e7 85 d2 74 |8.~.....1.C....t|
- 00000020 df c6 47 01 24 b4 09 cd 21 c3 |..G.$...!.|
- 0000002a
- org 100h
- section .text
- start:
- ; bubble sort - external loop
- ext:
- ; start from the first character (assume bh=0, true on every DOS)
- mov bl,82h
- ; "not-swapped" flag - 82h => no swaps in current iteration;
- ; 0 => a swap happened (the 82h will come in handy later)
- mov dx,bx
- ; bubble sort - internal loop
- int:
- ; read 2 characters at time in the full ax
- mov ax,word[bx] ; al ah
- ; ^[bx] ^[bx+1]
- ; check if we are at the end (the command line is CR terminated)
- cmp ah,0dh
- je skip
- ; make uppercase in cx
- mov cx,2020h
- or cx,ax
- ; compare
- cmp cl,ch
- jle next
- ; wrong order - swap and rewrite
- xchg al,ah
- mov word[bx],ax
- ; mark that we did a swap
- xor dx,dx
- next:
- ; next character
- inc bx
- jmp int
- skip:
- ; loop as far as we swapped something
- test dx,dx
- jz ext
- end:
- ; $-terminate the string
- mov byte[bx+1],'$'
- ; print
- ; dx already contains the location of the string, since that's the
- ; flag value we used for "no swaps"
- mov ah,9
- int 21h
- ret
- @_=/./g;a:{for(0..@_-2){@_[$_,$_+1]=@_[$_+1,$_],redo a if uc$_[$_]gt uc$_[$_+1]}}print@_
- echo "tThHiIsS" | perl -n sort2.pl
- hHiIsStT
- $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]);
- $ php -d error_reporting=0 sign.php qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKasdfJHGFDSAZXCVBNM
- AaaBbCcDddEeFffGgHhIiJjKkLlMmNnOoPpQqRrSssTtUuVvWwXxYyZz
- l=(`mod`32).fromEnum
- f=foldr(#)""
- e#[]=[e]
- e#a@(h:t)|l e<l h=e:a|1<2=h:e#t
- FcAZ OcQUC_FIa
- a <- cmdline arg, AZ <- string containing uppercase alphabet (implicit)
- FcAZ For each character c in AZ:
- FIa Filter characters of a on the following lambda function:
- UC_ Uppercase of character...
- Qc ... is equal to c
- O Output the resulting list, joined on empty string by default
- dlosc@dlosc:~/pip$ pip -e "FcAZ OcQUC_FIax" "HelLo wOrld"
- deHlLloOrw
Add Comment
Please, Sign In to add comment