C#: 250c
(compiled to exe; assumes "line" means from stdin, so ran as type trianglesfile | counttri.exe
)
using System;using System.Linq;class P{static void Main(){int n=int.Parse(Console.ReadLine());var a=new string[n];while(--n>=0)a[n]=string.Join(":",Console.ReadLine().Split(' ').OrderBy(x=>x));Console.Write(a.GroupBy(s=>s).Count(g=>g.Count()==1));}}
Ungolfed:
using System;
using System.Linq;
class P
{
static void Main()
{
int n = int.Parse(Console.ReadLine()); // reads line from stdin; converts to int without validation
var a = new string[n];
while (--n >= 0)
a[n] = string.Join(":", // re-stringfy the following:
Console.ReadLine() // - read the next line
.Split(' ') // - splits by space to form an array of sides
.OrderBy(x => x) // - sorts by default comparison
);
Console.Write(
a.GroupBy(s => s) // group on the sorted, stringified value
.Count(g => g.Count() == 1) // count the number of groups which have 1 member
);
}
}
C#: 116c
(via LINQPad, in "C# Statements" mode; assumes "line" means any single line from an arbitrary string s
, definition not counted)
string s = @"5
1 2 3
2 1 3
4 5 6
3 1 2
8 7 6"; // <- input not included in overall count
Regex.Split(s,"\r\n").Skip(1).GroupBy(x=>string.Join(":",x.Split(' ').OrderBy(y=>y))).Count(g=>g.Count()==1).Dump();
Ungolfed:
string s = @"5
1 2 3
2 1 3
4 5 6
3 1 2
8 7 6"; // literal string definition, not counted
Regex.Split(s, "\r\n") // split on regex
.Skip(1) // who cares about the number of following lines?
.GroupBy(x => string.Join(":", // re-stringify the following:
x.Split(' ') // - split by space into sides array
.OrderBy(y => y))) // - sort sides array
.Count(g => g.Count() == 1) // count the number of groups that have 1 member
.Dump(); // Output into LINQPad results pane
side a: 1 -> side b: 3 -> side c: 5
\$\endgroup\$