Skip to main content
Commonmark migration
Source Link

#APL(NARS) 50 chars, 100 bytes

APL(NARS) 50 chars, 100 bytes

{'...'≢⍵∼⎕D:0⋄4≠≢w←⍵⊂⍨⍵≠'.':0⋄w≢⍕¨m←⍎¨w:0⋄256>⌈/m}

test:

  p←{'...'≢⍵∼⎕D:0⋄4≠≢w←⍵⊂⍨⍵≠'.':0⋄w≢⍕¨m←⍎¨w:0⋄256>⌈/m}
  {⍞←'[',⍵,'=',(p ⍵),']'⋄⍬}¨a 
[1.160.10.240= 1 ][192.001.32.47= 0 ][1.2.3.= 0 ][0.00.10.255= 0 ][1.2.$.4= 0 ][255.160.0.34= 1 ][.1.1.1= 0 ][1..1.1.1= 0 ][1.1.1.-0= 0 ][.1.1.+1= 0 ][1 1 1 1= 0 ][1= 0 ][10.300.4.0= 0 ][10.4F.10.99= 0 ][fruit loops= 0 ][1.2.3.4.5= 0 ][0.0.0.0= 1 ][0.0 0.0.= 0 ][1.23..4= 0 ][1:1:1:1:1:1:1:1= 0 ]  

#APL(NARS) 50 chars, 100 bytes

{'...'≢⍵∼⎕D:0⋄4≠≢w←⍵⊂⍨⍵≠'.':0⋄w≢⍕¨m←⍎¨w:0⋄256>⌈/m}

test:

  p←{'...'≢⍵∼⎕D:0⋄4≠≢w←⍵⊂⍨⍵≠'.':0⋄w≢⍕¨m←⍎¨w:0⋄256>⌈/m}
  {⍞←'[',⍵,'=',(p ⍵),']'⋄⍬}¨a 
[1.160.10.240= 1 ][192.001.32.47= 0 ][1.2.3.= 0 ][0.00.10.255= 0 ][1.2.$.4= 0 ][255.160.0.34= 1 ][.1.1.1= 0 ][1..1.1.1= 0 ][1.1.1.-0= 0 ][.1.1.+1= 0 ][1 1 1 1= 0 ][1= 0 ][10.300.4.0= 0 ][10.4F.10.99= 0 ][fruit loops= 0 ][1.2.3.4.5= 0 ][0.0.0.0= 1 ][0.0 0.0.= 0 ][1.23..4= 0 ][1:1:1:1:1:1:1:1= 0 ]  

APL(NARS) 50 chars, 100 bytes

{'...'≢⍵∼⎕D:0⋄4≠≢w←⍵⊂⍨⍵≠'.':0⋄w≢⍕¨m←⍎¨w:0⋄256>⌈/m}

test:

  p←{'...'≢⍵∼⎕D:0⋄4≠≢w←⍵⊂⍨⍵≠'.':0⋄w≢⍕¨m←⍎¨w:0⋄256>⌈/m}
  {⍞←'[',⍵,'=',(p ⍵),']'⋄⍬}¨a 
[1.160.10.240= 1 ][192.001.32.47= 0 ][1.2.3.= 0 ][0.00.10.255= 0 ][1.2.$.4= 0 ][255.160.0.34= 1 ][.1.1.1= 0 ][1..1.1.1= 0 ][1.1.1.-0= 0 ][.1.1.+1= 0 ][1 1 1 1= 0 ][1= 0 ][10.300.4.0= 0 ][10.4F.10.99= 0 ][fruit loops= 0 ][1.2.3.4.5= 0 ][0.0.0.0= 1 ][0.0 0.0.= 0 ][1.23..4= 0 ][1:1:1:1:1:1:1:1= 0 ]  
deleted 258 characters in body
Source Link
user58988
user58988

#APL(NARS) 5850 chars, 116100 bytes

{'...'≢⍵∼⎕D:0⋄4≠≢w←⍵⊂⍨⍵≠'.':0⋄w≢⍕¨⍎¨⍕¨m←⍎¨w0⋄w≢⍕¨m←⍎¨w:0⋄256≤⌈0⋄256>⌈/m:0⋄1}

test:

  p←{'...'≢⍵∼⎕D:0⋄4≠≢w←⍵⊂⍨⍵≠'.':0⋄w≢⍕¨⍎¨⍕¨m←⍎¨w0⋄w≢⍕¨m←⍎¨w:0⋄256≤⌈0⋄256>⌈/m:0⋄1}
  a←'1.160.10.240' '192.001.32.47' '1.2.3.' '0.00.10.255' '1.2.$.4' '255.160.0.34' '.1.1.1' '1..1.1.1' '1.1.1.-0' '.1.1.+1' '1 1 1 1' '1' '10.300.4.0' '10.4F.10.99' 'fruit loops' '1.2.3.4.5' '0.0.0.0' '0.0 0.0.' '1.23..4' '1:1:1:1:1:1:1:1'
  {⍞←'[',⍵,'=',(p ⍵),']'⋄⍬}¨a 
[1.160.10.240= 1 ][192.001.32.47= 0 ][1.2.3.= 0 ][0.00.10.255= 0 ][1.2.$.4= 0 ][255.160.0.34= 1 ][.1.1.1= 0 ][1..1.1.1= 0 ][1.1.1.-0= 0 ][.1.1.+1= 0 ][1 1 1 1= 0 ][1= 0 ][10.300.4.0= 0 ][10.4F.10.99= 0 ][fruit loops= 0 ][1.2.3.4.5= 0 ][0.0.0.0= 1 ][0.0 0.0.= 0 ][1.23..4= 0 ][1:1:1:1:1:1:1:1= 0 ]  

#APL(NARS) 58 chars, 116 bytes

{'...'≢⍵∼⎕D:0⋄4≠≢w←⍵⊂⍨⍵≠'.':0⋄w≢⍕¨⍎¨⍕¨m←⍎¨w:0⋄256≤⌈/m:0⋄1}

test:

  p←{'...'≢⍵∼⎕D:0⋄4≠≢w←⍵⊂⍨⍵≠'.':0⋄w≢⍕¨⍎¨⍕¨m←⍎¨w:0⋄256≤⌈/m:0⋄1}
  a←'1.160.10.240' '192.001.32.47' '1.2.3.' '0.00.10.255' '1.2.$.4' '255.160.0.34' '.1.1.1' '1..1.1.1' '1.1.1.-0' '.1.1.+1' '1 1 1 1' '1' '10.300.4.0' '10.4F.10.99' 'fruit loops' '1.2.3.4.5' '0.0.0.0' '0.0 0.0.' '1.23..4' '1:1:1:1:1:1:1:1'
  {⍞←'[',⍵,'=',(p ⍵),']'⋄⍬}¨a
[1.160.10.240= 1 ][192.001.32.47= 0 ][1.2.3.= 0 ][0.00.10.255= 0 ][1.2.$.4= 0 ][255.160.0.34= 1 ][.1.1.1= 0 ][1..1.1.1= 0 ][1.1.1.-0= 0 ][.1.1.+1= 0 ][1 1 1 1= 0 ][1= 0 ][10.300.4.0= 0 ][10.4F.10.99= 0 ][fruit loops= 0 ][1.2.3.4.5= 0 ][0.0.0.0= 1 ][0.0 0.0.= 0 ][1.23..4= 0 ][1:1:1:1:1:1:1:1= 0 ]  

#APL(NARS) 50 chars, 100 bytes

{'...'≢⍵∼⎕D:0⋄4≠≢w←⍵⊂⍨⍵≠'.':0⋄w≢⍕¨m←⍎¨w:0⋄256>⌈/m}

test:

  p←{'...'≢⍵∼⎕D:0⋄4≠≢w←⍵⊂⍨⍵≠'.':0⋄w≢⍕¨m←⍎¨w:0⋄256>⌈/m}
  {⍞←'[',⍵,'=',(p ⍵),']'⋄⍬}¨a 
[1.160.10.240= 1 ][192.001.32.47= 0 ][1.2.3.= 0 ][0.00.10.255= 0 ][1.2.$.4= 0 ][255.160.0.34= 1 ][.1.1.1= 0 ][1..1.1.1= 0 ][1.1.1.-0= 0 ][.1.1.+1= 0 ][1 1 1 1= 0 ][1= 0 ][10.300.4.0= 0 ][10.4F.10.99= 0 ][fruit loops= 0 ][1.2.3.4.5= 0 ][0.0.0.0= 1 ][0.0 0.0.= 0 ][1.23..4= 0 ][1:1:1:1:1:1:1:1= 0 ]  
deleted 425 characters in body
Source Link
user58988
user58988

#APL  (NARS), 104 characters 58 chars, 208116 bytes

{3≠+/⍵='.'...'≢⍵∼⎕D:0⋄4≠↑⍴w←(⍵≠'0⋄4≠≢w←⍵⊂⍨⍵≠'.')⊂⍵:0⋄∼∧/{''≡⍵∼'0123456789'∩⍵}¨w:0⋄(↑∘⍴¨w)≢1+⌊{⍵≤0:0⋄10⍟⍵}¨m←⍎¨w0⋄w≢⍕¨⍎¨⍕¨m←⍎¨w:0⋄256≤⌈/m:0⋄1}

The input has to be one string...testtest:

  p←{3≠+/⍵='.'...'≢⍵∼⎕D:0⋄4≠↑⍴w←(⍵≠'0⋄4≠≢w←⍵⊂⍨⍵≠'.')⊂⍵:0⋄∼∧/{''≡⍵∼'0123456789'∩⍵}¨w:0⋄(↑∘⍴¨w)≢1+⌊{⍵≤0:0⋄10⍟⍵}¨m←⍎¨w0⋄w≢⍕¨⍎¨⍕¨m←⍎¨w:0⋄256≤⌈/m:0⋄1}
  a←'1.160.10.240' '192.001.32.47' '1.2.3.' '0.00.10.255' '1.2.$.4' '255.160.0.34' '.1.1.1' '1..1.1.1' '1.1.1.-0' '.1.1.+1' '1 1 1 1' '1' '10.300.4.0' '10.4F.10.99' 'fruit loops' '1.2.3.4.5' '0.0.0.0' '0.0 0.0.' '1.23..4' '1:1:1:1:1:1:1:1'
  {'['⍞←'[',⍵,'=',(p ⍵),']'']'⋄⍬}¨a
[1.160.10.240= 1 ]  [192][192.001.32.47= 0 ]  [1][1.2.3.= 0 ]  [0][0.00.10.255= 0 ]  [1][1.2.$.4= 0 ]
[255][255.160.0.34= 1 ]  [][.1.1.1= 0 ]  [1][1..1.1.1= 0 ]  [1][1.1.1.-0= 0 ]  [][.1.1.+1= 0 ]  [1][1 1 1 1= 0 ]
[1=][1= 0 ]  [10][10.300.4.0= 0 ]  [10][10.4F.10.99= 0 ]  [fruit][fruit loops= 0 ]  [1][1.2.3.4.5= 0 ]][0.0.0.0= 1 [0][0.0 0.0.0== 0 ][1.23..4= 0 ][1:1:1:1:1:1:1:1= 0 ]  

Some explanation:

"If string ⍵ has number of points '.' different from 3 then return 0": "3≠+/⍵='.':0"

"Build the array of array of characters w cutting where there is the char '.' from ⍵; if len w is not 4, return 0": "4≠↑⍴w←(⍵≠'.')⊂⍵:0"

"If each element of w has some non-digit character then return 0": "∼∧/{''≡⍵∼'0123456789'∩⍵}¨w:0"

#APL  (NARS), 104 characters, 208 bytes

{3≠+/⍵='.':0⋄4≠↑⍴w←(⍵≠'.')⊂⍵:0⋄∼∧/{''≡⍵∼'0123456789'∩⍵}¨w:0⋄(↑∘⍴¨w)≢1+⌊{⍵≤0:0⋄10⍟⍵}¨m←⍎¨w:0⋄256≤⌈/m:0⋄1}

The input has to be one string...test

  p←{3≠+/⍵='.':0⋄4≠↑⍴w←(⍵≠'.')⊂⍵:0⋄∼∧/{''≡⍵∼'0123456789'∩⍵}¨w:0⋄(↑∘⍴¨w)≢1+⌊{⍵≤0:0⋄10⍟⍵}¨m←⍎¨w:0⋄256≤⌈/m:0⋄1}
  a←'1.160.10.240' '192.001.32.47' '1.2.3.' '0.00.10.255' '1.2.$.4' '255.160.0.34' '.1.1.1' '1..1.1.1' '1.1.1.-0' '.1.1.+1' '1 1 1 1' '1' '10.300.4.0' '10.4F.10.99' 'fruit loops' '1.2.3.4.5' '0.0.0.0'
  {'[',⍵,'=',(p ⍵),']'}¨a
[1.160.10.240= 1 ]  [192.001.32.47= 0 ]  [1.2.3.= 0 ]  [0.00.10.255= 0 ]  [1.2.$.4= 0 ]
[255.160.0.34= 1 ]  [.1.1.1= 0 ]  [1..1.1.1= 0 ]  [1.1.1.-0= 0 ]  [.1.1.+1= 0 ]  [1 1 1 1= 0 ]
[1= 0 ]  [10.300.4.0= 0 ]  [10.4F.10.99= 0 ]  [fruit loops= 0 ]  [1.2.3.4.5= 0 ]  [0.0.0.0= 1 ]

Some explanation:

"If string ⍵ has number of points '.' different from 3 then return 0": "3≠+/⍵='.':0"

"Build the array of array of characters w cutting where there is the char '.' from ⍵; if len w is not 4, return 0": "4≠↑⍴w←(⍵≠'.')⊂⍵:0"

"If each element of w has some non-digit character then return 0": "∼∧/{''≡⍵∼'0123456789'∩⍵}¨w:0"

#APL(NARS) 58 chars, 116 bytes

{'...'≢⍵∼⎕D:0⋄4≠≢w←⍵⊂⍨⍵≠'.':0⋄w≢⍕¨⍎¨⍕¨m←⍎¨w:0⋄256≤⌈/m:0⋄1}

test:

  p←{'...'≢⍵∼⎕D:0⋄4≠≢w←⍵⊂⍨⍵≠'.':0⋄w≢⍕¨⍎¨⍕¨m←⍎¨w:0⋄256≤⌈/m:0⋄1}
  a←'1.160.10.240' '192.001.32.47' '1.2.3.' '0.00.10.255' '1.2.$.4' '255.160.0.34' '.1.1.1' '1..1.1.1' '1.1.1.-0' '.1.1.+1' '1 1 1 1' '1' '10.300.4.0' '10.4F.10.99' 'fruit loops' '1.2.3.4.5' '0.0.0.0' '0.0 0.0.' '1.23..4' '1:1:1:1:1:1:1:1'
  {⍞←'[',⍵,'=',(p ⍵),']'⋄⍬}¨a
[1.160.10.240= 1 ][192.001.32.47= 0 ][1.2.3.= 0 ][0.00.10.255= 0 ][1.2.$.4= 0 ][255.160.0.34= 1 ][.1.1.1= 0 ][1..1.1.1= 0 ][1.1.1.-0= 0 ][.1.1.+1= 0 ][1 1 1 1= 0 ][1= 0 ][10.300.4.0= 0 ][10.4F.10.99= 0 ][fruit loops= 0 ][1.2.3.4.5= 0 ][0.0.0.0= 1 ][0.0 0.0.= 0 ][1.23..4= 0 ][1:1:1:1:1:1:1:1= 0 ]  
added 9 characters in body
Source Link
user58988
user58988
Loading
Copy edited (e.g. ref. <https://en.wiktionary.org/wiki/explanation#Noun> and <http://www.wikihow.com/Use-Than-and-Then>).
Source Link
Loading
Source Link
user58988
user58988
Loading