Difference between revisions of "CodeReportSolutions"

From ZCubes Wiki
Jump to navigation Jump to search
Line 22: Line 22:
 
===z^3 Solution===
 
===z^3 Solution===
 
z=["--X","X++","X++"];
 
z=["--X","X++","X++"];
 +
// todo
 +
 +
==Count Negative Numbers in a Sorted Matrix==
 +
 +
Video: https://www.youtube.com/watch?v=bXsKo2ZhgTg
 +
 +
===z^3 Solution===
 +
 +
x=[-2,-1,0;-1,1,3;-1,2,4];
 +
(x⍌).findv(NEGATIVE)#
 +
 +
Gives answer 4
 +
 +
// ⍌ Flatten Array
 +
// findv Gives result of function call NEGATIVE
 +
// # Counts the result
 +
// Also note simpler z^3 Array Notation used to create the variable x (with optional , and ;). Usual Javascript array notations also work.
 +
// x=[-2 -1 0;-1 1 3;-1 2 4]; will also work to create the array.

Revision as of 22:39, 30 July 2024

Code Report Solutions

Following are some simple solutions to videos found on YouTube. Idea is to make it easier for comparing and learning z^3 and other beautiful languages.

Number of Different Integers in a String

Video: https://www.youtube.com/watch?v=59vAjBS3yZM [APL Wins (vs C++, Java & Python)]

z^3 Solution

s="ad3343sadfsd343434df343443sff"; (s#/[^\d]+/)∪

Result: 3343 343434 343443

  1. splits string using the postfix regexp pattern. ∪ extracts unique from the results

// 12 Character z^3 Solution vs. 14 Character APL Solution

Final Value of Variable After Performing Operations

Video: https://www.youtube.com/watch?v=8Njxgy4itts [4 APL Solutions in 10 Minutes!]

z^3 Solution

z=["--X","X++","X++"]; // todo

Count Negative Numbers in a Sorted Matrix

Video: https://www.youtube.com/watch?v=bXsKo2ZhgTg

z^3 Solution

x=[-2,-1,0;-1,1,3;-1,2,4]; (x⍌).findv(NEGATIVE)#

Gives answer 4

// ⍌ Flatten Array // findv Gives result of function call NEGATIVE // # Counts the result // Also note simpler z^3 Array Notation used to create the variable x (with optional , and ;). Usual Javascript array notations also work. // x=[-2 -1 0;-1 1 3;-1 2 4]; will also work to create the array.