Bitcoin Forum

Economy => Services => Topic started by: Redones on April 18, 2016, 02:11:28 AM



Title: PHP programmer needed
Post by: Redones on April 18, 2016, 02:11:28 AM
its a easy task for an expert php dev,I will pay at least 0.001BTC maybe more
I wanna an php script that extract only uppercase word from this text:

4. A quick and lively dance. [Obs.]
Make you dance canary With sprightly fire and motion. Shak.

CANARY
Ca*na"ry, v. i.

Defn: To perform the canary dance; to move nimbly; to caper. [Obs.]
But to jig of a tune at the tongue's end, canary to it with your
feet. Shak.
CANARY BIRD
Ca*na"ry bird`. (Zoöl.)

Defn: A small singing bird of the Finch family (Serinus Canarius), a
native of the Canary Islands. It was brought to Europe in the 16th
century, and made a household pet. It generally has a yellowish body
with the wings and tail greenish, but in its wild state it is more
frequently of gray or brown color. It is sometimes called canary
finch.canary.

Canary bird flower (Bot.), a climbing plant (Tropæolum peregrinum)
with canary-colored flowers of peculiar form; -- called also canary
vine.

CANASTER
Ca*nas"ter, n. Etym: [Sp. canasta, canastro, basket, fr. L.
canistrum. See Canister.]

Defn: A kind of tobacco for smoking, made of the dried leaves,
coarsely broken; -- so called from the rush baskets in which it is
packed in South America. McElrath.

CAN BUOY
Can" buoy`.

Defn: See under Buoy, n.

CANCAN
Can"can, n. Etym: [F.]

Defn: A rollicking French dance, accompanied by indecorous or
extravagant postures and gestures.

CANCEL
Can"cel, v. i. [Imp. & p. p. Canceled or Cancelled (; p. pr. & vb. n.
Canceling or Cancelling.] Etym: [L. cancellare to make like a
lattice, to strike or cross out (cf. Fr. canceller, OF. canceler) fr.
cancelli lattice, crossbars, dim. of cancer lattice; cf. Gr.
Chancel.}]




Title: Re: PHP programmer needed
Post by: bitspill on April 18, 2016, 04:43:23 AM
Here's a quick solution, there's probably a more elegant/performant way around however.


Code:
<?php
function extractUppercase($str) { 
$ret = array();
$arr preg_split("/[\s,\.\p{P}]+/"$str);

$count count($arr);
for ($i 0$i $count$i++) {                
if ($arr[$i] == strtoupper($arr[$i]) && !empty($arr[$i]) && !is_numeric($arr[$i]))
$ret[] = $arr[$i];
}
return $ret;
}


echo 
"<pre>";


$test '4. A quick and lively dance. [Obs.]
Make you dance canary With sprightly fire and motion. Shak.
CANARY
Ca*na"ry, v. i.
Defn: To perform the canary dance; to move nimbly; to caper. [Obs.]
But to jig of a tune at the tongue\'s end, canary to it with your
feet. Shak.
CANARY BIRD
Ca*na"ry bird`. (Zoöl.)
Defn: A small singing bird of the Finch family (Serinus Canarius), a
native of the Canary Islands. It was brought to Europe in the 16th
century, and made a household pet. It generally has a yellowish body
with the wings and tail greenish, but in its wild state it is more
frequently of gray or brown color. It is sometimes called canary
finch.canary.
Canary bird flower (Bot.), a climbing plant (Tropæolum peregrinum)
with canary-colored flowers of peculiar form; -- called also canary
vine.
CANASTER
Ca*nas"ter, n. Etym: [Sp. canasta, canastro, basket, fr. L.
canistrum. See Canister.]
Defn: A kind of tobacco for smoking, made of the dried leaves,
coarsely broken; -- so called from the rush baskets in which it is
packed in South America. McElrath.
CAN BUOY
Can" buoy`.
Defn: See under Buoy, n.
CANCAN
Can"can, n. Etym: [F.]
Defn: A rollicking French dance, accompanied by indecorous or
extravagant postures and gestures.
CANCEL
Can"cel, v. i. [Imp. & p. p. Canceled or Cancelled (; p. pr. & vb. n.
Canceling or Cancelling.] Etym: [L. cancellare to make like a
lattice, to strike or cross out (cf. Fr. canceller, OF. canceler) fr.
cancelli lattice, crossbars, dim. of cancer lattice; cf. Gr.
Chancel.}]'
;

$result extractUppercase($test);

echo 
"Test:\n\n"$test"\n\n\n\nResult:\n\n";
print_r($result);

echo 
"</pre>";
?>

Which leads to this sample output:

Test:

4. A quick and lively dance. [Obs.]
Make you dance canary With sprightly fire and motion. Shak.
CANARY
Ca*na"ry, v. i.
Defn: To perform the canary dance; to move nimbly; to caper. [Obs.]
But to jig of a tune at the tongue's end, canary to it with your
feet. Shak.
CANARY BIRD
Ca*na"ry bird`. (Zoöl.)
Defn: A small singing bird of the Finch family (Serinus Canarius), a
native of the Canary Islands. It was brought to Europe in the 16th
century, and made a household pet. It generally has a yellowish body
with the wings and tail greenish, but in its wild state it is more
frequently of gray or brown color. It is sometimes called canary
finch.canary.
Canary bird flower (Bot.), a climbing plant (Tropæolum peregrinum)
with canary-colored flowers of peculiar form; -- called also canary
vine.
CANASTER
Ca*nas"ter, n. Etym: [Sp. canasta, canastro, basket, fr. L.
canistrum. See Canister.]
Defn: A kind of tobacco for smoking, made of the dried leaves,
coarsely broken; -- so called from the rush baskets in which it is
packed in South America. McElrath.
CAN BUOY
Can" buoy`.
Defn: See under Buoy, n.
CANCAN
Can"can, n. Etym: [F.]
Defn: A rollicking French dance, accompanied by indecorous or
extravagant postures and gestures.
CANCEL
Can"cel, v. i. [Imp. & p. p. Canceled or Cancelled (; p. pr. & vb. n.
Canceling or Cancelling.] Etym: [L. cancellare to make like a
lattice, to strike or cross out (cf. Fr. canceller, OF. canceler) fr.
cancelli lattice, crossbars, dim. of cancer lattice; cf. Gr.
Chancel.}]



Result:

Array
(
    [ 0] => A
    [ 1] => CANARY
    [ 2] => CANARY
    [ 3] => BIRD
    [ 4] => A
    [ 5] => CANASTER
    [ 6] => L
    [ 7] => A
    [ 8] => CAN
    [ 9] => BUOY
    [ 10] => CANCAN
    [ 11] => F
    [ 12] => A
    [ 13] => CANCEL
    [ 14] => L
    [ 15] => OF
)



If it does the deed feel free to send a tip to 12VJryWvJaUNa9LWKVnY38Ds1YMqZjE8L1 otherwise this was a fun exercise ;)


Title: Re: PHP programmer needed
Post by: Bitsky on April 18, 2016, 07:56:19 PM
Why so complex?

Code:
<?php

$tmp 
= <<<EOF
4. A quick and lively dance. [Obs.]
Make you dance canary With sprightly fire and motion. Shak.

CANARY
Ca*na"ry, v. i.

Defn: To perform the canary dance; to move nimbly; to caper. [Obs.]
But to jig of a tune at the tongue's end, canary to it with your
feet. Shak.
CANARY BIRD
Ca*na"ry bird`. (Zoöl.)

Defn: A small singing bird of the Finch family (Serinus Canarius), a
native of the Canary Islands. It was brought to Europe in the 16th
century, and made a household pet. It generally has a yellowish body
with the wings and tail greenish, but in its wild state it is more
frequently of gray or brown color. It is sometimes called canary
finch.canary.

Canary bird flower (Bot.), a climbing plant (Tropæolum peregrinum)
with canary-colored flowers of peculiar form; -- called also canary
vine.

CANASTER
Ca*nas"ter, n. Etym: [Sp. canasta, canastro, basket, fr. L.
canistrum. See Canister.]

Defn: A kind of tobacco for smoking, made of the dried leaves,
coarsely broken; -- so called from the rush baskets in which it is
packed in South America. McElrath.

CAN BUOY
Can" buoy`.

Defn: See under Buoy, n.

CANCAN
Can"can, n. Etym: [F.]

Defn: A rollicking French dance, accompanied by indecorous or
extravagant postures and gestures.

CANCEL
Can"cel, v. i. [Imp. & p. p. Canceled or Cancelled (; p. pr. & vb. n.
Canceling or Cancelling.] Etym: [L. cancellare to make like a
lattice, to strike or cross out (cf. Fr. canceller, OF. canceler) fr.
cancelli lattice, crossbars, dim. of cancer lattice; cf. Gr.
Chancel.}]
EOF;

echo 
"<pre>";

preg_match_all('/[A-Z]{2,}/s'$tmp$ucwords);
print_r($ucwords[0]);

?>

Result:
Code:
Array
(
    [0] => CANARY
    [1] => CANARY
    [2] => BIRD
    [3] => CANASTER
    [4] => CAN
    [5] => BUOY
    [6] => CANCAN
    [7] => CANCEL
    [8] => OF
)


Title: Re: PHP programmer needed
Post by: bitspill on April 18, 2016, 11:53:56 PM
Why so complex?

Hehe, haven't touched php in a while and it was quite late. But I knew it was bad thus my comment about being a fun exercise and there being better ways ;)

I thought about a pure regex solution later but didn't know the function to cal, I was browsing the docs for each function  as I got to it because I couldn't remember them and I didn't feel like going back at it again, your solution is much better :P


Title: Re: PHP programmer needed
Post by: Redones on April 19, 2016, 01:05:21 AM
Really thank you so much for your reply,its done with VBA yesterday.


Title: Re: PHP programmer needed
Post by: Redones on April 19, 2016, 01:24:58 AM
Here is your 0.001 tip :

http://btc.blockr.io/tx/info/b33e94b321f2277354d68134f066069cd16b0c5ef53d314534a1399db416becb


Title: Re: PHP programmer needed
Post by: bitspill on April 19, 2016, 03:50:30 AM
LOL. Well ok. :P

Just tried to send half of that to Bitsky since his was a much better solution but forgot a zero  ;D
https://www.blocktrail.com/BTC/tx/469547a17e4e625799cc184324b14c1438c9be5fb63cd8f19da9e3d9973f5f5d


Title: Re: PHP programmer needed
Post by: Redones on April 19, 2016, 05:23:53 PM
LOL. Well ok. :P

Just tried to send half of that to Bitsky since his was a much better solution but forgot a zero  ;D
https://www.blocktrail.com/BTC/tx/469547a17e4e625799cc184324b14c1438c9be5fb63cd8f19da9e3d9973f5f5d

Get 0.001 And pay 0.005, Bitsky you are really lucky


Title: Re: PHP programmer needed
Post by: Bitsky on April 19, 2016, 07:19:17 PM
LOL. Well ok. :P

Just tried to send half of that to Bitsky since his was a much better solution but forgot a zero  ;D
https://www.blocktrail.com/BTC/tx/469547a17e4e625799cc184324b14c1438c9be5fb63cd8f19da9e3d9973f5f5d
Thanks! :)

Get 0.001 And pay 0.005, Bitsky you are really lucky
I don't think I'm going to complain ;)